thanks UFO! the reason about the player direction is because it started at level 3 (for quick editing, i forgot to take it out)
so the sprite was mirroed 2 times resulting is a sprite facting the wrong way. And ill change the transporter image to blue unstead of red
[EDIT] here is the source w/o the jump to level 3
Rem Project: 2D RPG
Rem Created: 1/9/2006 7:09:13 PM
Rem ***** Main Source *****
Menu:
if music exist (3) then delete music 3
load music "tracks/titlemusic.mp3",3
Do : CLS : Set text to normal : set text size 20 : set text font "times new roman" : set display mode 640,480,16
if Button(265,185,"[ New Game ]")=1 then Goto Intro
if Button(261,220,"[ Load Game ]")=1 then CLS : print "Load Function Not Implemented Yet, [press any key]" : wait key
if Button(235,80,"-Visit the forum page-")=1 then CLS : print "Please wait..." : wait 100 : execute file "http://forum.thegamecreators.com/?m=forum_view&t=69842&b=7","","" : end
if Button(284,260,"Credits")=1 then goto Credits
if Button(295,290,"Exit")=1 then end
if Button(245,420,"[ Admin Options ]")=1 then CLS : goto Admin_pass
loop
function Button(x1,y1,WORDS$)
Pressed=0
x2=Text Width(WORDS$)
y2=Text Height(WORDS$)
if mousex()>x1 and mousex()<x1+x2
if mousey()>y1-y2 and mousey()<y1+y2
Pressed=1
endif
endif
if pressed=1 then ink rgb(255,0,255),0 else ink rgb(200,255,0),0
if pressed=1
Pressed=Mouseclick()
else
pressed = 0
endif
text x1,y1,WORDS$
endfunction pressed
`Setup
Sync on : Sync Rate 60
set window on : maximize window
set display mode 1024,768,16
backgd=rgb(200,200,200)
dim backgd(0) : backgd(0)=backgd
`Initialize
Set text font "Tahoma"
Set text to normal
Set text size 20
cls backgd
Function Frame(Frame$,x,y,tx,ty)
ink rgb(128,128,128),0
line x,y+3,x,ty-3
line x+3,y,tx-3,y
line x+3,ty,tx-3,ty
line tx,y+3,tx,ty-3
dot x+1,y+1 : dot x+2,y+1 : dot x+1,y+2
dot x+1,ty-1 : dot x+2,ty-1 : dot x+1,ty-2
dot tx-1,y+1 : dot tx-2,y+1 : dot tx-1,y+2
dot tx-1,ty-1 : dot tx-2,ty-1 : dot tx-1,ty-2
ink backgd(0),0
box x+10,y-5,(x+text width(frame$))+20,y+5
ink rgb(0,0,0),0
text x+15,y-10,frame$
Endfunction
Function radio(r1$,x1,y1,r2$,x2,y2)
mx=mousex()
my=mousey()
mc=mouseclick()
ink rgb(100,100,100),0
circle x1,y1,10
circle x2,y2,10
if mx>x1-10 and mx<x1+10 and my>y1-10 and my<y1+10
if mc=1
radio=1
endif
endif
if mx>x2-10 and mx<x2+10 and my>y2-10 and my<y2+10
if mc=1
radio=2
endif
endif
if radio=1 and mc=0 then radio=1
if radio=2 and mc=0 then radio=2
if radio=1
for r=1 to 5
ink rgb(100,100,100),0
circle x1,y1,r
next r
for r=1 to 9
ink rgb(243,243,243),0
circle x2,y2,r
next r
endif
if radio=2
for r=1 to 5
ink rgb(100,100,100),0
circle x2,y2,r
next r
for r=1 to 9
ink rgb(243,243,243),0
circle x1,y1,r
next r
endif
ink rgb(0,0,0),0
text x1+15,y1-10,r1$
text x2+15,y2-10,r2$
Endfunction radio
Function Infobox(info$,x,y,sx)
ink rgb(0,0,0),0
box x,y,x+sx,y+30
ink rgb(255,255,255),0
box x+1,y+1,x+(sx-1),y+29
ink rgb(0,0,0),0
text x+5,y,info$
Endfunction
Admin_pass:
cls
input "Please enter the password: " ,password$
if password$ = "flowers"
goto Admin_settings
else
goto wrong
endif
wrong:
cls
print "Password Incorrect, Access Denied. [Press Spacekey]"
wait key
goto menu
Admin_settings:
` This code was downloaded from The Game Creators
` It is reproduced here with full permission
` http://www.thegamecreators.com
SET DISPLAY MODE 1024,768,16
CLS RGB(0,0,0)
` Prepare the array which stores all the index card information
type IndexType
x1 AS INTEGER
y1 AS INTEGER
x2 AS INTEGER
y2 AS INTEGER
Txt AS STRING
Font AS STRING
FontSize AS BYTE
ThreeD AS BYTE
TabHeight AS BYTE
CurrentTab AS BYTE
CardCol AS INTEGER
TxtCol AS INTEGER
ThreeDCol AS INTEGER
HiCol AS INTEGER
ShadCol AS INTEGER
NoOfTabs AS INTEGER
endtype
` You may have more than one set of index cards identified by the 'Number' variable
Number=1
DIM IndexCardData(Number) AS IndexType
` At the beginning of the programme define how the tabs will appear
` See the TabSetup function for description of the parameters
TabSetup(1,200,100,800,500,"2D RPG|To-Do List|TAB 3","Arial",15,2,20,RGB(125,125,125),RGB(0,0,0),RGB(150,150,150),RGB(255,255,255),RGB(0,0,0))
` Later in the program display the index cards
IndexCard(Number,1) : rem This time card 1 will be on top
` This is the main loop which monitors the pointer and clicking
Number=1 : rem This variable must be set to the value which identifies the index card set you are checking
do
set cursor screen width()/2-150, screen height()/2+250
set text size 25
ink rgb(255,0,255),0
print "Press [Spacekey] to go back"
if spacekey()=1 then goto menu
if MOUSECLICK()=1
MX=MOUSEX()
MY=MOUSEY()
` Check all tabs in turn
CardWidth=(IndexCardData(Number).x2-IndexCardData(Number).x1)/IndexCardData(Number).NoOfTabs
for Tab=1 TO IndexCardData(Number).NoOfTabs
TabStart=IndexCardData(Number).x1+(Tab-1)*CardWidth
` Was this tab clicked?
if MX>TabStart AND MX<TabStart+CardWidth AND MY>IndexCardData(Number).y1-IndexCardData(Number).TabHeight AND MY<IndexCardData(Number).y1
` This tab was clicked so redraw the index cards with this one on top
IndexCard(Number,Tab)
` Place here the gosubs or functions which draw what you require on the topmost
` index card and any other code to be executed after the card has been drawn
` Eg
IF Tab=2
set cursor 260,160
ink rgb(0,0,0),0
set text size 30
print "To Do List"
set text size 16
set cursor 260,210
print "1. Add more levels"
set cursor 260,227
print "2. Add S/LOAD functions"
ENDIF
` IF Tab=2
` GOSUB Routine_That_Draws_What_Is_On_Index_Card_Two
` ENDIF
endif
next Tab
endif
` Test for key press
loop
END
` Sets up set of index cards # Number for use later
function TabSetup(Number,x1,y1,x2,y2,TabText$,Font$,FontSize,ThreeD,TabHeight,CardCol,TxtCol,ThreeDCol,HiCol,ShadCol)
` Number = number allocated to this index card set
` x1, y1 = top left coordinates of the index cards
` x2, y2 = bottom right coordinates of the index cards
` TabText$ = word(s) that appear on the tabs separated with "|" character
` ThreeD = appearance of TabText$ on the tabs:
` normal if ThreeD=0
` embossed if ThreeD=1
` etched if ThreeD=2
` TabHeight= Height of all tabs
` CardCol = index card colour
` TextCol = Text$ colour
` ThreeDCol= ThreeD colour (used with embossing or etching)
` HiCol = highlight colour (brighter edges of the index card)
` ShadCol = shadow colour (also colour of 'shading' on inactive tab)
` NoOfTabs = No of tabs in this card set
` set (or reset) and store the index card set's data
IndexCardData(Number).x1=x1
IndexCardData(Number).y1=y1
IndexCardData(Number).x2=x2
IndexCardData(Number).y2=y2
IndexCardData(Number).Txt=TabText$
IndexCardData(Number).Font=Font$
IndexCardData(Number).FontSize=FontSize
IndexCardData(Number).ThreeD=ThreeD
IndexCardData(Number).TabHeight=TabHeight
IndexCardData(Number).CurrentTab=0 : rem default start value
IndexCardData(Number).CardCol=CardCol
IndexCardData(Number).TxtCol=TxtCol
IndexCardData(Number).ThreeDCol=ThreeDCol
IndexCardData(Number).HiCol=HiCol
IndexCardData(Number).ShadCol=ShadCol
NoOfTabs=0
for Pointer=1 TO LEN(TabText$)
if MID$(TabText$,Pointer)="|"then INC NoOfTabs
next Pointer
INC NoOfTabs
IndexCardData(Number).NoOfTabs=NoOfTabs
endfunction
` Displays index cards or changes existing set's appearance
function IndexCard(Number,CurrentTab)
` Number = Number allocated to this index card set
` CurrentTab = Number of the card to be drawn on top of the others
` Ensure that the tab's new state is different to its existing state
` and that it is therefore due to be drawn
` Ensure that the chosen card is not already on top
if IndexCardData(Number).CurrentTab<>CurrentTab
` Don't allow a zero value
if CurrentTab=0 then CurrentTab=Number
` Calculate card width
CardWidth=IndexCardData(Number).x2-IndexCardData(Number).x1+1
` Calculate tab width
TabWidth=CardWidth/IndexCardData(Number).NoOfTabs
` Draw the basic card
INK IndexCardData(Number).CardCol,0
BOX IndexCardData(Number).x1,IndexCardData(Number).y1,IndexCardData(Number).x2,IndexCardData(Number).y2
` Draw card set's shadowed edges
INK IndexCardData(Number).ShadCol,0
LINE IndexCardData(Number).x1,IndexCardData(Number).y2,IndexCardData(Number).x2,IndexCardData(Number).y2
LINE IndexCardData(Number).x2,IndexCardData(Number).y1,IndexCardData(Number).x2,IndexCardData(Number).y2
` Draw card set's highlighted edges
INK IndexCardData(Number).HiCol,0
LINE IndexCardData(Number).x1,IndexCardData(Number).y1,IndexCardData(Number).x1,IndexCardData(Number).y2
` Calculate position of top edge of tabs
TopEdge=IndexCardData(Number).y1-IndexCardData(Number).TabHeight
` Calculate position of the first card's tab's front edge
TabStart=IndexCardData(Number).x1
` Calculate position of the first card's tab's back edge
TabEnd=IndexCardData(Number).x1+TabWidth-1
TextPointer=1
for T=1 TO IndexCardData(Number).NoOfTabs
if T=IndexCardData(Number).NoOfTabs
` Adjust last card's tab's back edge if necessary to keep it in line with right hand edge of card
TabEnd=IndexCardData(Number).x2
endif
` Draw next tab's highlighted edges
INK IndexCardData(Number).HiCol,0
LINE TabStart,IndexCardData(Number).y1,TabStart,TopEdge+3
LINE TabStart,TopEdge+3,TabStart+3,TopEdge
LINE TabStart+3,TopEdge,TabEnd-3,TopEdge
if T<>CurrentTab then LINE TabStart,IndexCardData(Number).y1,TabEnd,IndexCardData(Number).y1
` Draw tab's shadowed edges
INK IndexCardData(Number).ShadCol,0
LINE TabEnd-3,TopEdge,TabEnd,TopEdge+3
LINE TabEnd,TopEdge+3,TabEnd,IndexCardData(Number).y1
` Flood fill the tab
INK IndexCardData(Number).CardCol,0
P1=TabStart+1
P2=P1+TabWidth-2
PT=POINT(P1,L)
for L=IndexCardData(Number).y1-1 TO TopEdge+1 STEP -1
if POINT(P1,L)<>PT
INC P1
DEC P2
endif
LINE P1,L,P2,L
next L
` Prepare for the text
SET TEXT TRANSPARENT
SET TEXT FONT IndexCardData(Number).Font
SET TEXT SIZE IndexCardData(Number).FontSize
FontHeight=IndexCardData(Number).FontSize
TabText$=IndexCardData(Number).Txt
` The variable where the tab's text will be stored temporarily
T$=""
` Seek out the relevant text for this tab
for Pointer=TextPointer TO LEN(TabText$)
if MID$(TabText$,Pointer)<>"|"
T$=T$+MID$(TabText$,Pointer)
else
INC TextPointer
Pointer=LEN(TabText$)+1
endif
next Pointer
INC TextPointer,LEN(T$)
Width=TEXT WIDTH(T$)
` Find the tab's horizontal mid point
MidTabX=TabStart+TabWidth/2
` Find the tab's vertical mid point - may need adjustment for different fonts
MidTabY=TopEdge+TabHeight/2
` Is the text embossed?
if IndexCardData(Number).ThreeD=1
INK IndexCardData(Number).ThreeDCol,0
` Draw the 3D effect for the text
TEXT MidTabX-Width/2-1,MidTabY+FontHeight/2-4,T$
endif
` Is the text etched?
if IndexCardData(Number).ThreeD=2
INK IndexCardData(Number).ThreeDCol,0
` Draw the 3D effect for the text
TEXT MidTabX-Width/2+1,MidTabY+FontHeight/2-4,T$
endif
INK IndexCardData(Number).TxtCol,0
` Draw the text to overlap the 3D effect
TEXT MidTabX-Width/2,MidTabY+FontHeight/2-4,T$
` Store the number of the index card that is now on top
IndexCardData(Number).CurrentTab=CurrentTab
` Adjust pointers for next tab
INC TabStart,TabWidth
INC TabEnd,TabWidth
next T
endif
endfunction
Intro:
CLS
input "Please enter a profile name: ",char_name$
loop music 3
do: CLS
set text to normal
texty#=texty#-0.05
ink rgb(255,0,0),0
set text font "Bodoni MT"
set text size 18
set cursor 0,0
set cursor screen width()/2,texty#+180
center text screen width()/2,texty#+180,"Your name is Matt Kalaway. You are the rightfull prince"
center text screen width()/2,texty#+195,"of the Shanotop palace. An imposter caught you while you where"
center text screen width()/2,texty#+210,"in your sleep. You where still a prisoner to your dreams when"
center text screen width()/2,texty#+225,"you awoke and found yourself prisoner to another foe..."
center text screen width()/2,texty#+240,"...Another enemy..."
center text screen width()/2,texty#+255,"...Another grudge to hold for eternity. You, Matt Kalaway must"
center text screen width()/2,texty#+270,"fight your way threw the rat infested tunnels of your own"
center text screen width()/2,texty#+285,"dungeon. You must gain revenge on this imposter... this destroyer..."
center text screen width()/2,texty#+300,""
center text screen width()/2,texty#+315,"Use the arrowkeys to move and spacekey to jump. Use the control key"
center text screen width()/2,texty#+330,"to use your frost shock ability (To activate this you must collect the artifact first)"
center text screen width()/2,texty#+345,"Shoot the target to relocate special platforms!"
center text screen width()/2,texty#+360,""
center text screen width()/2,texty#+375,"Good Luck, Matt"
set text size 15
center text screen width()/2,texty#+400,"[Press the spacekey to continue]"
if spacekey()=1 then stop music 3 : goto Loading_bar
loop
credits:
ink rgb(255,255,255),0
cls:texty2#=screen height()
Do : CLS : Set text to normal
texty2#=texty2#-0.50
set text size 20
center text screen width()/2,texty2#,"2D RPG [Open Source Game]"
set text to normal
set text size 15
center text screen width()/2,texty2#+20,"Created by: Snowfall Studios, Smallg, and Darklord"
set text size 12
center text screen width()/2,texty2#+40,"Programmers: Snowfall Studios, Smallg, and Darklord"
center text screen width()/2,texty2#+60,"2D Arts: David Gervais"
center text screen width()/2,texty2#+80,"Music: Matt McFarland"
center text screen width()/2,texty2#+100,"Sound FX: The Game Creators"
center text screen width()/2,texty2#+120,"Programming language: DarkBASIC Pro"
set text size 15
set text to bold
center text screen width()/2,texty2#+155,"Press the return key to continue"
if returnkey()=1 then goto menu
sync
loop
Loading_bar:
set text size 18
ink rgb(255,255,255),0
do
set cursor 200,200
box 10,40,110,50
for i=1 to 100 : cls : ink rgb(255,100,100),0 : text 10,20,"loading..." : ink rgb(255,0,0),0 : box 10,40,30+i,50 : wait 20 : sync : next i : goto START
loop
START:
autocam off
make_menu()
add_drop("File ")
add_sub_drop(1,"Exit Game") : ` sub drop 1
add_drop("Game Options")
add_sub_drop(2,"Save Game") : ` sub drop 1
add_sub_sub_drop(2,1,"Not implemented yet")
add_sub_drop(2,"Load Game") : ` sub drop 2
add_sub_sub_drop(2,2,"No games saved")
Rem Set-up the game
sync on : sync rate 30
backdrop on : color backdrop rgb(0,0,0) : hide mouse
disable escapekey : set text font "arial"
CLS
`delete all sprites
for rat=98 to 100
if sprite exist(rat) then delete sprite rat
next rat
for tile=2 to 30
if sprite exist(tile) then delete sprite tile
next tile
if sprite exist(1) then delete sprite 1
`reset all variables
x# = 100 : y# = 200
oldx# = x# : oldy# = y#
grav# = 0
health = 100 : mana = 100
ground = 2 : ground2 = 10
dim rat_dead(3)
for rat=1 to 3
rat_dead(rat)=0
next rat
right98=0 : right99=0 : right100=1
force=0 : flip#=0 : using_force=0 : attacking=0
x98=375 : y98=435
x99=620 : y99=435
x100=61 : y100=64
tmoved=0
artifact = 1
recharge=timer()
btimer=timer()
potion=1
potion2=0
totalmana = 100
totalhealth = 100
save = 0
load = 0
Rem Create the player sprite
Load image "sprites/hero1.png", 1
load image "sprites/hero2.png",35
sprite 1,x#,y#,1
Rem Load in the floor
Load image "sprites/ground1.png", 2
`load images
load image "sprites/wall2.png", 1000
load image "sprites/wall3.png", 1001
load image "sprites/wall4.png", 1002
load image "sprites/wall1.png", 3
load image "sprites/wall5.png", 1003
load image "sprites/wall6.png", 1004
load image "misc/cursor.bmp",36
`load music
load music "tracks/track1.mp3",1
`load sounds
load sound "sounds/weapon.wav",1
load sound "sounds/ping.wav",2
load sound "sounds/power up 1.wav",3
load sound "sounds/torpedo.wav",4
load sound "sounds/button1.wav",5
load sound "sounds/button2.wav",6
`set up upside down teleporters
sprite 15,639,49,1002
rotate sprite 15,180
`make a few enemies
load image "sprites/rat1.png",98
sprite 100,x100,y100,98 : mirror sprite 100 : right100=1
`upgrades
load image "sprites/force.png",100
load image "sprites/potion.png",32
load image "sprites/mpotion.png",33
load image "sprites/armor1.png",34
`-----------------------------------------_-------------------------------------------
`________________________-----------------------------------__________________________
`------------------------ L-E-V-E-L O-N-E L-O-O-P
`-----------------------------------------_-------------------------------------------
`________________________-----------------------------------__________________________
level1_loop:
do
`Always put cursor where the mouse is
sprite 1001,mousex(),mousey(),36
set cursor 0,10
return$=update_menu()
if return$="Save Game" then save = 1 : play sound 5
if return$="Load Game" then load = 1 : play sound 5
if return$="Exit Game" then end
loop music 1
show all sprites
if mana<99
if timer()>recharge+900 then inc mana,2 : recharge=timer()
endif
Rem update the old variables
oldx# = x#
oldy# = y#
if escapekey()=1
do
CLS
ink rgb(255,0,0),0
center text 320,240,"Paused - Press [Space Bar] to continue or [Q] to exit"
if spacekey()=1 then exit
if keystate(16) then end
sync
loop
endif
Rem control the player with the keyboard
`move left
if leftkey()=1
x#=x#-5
`If if is not flipped the right way then flip it
if leftkey() and flip# = 0
mirror sprite 1
flip# = 1
endif
endif
`Move right
if rightkey()
x#=x#+5
`If if is not flipped the right way then flip it
if rightkey() and flip# = 1
mirror sprite 1
flip# = 0
endif
endif
`Jumping
if spacekey() and grav# = 0 then y# = y# -60
grav# = grav# - 1
y# = y# - grav#
Rem Update sprites
sprite 1,x#,y#,1
sprite 2,0,450,2
sprite 3,100,419,3
sprite 4,125,419,3
sprite 5,160,390,3
sprite 6,160,419,3
sprite 7,250,365,3
sprite 8,290,332,1000
sprite 9,285,365,3
sprite 10,400,386,1001
sprite 11,552,349,3
sprite 12,610,303,1002
sprite 13,610,200,3
sprite 14,500,200,3
sprite 15,639,49,1002
sprite 16,400,200,3
sprite 17,300,200,3
sprite 18,300,200,1002
sprite 19,300,80,3
sprite 20,270,80,3
sprite 21,240,80,3
sprite 22,210,80,3
sprite 23,180,80,3
sprite 24,150,80,3
sprite 25,120,80,3
sprite 26,90,80,3
sprite 27,60,80,3
sprite 28,30,80,3
sprite 29,0,80,3
sprite 30,0,48,1000
sprite 31,4200,17000,1003
if potion=1 then sprite 51,410,175,32
if potion2=1 then sprite 52,410,175,32
`reset enemies
if rat_dead(1)=0 then sprite 98,x98,y98,98
if rat_dead(2)=0 then sprite 99,x99,y99,98
if rat_dead(3)=0 then sprite 100,x100,y100,98
Rem Display info
set cursor 0,0
ink rgb(255,0,0),0
set cursor X#,Y#-26
print "Health: ",health," / ",totalhealth
ink rgb(0,0,255),0
set cursor X#,Y#-15
print "Mana: ",mana," / ",totalmana
`print "Artifact" over it
if artifact = 1 then text 37,420,"Artifact"
if sprite collision(1,2)
y# = y# + 1000
grav# = 0.0
endif
if sprite collision(1,12) then oldy# = y# - 150 : play sound 3
if sprite collision(1,18) then oldy# = y# - 230 : play sound 3
`set collision to boxes
for boxes = 2 to 30
if sprite collision(1,boxes)
if sprite y(1)>sprite y(boxes) then x#=oldx#
y# = oldy#
grav# = 0.0
endif
next boxes
`player and rat collisions
for rat=98 to 100
`rat attacks player
if sprite exist(rat)
if sprite collision(1,rat)
x#=oldx#
dec health,2
endif
`player attacks rat
if spacekey() and attacking<20 : `stops player from holding down space
inc attacking,1
if sprite collision(1,rat) then delete sprite rat : rat_dead(rat-97)=1
endif
endif
next rat
if spacekey()=0 then attacking=0
`upgrade
if force=0 then sprite 200,50,438,100
`make it so that players health cant go over 100
if health > 100 then health = 100
`make it so that if players health is already 100 then print if it hits the potion
if sprite exist (1) and sprite exist (51)
if sprite collision(1,51) and health = 100
ink rgb(255,0,0),0
text X#-30,Y#-15,"You already have full health"
endif
endif
`check if player gets life potion
if sprite exist(51)
if sprite collision(1,51) and health<totalhealth
delete sprite 51 : health=health + 25 : potion=0 : play sound 3
endif
endif
`check if player gains force
if sprite exist(200)
if sprite collision(1,200) then force=1 : inc mana,30 : play sound 2 : delete sprite 200 : artifact = 0
if mana > totalmana then mana = totalmana
endif
`check if player uses force
if force=1 and using_force=0
if controlkey()=1
if mana>25 and timer()>btimer+2000 : btimer=timer()
load image "sprites/force blast.png",101 : play sound 1 : blast_life=10 : using_force=1 : mana=mana-25
if flip#=0 then sprite 101,x#+15,y#+5,101 : right_blast=1
if flip#=1 then sprite 101,x#-15,y#+5,101 : right_blast=0
endif
endif
endif
`update force blast
if sprite exist(101)
x101=sprite x(101) : y101=sprite y(101)
if blast_life>0 and right_blast=1 then sprite 101,x101+6,y101,101
if blast_life>0 and right_blast=0 then sprite 101,x101-6,y101,101
dec blast_life,1
endif
`check if force hits wall
for tile=2 to 30
if sprite exist(101)
if sprite collision(101,tile) then delete sprite 101 : using_force=0
endif
next tile
`check if force hits a rat
for rat=98 to 100
if sprite exist(101) and sprite exist(rat)
if sprite collision(101,rat) then delete sprite 101 : delete sprite rat : using_force=0 : rat_dead(rat-97)=1
endif
next rat
if blast_life=0 and sprite exist(101) then delete sprite 101 : using_force=0
`move rats
if sprite exist(98)
if x98>195 and right98=0 then dec x98,1
if x98=195 then mirror sprite 98 : right98=1
if x98<375 and right98=1 then inc x98,1
if x98=375 then mirror sprite 98 : right98=0
endif
if sprite exist(99)
if x99>500 and right99=0 then dec x99,1
if x99=500 then mirror sprite 99 : right99=1
if x99<620 and right99=1 then inc x99,1
if x99=620 then mirror sprite 99 : right99=0
endif
if sprite exist(100)
if x100>60 and right100=0 then dec x100,1
if x100=60 then mirror sprite 100 : right100=1
if x100<300 and right100=1 then inc x100,1
if x100=300 then mirror sprite 100 : right100=0
endif
`set sprite alpha
set sprite alpha 1,150
set sprite alpha 2,150
if sprite exist (51) then set sprite alpha 51,120
`set left collision
If x# < 1 then x# = 1
If x# > 640 then x# = 640
`set top collision
If y# < 1 then y# = 1
If y# > 480 then y# = 1
`set right collision
If x# > 610 then x# = 610
if health <= 0
CLS : hide all sprites
do
ink rgb(255,0,0),0
center text 320,240,"Your health has reached 0 and you died"
center text 320,260,"- Press escape to quit -"
sync
if escapekey()=1 then ALERT_i("Check for updates!","Alert.") : end
loop
endif
`Set win
if sprite collision(1,30)
CLS : hide all sprites
do
ink rgb(255,0,0),0
center text 320,240,"Congratulations, you have completed level 1!"
center text 320,260,"- Press return to continue or escape to quit -"
sync
if returnkey() then goto level2_setup
if escapekey()=1 then end
loop
endif
Rem Update the screen
sync
loop
`-----------------------------------------_-------------------------------------------
`________________________-----------------------------------__________________________
`------------------------ L-E-V-E-L T-W-O L-O-O-P
`-----------------------------------------_-------------------------------------------
`________________________-----------------------------------__________________________
level2_setup:
`Delete potion if it currently exists:
if sprite exist(51) then delete sprite 51
`reset all variables
x# = 100 : y# = 200
oldx# = x# : oldy# = y#
grav# = 0
ground = 2 : ground2 = 10
dim rat_dead(3)
for rat=1 to 3
rat_dead(rat)=0
next rat
right98=0 : right99=0 : right100=1
force=0 : flip#=0 : mirror sprite 1 : using_force=0 : attacking=0
x98=375 : y98=435
x99=620 : y99=435
x100=61 : y100=64
tmoved=0
recharge=timer()
btimer=timer()
artifact = 1
Hide Mouse
`recreate enemies just encase there was glitch =D
if sprite exist (98) then delete sprite 98
if sprite exist (99) then delete sprite 99
if sprite exist (100) then delete sprite 100
sprite 100,x100,y100,98 : mirror sprite 100 : right100=1
show all sprites
x# = 100 : y# = 200
`Set sprite that moves in position before main loop so it can move:
sprite 15,470,49,1002
`Position target before hand
sprite 31,420,170,1003
`goto the main loop
goto level2_loop
level2_loop:
do
`Always put cursor where the mouse is
sprite 1001,mousex(),mousey(),36
set cursor 0,10
return$=update_menu()
if return$="Exit Game" then end
loop music 1
if mana<99
if timer()>recharge+900 then inc mana,2 : recharge=timer()
endif
Rem update the old variables
oldx# = x#
oldy# = y#
if escapekey()=1
do
CLS
ink rgb(255,0,0),0
center text 320,240,"Paused - Press [Space Bar] to continue or [Q] to exit"
if spacekey()=1 then exit
if keystate(16) then end
sync
loop
endif
Rem control the player with the keyboard
`move left
if leftkey()=1
x#=x#-5
`If if is not flipped the right way then flip it
if leftkey() and flip# = 0
mirror sprite 1
flip# = 1
endif
endif
`Move right
if rightkey()
x#=x#+5
`If if is not flipped the right way then flip it
if rightkey() and flip# = 1
mirror sprite 1
flip# = 0
endif
endif
`Jumping
if spacekey() and grav# = 0 then y# = y# -60
grav# = grav# - 1
y# = y# - grav#
Rem Update sprites
sprite 1,x#,y#,1
sprite 2,0,450,2
sprite 3,5000,419,3
sprite 4,0,419,3
sprite 5,0,390,3
sprite 6,160,419,3
sprite 7,250,365,3
sprite 8,5000,332,1000
sprite 9,285,365,3
sprite 10,400,386,1001
sprite 11,552,349,3
sprite 12,461,356,1002
sprite 13,0,450,3
sprite 14,570,200,3
sprite 16,600,200,3
sprite 17,300,200,3
sprite 18,300,200,1002
sprite 19,300,80,3
sprite 20,270,80,3
sprite 21,240,80,3
sprite 22,210,80,3
sprite 23,180,80,3
sprite 24,150,80,3
sprite 25,120,80,3
sprite 26,90,80,3
sprite 27,60,80,3
sprite 28,30,80,3
sprite 29,0,80,3
sprite 30,0,48,1000
`reset enemies
if rat_dead(1)=0 then sprite 98,x98,y98,98
if rat_dead(2)=0 then sprite 99,x99,y99,98
if rat_dead(3)=0 then sprite 100,x100,y100,98
Rem Display info
set cursor 0,0
ink rgb(255,0,0),0
set cursor X#,Y#-26
print "Health: ",health," / ",totalhealth
ink rgb(0,0,255),0
set cursor X#,Y#-15
print "Mana: ",mana," / ",totalmana
`print "Artifact" over it
if artifact = 1 then text 37,420,"Artifact"
if sprite collision(1,2)
y# = y# + 1000
grav# = 0.0
endif
if sprite collision(1,12) then oldy# = y# - 230 : play sound 3
if sprite collision(1,18) then oldy# = y# - 230 : play sound 3
`set collision to boxes
for boxes = 2 to 30
if sprite collision(1,boxes)
if sprite y(1)>sprite y(boxes) then x#=oldx#
y# = oldy#
grav# = 0.0
endif
next boxes
`player and rat collisions
for rat=98 to 100
`rat attacks player
if sprite exist(rat)
if sprite collision(1,rat)
x#=oldx#
dec health,2
endif
`player attacks rat
if spacekey() and attacking<20 : `stops player from holding down space
inc attacking,1
if sprite collision(1,rat) then delete sprite rat : rat_dead(rat-97)=1
endif
endif
next rat
if spacekey()=0 then attacking=0
`upgrade
if force=0 then sprite 200,50,438,100
`check if player gains force
if sprite exist(200)
if sprite collision(1,200) then force=1 : play sound 2 : artifact = 0 : delete sprite 200
endif
`check if player uses force
if force=1 and using_force=0
if controlkey()=1
if mana>25 and timer()>btimer+2000 : btimer=timer()
load image "sprites/force blast.png",101 : play sound 1 : blast_life=25 : using_force=1 : mana=mana-25
if flip#=0 then sprite 101,x#+15,y#+5,101 : right_blast=1
if flip#=1 then sprite 101,x#-15,y#+5,101 : right_blast=0
endif
endif
endif
`update force blast
if sprite exist(101)
x101=sprite x(101) : y101=sprite y(101)
if blast_life>0 and right_blast=1 then sprite 101,x101+6,y101,101
if blast_life>0 and right_blast=0 then sprite 101,x101-6,y101,101
dec blast_life,1
endif
`check if force hits wall
for tile=2 to 30
if sprite exist(101)
if sprite collision(101,tile) then delete sprite 101 : using_force=0
endif
next tile
`check if force hits a rat
for rat=98 to 100
if sprite exist(101) and sprite exist(rat)
if sprite collision(101,rat) then delete sprite 101 : delete sprite rat : using_force=0 : rat_dead(rat-97)=1
endif
next rat
if blast_life=0 and sprite exist(101) then delete sprite 101 : using_force=0
`Target:
for target=31 to 31
if sprite exist(101) and sprite exist(31)
if sprite collision(101,31) then move sprite 31,3000 : move sprite 15,130
endif
next target
`move rats
if sprite exist(98)
if x98>195 and right98=0 then dec x98,1
if x98=195 then mirror sprite 98 : right98=1
if x98<375 and right98=1 then inc x98,1
if x98=375 then mirror sprite 98 : right98=0
endif
if sprite exist(99)
if x99>500 and right99=0 then dec x99,1
if x99=500 then mirror sprite 99 : right99=1
if x99<620 and right99=1 then inc x99,1
if x99=620 then mirror sprite 99 : right99=0
endif
if sprite exist(100)
if x100>60 and right100=0 then dec x100,1
if x100=60 then mirror sprite 100 : right100=1
if x100<300 and right100=1 then inc x100,1
if x100=300 then mirror sprite 100 : right100=0
endif
`set sprite alpha
set sprite alpha 1,150
set sprite alpha 2,150
`set left collision
If x# < 1 then x# = 1
If x# > 640 then x# = 640
`set top collision
If y# < 1 then y# = 1
If y# > 480 then y# = 1
`set right collision
If x# > 610 then x# = 610
`set player death
if health <= 0
CLS : hide all sprites
do
ink rgb(255,0,0),0
center text 320,240,"Your health has reached 0 and you died"
center text 320,260,"- Press escape to quit -"
sync
if escapekey()=1 then ALERT_i("Check for updates!","Alert.") : end
loop
endif
`Set win
if sprite collision(1,30)
CLS : hide all sprites
do
ink rgb(255,0,0),0
center text 320,240,"Congratulations, you have completed level 2!"
center text 320,260,"- Press return to continue or escape to quit -"
sync
if escapekey()=1 then end
if returnkey()=1 then goto level3_setup
loop
endif
Rem Update the screen
sync
loop
`-----------------------------------------_-------------------------------------------
`________________________-----------------------------------__________________________
`------------------------ L-E-V-E-L T-H-R-E-E L-O-O-P
`-----------------------------------------_-------------------------------------------
`________________________-----------------------------------__________________________
level3_setup:
`Delete potion if it currently exists:
if sprite exist(51) then delete sprite 51
`reset all variables
x# = 100 : y# = 200
oldx# = x# : oldy# = y#
grav# = 0
ground = 2 : ground2 = 10
dim rat_dead(3)
for rat=1 to 3
rat_dead(rat)=0
next rat
right98=0 : right99=0 : right100=1
force=0 : flip#=0 : mirror sprite 1 : using_force=0 : attacking=0
x98=375 : y98=435
x99=620 : y99=435
x100=61 : y100=64
tmoved=0
recharge=timer()
btimer=timer()
artifact = 1 : potion2 = 1 : armor1 = 1 : hero2t = 0
`recreate enemies just encase there was glitch =D
if sprite exist (98) then delete sprite 98
if sprite exist (99) then delete sprite 99
if sprite exist (100) then delete sprite 100
sprite 100,x100,y100,98 : mirror sprite 100 : right100=1
show all sprites
x# = 56 : y# = 300
`Set sprite that moves in position before main loop so it can move:
sprite 15,470,49,1002
sprite 29,0,140,3
`Position target before hand
sprite 31,420,170,1003
sprite 32,150,130,1003
hide mouse
`goto the main loop
`goto level3_loop
level3_loop:
do
`Always put cursor where the mouse is
sprite 1001,mousex(),mousey(),36
set cursor 0,10
return$=update_menu()
if return$="Exit Game" then end
show all sprites
loop music 1
if mana<99
if timer()>recharge+900 then inc mana,2 : recharge=timer()
endif
Rem update the old variables
oldx# = x#
oldy# = y#
if escapekey()=1
do
CLS
ink rgb(255,0,0),0
center text 320,240,"Paused - Press [Space Bar] to continue or [Q] to exit"
if spacekey()=1 then exit
if keystate(16) then end
sync
loop
endif
Rem control the player with the keyboard
`move left
if leftkey()=1
x#=x#-5
`If if is not flipped the right way then flip it
if leftkey() and flip# = 0
mirror sprite 1
flip# = 1
endif
endif
`Move right
if rightkey()
x#=x#+5
`If if is not flipped the right way then flip it
if rightkey() and flip# = 1
mirror sprite 1
flip# = 0
endif
endif
`Jumping
if spacekey() and grav# = 0 then y# = y# -60
grav# = grav# - 1
y# = y# - grav#
Rem Update sprites
sprite 1,X#,Y#,1
sprite 2,0,450,2
sprite 3,5000,419,3
sprite 4,0,419,3
sprite 5,0,390,3
sprite 6,160,419,3
sprite 7,250,365,3
sprite 8,5000,332,1000
sprite 9,285,365,3
sprite 10,0,386,1001
sprite 11,552,349,3
sprite 12,461,356,1002
sprite 13,0,450,3
sprite 14,570,200,3
sprite 16,600,200,3
sprite 17,300,200,3
sprite 18,300,200,1002
sprite 19,300,80,3
sprite 20,270,80,3
sprite 21,240,80,3
sprite 22,210,80,3
sprite 23,180,80,3
sprite 24,150,80,3
sprite 25,120,80,3
sprite 26,90,80,3
sprite 27,60,80,3
sprite 28,40,80,3
sprite 30,-5000,38,1000
sprite 33,40,80,3
sprite 34,40,97,3
sprite 35,40,122,3
sprite 36,40,152,3
sprite 37,0,250,3
sprite 38,25,250,3
sprite 39,50,250,3
sprite 40,75,250,3
sprite 41,100,250,3
sprite 42,105,218,1000
if potion2=1 then sprite 52,316,52,33
if armor1 =1 then sprite 53,45,46,34
if hero2t =1 then sprite 1,X#,Y#,35
`reset enemies
if rat_dead(1)=0 then sprite 98,x98,y98,98
if rat_dead(2)=0 then sprite 99,x99,y99,98
if rat_dead(3)=0 then sprite 100,x100,y100,98
Rem Display info
set cursor 0,0
ink rgb(255,0,0),0
set cursor X#,Y#-26
print "Health: ",health," / ",totalhealth
ink rgb(0,0,255),0
set cursor X#,Y#-15
print "Mana: ",mana," / ",totalmana
`print "Artifact" over it
if artifact = 1 then text 37,350,"Artifact"
if sprite collision(1,2)
y# = y# + 1000
grav# = 0.0
endif
if sprite collision(1,12) then oldy# = y# - 220 : play sound 3
if sprite collision(1,18) then oldy# = y# - 230 : play sound 3
`set collision to boxes
for boxes = 2 to 30
if sprite collision(1,boxes)
if sprite y(1)>sprite y(boxes) then x#=oldx#
y# = oldy#
grav# = 0.0
endif
next boxes
`Collision to the rest of the boxes
for moreboxes = 33 to 42
if sprite collision(1,moreboxes)
if sprite y(1)>sprite y(moreboxes) then x#=oldx#
y# = oldy#
grav# = 0.0
endif
next moreboxes
`player and rat collisions
for rat=98 to 100
`rat attacks player
if sprite exist(rat)
if sprite collision(1,rat)
x#=oldx#
dec health,2
endif
`player attacks rat
if spacekey() and attacking<20 : `stops player from holding down space
inc attacking,1
if sprite collision(1,rat) then delete sprite rat : rat_dead(rat-97)=1
endif
endif
next rat
if spacekey()=0 then attacking=0
`upgrade
if force=0 then sprite 200,50,368,100
`check if player gains force
if sprite exist(200)
if sprite collision(1,200) then force=1 : inc mana,30 : play sound 2 : artifact = 0 : delete sprite 200
endif
`check if player uses force
if force=1 and using_force=0
if controlkey()=1
if mana>25 and timer()>btimer+2000 : btimer=timer()
load image "sprites/force blast.png",101 : play sound 1 : blast_life=25 : using_force=1 : mana=mana-25
if flip#=0 then sprite 101,x#+15,y#+5,101 : right_blast=1
if flip#=1 then sprite 101,x#-15,y#+5,101 : right_blast=0
endif
endif
endif
`update force blast
if sprite exist(101)
x101=sprite x(101) : y101=sprite y(101)
if blast_life>0 and right_blast=1 then sprite 101,x101+6,y101,101
if blast_life>0 and right_blast=0 then sprite 101,x101-6,y101,101
dec blast_life,1
endif
`check if force hits wall
for tile=2 to 30
if sprite exist(101)
if sprite collision(101,tile) then delete sprite 101 : using_force=0
endif
next tile
`check if force hits a rat
for rat=98 to 100
if sprite exist(101) and sprite exist(rat)
if sprite collision(101,rat) then delete sprite 101 : delete sprite rat : using_force=0 : rat_dead(rat-97)=1
endif
next rat
if blast_life=0 and sprite exist(101) then delete sprite 101 : using_force=0
`Target:
for target=31 to 31
if sprite exist(101) and sprite exist(target)
if sprite collision(101,target) then move sprite target,3000 : move sprite 15,130
endif
next target
`Target2:
for target2=32 to 32
if sprite exist(101) and sprite exist(target2)
if sprite collision(101,target2) then move sprite target2,3000 : move sprite 29,70
endif
next target2
`make it so that players mana cant go over 100
if mana > totalmana then mana = totalmana
`make it so that if players health is already 100 then print if it hits the potion
if sprite exist (1) and sprite exist (52)
if sprite collision(1,52) and mana = totalmana
ink rgb(255,0,0),0
text X#-30,Y#-15,"You already have full mana"
endif
endif
`check if player gets red armor
if sprite exist(53)
if sprite collision(1,53)
ink rgb(255,0,0),0
set text size 12
text X#+100,Y#-25,"Item drop:"
text X#+100,Y#-10,"Red Dragon Armor: [+30 total mana]"
text X#+100,Y#+5, "press [Enter] to pick it up"
if returnkey()=1
stop music 1
delete sprite 53 : armor1=0 : play sound 3 : totalmana = totalmana + 30 : hero2t = 1 : play sound 4
do
hide all sprites
CLS
set text to bold
ink rgb(255,255,0),0
set text size 50
text 100,200,"ARMOR UP! +30 MANA"
set text size 16
set text to normal
center text 320,260,"-Press Spacekey To Continue-"
if spacekey()=1 then exit
sync
loop
endif
endif
endif
`check if player gets mana potion
if sprite exist(52)
if sprite collision(1,52) and mana<totalmana
delete sprite 52 : mana=mana + 25 : potion2=0 : play sound 3
endif
endif
`check if player has full mana
if sprite exist (1) and sprite exist (52)
if sprite collision(1,52) and mana = 100
ink rgb(255,0,0),0
text X#-30,Y#-15,"You already have full mana"
endif
endif
`move rats
if sprite exist(98)
if x98>195 and right98=0 then dec x98,1
if x98=195 then mirror sprite 98 : right98=1
if x98<375 and right98=1 then inc x98,1
if x98=375 then mirror sprite 98 : right98=0
endif
if sprite exist(99)
if x99>500 and right99=0 then dec x99,1
if x99=500 then mirror sprite 99 : right99=1
if x99<620 and right99=1 then inc x99,1
if x99=620 then mirror sprite 99 : right99=0
endif
if sprite exist(100)
if x100>60 and right100=0 then dec x100,1
if x100=60 then mirror sprite 100 : right100=1
if x100<300 and right100=1 then inc x100,1
if x100=300 then mirror sprite 100 : right100=0
endif
`set sprite alpha
set sprite alpha 1,150
set sprite alpha 2,150
`set left collision
If x# < 1 then x# = 1
If x# > 640 then x# = 640
`set top collision
If y# < 1 then y# = 1
If y# > 480 then y# = 1
`set right collision
If x# > 610 then x# = 610
`Set player death
if health <= 0
CLS : hide all sprites
do
ink rgb(255,0,0),0
center text 320,240,"Your health has reached 0 and you died"
center text 320,260,"- Press escape to quit -"
sync
if escapekey()=1 then ALERT_i("Check for updates!","Alert.") : end
loop
endif
`Set win
if sprite collision(1,42)
CLS : hide all sprites
do
ink rgb(255,0,0),0
center text 320,240,"Congratulations, you have completed level 3!"
center text 320,260,"- Press the return key to continue or escape to quit -"
sync
if escapekey()=1 then end
if returnkey()=1 then goto level4_setup
loop
endif
Rem Update the screen
sync
loop
`-----------------------------------------_-------------------------------------------
`________________________-----------------------------------__________________________
`------------------------ L-E-V-E-L F-O-U-R L-O-O-P
`-----------------------------------------_-------------------------------------------
`________________________-----------------------------------__________________________
level4_setup:
`Delete potion if it currently exists:
if sprite exist(51) then delete sprite 51
`reset all variables
x# = 100 : y# = 200
oldx# = x# : oldy# = y#
grav# = 0
ground = 2 : ground2 = 10
dim rat_dead(3)
for rat=1 to 3
rat_dead(rat)=0
next rat
right98=0 : right99=0 : right100=1
force=0 : flip#=1 : mirror sprite 1 : using_force=0 : attacking=0
x98=375 : y98=435
x99=620 : y99=435
x100=61 : y100=54
tmoved=0
recharge=timer()
btimer=timer()
artifact = 1 : potion2 = 1 : armor1 = 0 : hero2t = 1
`recreate enemies just encase there was glitch =D
if sprite exist (98) then delete sprite 98
if sprite exist (99) then delete sprite 99
if sprite exist (100) then delete sprite 100
sprite 100,x100,y100,98 : mirror sprite 100 : right100=1
show all sprites
x# = 56 : y# = 300
`Set sprite that moves in position before main loop so it can move:
sprite 15,470,25,1002
sprite 17,426,328,3
sprite 11,496,356,3
sprite 12,461,356,1002
sprite 13,426,356,3
sprite 14,496,328,3
sprite 20,461,328,3
`Position target before hand
sprite 31,540,120,1004
sprite 32,150,202,1003
hide mouse
`goto the main loop
goto level4_loop
level4_loop:
do
`Always put cursor where the mouse is
sprite 1001,mousex(),mousey(),36
set cursor 0,10
return$=update_menu()
if return$="Exit Game" then end
show all sprites
loop music 1
if mana<99
if timer()>recharge+900 then inc mana,2 : recharge=timer()
endif
Rem update the old variables
oldx# = x#
oldy# = y#
if escapekey()=1
do
CLS
ink rgb(255,0,0),0
center text 320,240,"Paused - Press [Space Bar] to continue or [Q] to exit"
if spacekey()=1 then exit
if keystate(16) then end
sync
loop
endif
Rem control the player with the keyboard
`move left
if leftkey()=1
x#=x#-5
`If if is not flipped the right way then flip it
if leftkey() and flip# = 0
mirror sprite 1
flip# = 1
endif
endif
`Move right
if rightkey()
x#=x#+5
`If if is not flipped the right way then flip it
if rightkey() and flip# = 1
mirror sprite 1
flip# = 0
endif
endif
`Jumping
if spacekey() and grav# = 0 then y# = y# -60
grav# = grav# - 1
y# = y# - grav#
Rem Update sprites
sprite 1,X#,Y#,1
sprite 2,0,450,2
sprite 3,5000,419,3
sprite 4,0,419,3
sprite 5,0,390,3
sprite 6,160,419,3
sprite 7,250,365,3
sprite 8,5000,332,1000
sprite 9,285,365,3
sprite 10,431,386,1001
sprite 16,320,365,3
sprite 18,320,337,1002
sprite 19,300,70,3
sprite 21,320,230,3
sprite 22,210,70,3
sprite 23,180,70,3
sprite 24,1500,70,3
sprite 25,1200,70,3
sprite 26,90,70,3
sprite 27,60,70,3
sprite 28,40,70,3
sprite 29,102,250,3
sprite 30,-5000,38,1000
sprite 33,0,70,3
sprite 34,40,97,3
sprite 35,40,122,3
sprite 36,30,70,3
sprite 37,0,250,3
sprite 38,25,250,3
sprite 39,50,250,3
sprite 40,75,250,3
sprite 41,285,395,3
sprite 42,105,218,1000
if potion2=1 then sprite 52,316,52,33
if armor1 =1 then sprite 53,45,36,34
if hero2t =1 then sprite 1,X#,Y#,35
`reset enemies
if rat_dead(1)=0 then sprite 98,x98,y98,98
if rat_dead(2)=0 then sprite 99,x99,y99,98
if rat_dead(3)=0 then sprite 100,x100,y100,98
Rem Display info
set cursor 0,0
ink rgb(255,0,0),0
set cursor X#,Y#-26
print "Health: ",health," / ",totalhealth
ink rgb(0,0,255),0
set cursor X#,Y#-15
print "Mana: ",mana," / ",totalmana
`print "Artifact" over it
if artifact = 1 then text 37,350,"Artifact"
if sprite collision(1,2)
y# = y# + 1000
grav# = 0.0
endif
if sprite collision(1,12) then oldy# = y# - 250 : play sound 3
if sprite collision(1,18) then oldy# = y# - 150 : play sound 3
`set collision to boxes
for boxes = 2 to 30
if sprite collision(1,boxes)
if sprite y(1)>sprite y(boxes) then x#=oldx#
y# = oldy#
grav# = 0.0
endif
next boxes
`Collision to the rest of the boxes
for moreboxes = 33 to 42
if sprite collision(1,moreboxes)
if sprite y(1)>sprite y(moreboxes) then x#=oldx#
y# = oldy#
grav# = 0.0
endif
next moreboxes
`player and rat collisions
for rat=98 to 100
`rat attacks player
if sprite exist(rat)
if sprite collision(1,rat)
x#=oldx#
dec health,2
endif
`player attacks rat
if spacekey() and attacking<20 : `stops player from holding down space
inc attacking,1
if sprite collision(1,rat) then delete sprite rat : rat_dead(rat-97)=1
endif
endif
next rat
if spacekey()=0 then attacking=0
`upgrade
if force=0 then sprite 200,50,368,100
`check if player gains force
if sprite exist(200)
if sprite collision(1,200) then force=1 : inc mana,30 : play sound 2 : artifact = 0 : delete sprite 200
endif
`check if player uses force
if force=1 and using_force=0
if controlkey()=1
if mana>25 and timer()>btimer+2000 : btimer=timer()
load image "sprites/force blast.png",101 : play sound 1 : blast_life=25 : using_force=1 : mana=mana-25
if flip#=0 then sprite 101,x#+15,y#+5,101 : right_blast=1
if flip#=1 then sprite 101,x#-15,y#+5,101 : right_blast=0
endif
endif
endif
`update force blast
if sprite exist(101)
x101=sprite x(101) : y101=sprite y(101)
if blast_life>0 and right_blast=1 then sprite 101,x101+6,y101,101
if blast_life>0 and right_blast=0 then sprite 101,x101-6,y101,101
dec blast_life,1
endif
`check if force hits wall
for tile=2 to 30
if sprite exist(101)
if sprite collision(101,tile) then delete sprite 101 : using_force=0
endif
next tile
`check if force hits a rat
for rat=98 to 100
if sprite exist(101) and sprite exist(rat)
if sprite collision(101,rat) then delete sprite 101 : delete sprite rat : using_force=0 : rat_dead(rat-97)=1
endif
next rat
if blast_life=0 and sprite exist(101) then delete sprite 101 : using_force=0
`Target:
for target=31 to 31
if sprite exist(101) and sprite exist(target)
if sprite collision(101,target) then X# = 301 : Y# = 10 : hide sprite target
endif
next target
`Target2:
for target2=32 to 32
if sprite exist(101) and sprite exist(target2)
if sprite collision(101,target2) then move sprite target2,3000 : move sprite 17,5000: move sprite 11,5000 : move sprite 13,5000 : move sprite 14,5000 : move sprite 20,170
endif
next target2
`make it so that players mana cant go over 100
if mana > totalmana then mana = totalmana
`make it so that if players health is already 100 then print if it hits the potion
if sprite exist (1) and sprite exist (52)
if sprite collision(1,52) and mana = totalmana
ink rgb(255,0,0),0
text X#-30,Y#-15,"You already have full mana"
endif
endif
`check if player gets mana potion
if sprite exist(52)
if sprite collision(1,52) and mana<totalmana
delete sprite 52 : mana=mana + 25 : potion2=0 : play sound 3
endif
endif
`check if player has full mana
if sprite exist (1) and sprite exist (52)
if sprite collision(1,52) and mana = 100
ink rgb(255,0,0),0
text X#-30,Y#-15,"You already have full mana"
endif
endif
`move rats
if sprite exist(98)
if x98>195 and right98=0 then dec x98,1
if x98=195 then mirror sprite 98 : right98=1
if x98<375 and right98=1 then inc x98,1
if x98=375 then mirror sprite 98 : right98=0
endif
if sprite exist(99)
if x99>500 and right99=0 then dec x99,1
if x99=500 then mirror sprite 99 : right99=1
if x99<620 and right99=1 then inc x99,1
if x99=620 then mirror sprite 99 : right99=0
endif
if sprite exist(100)
if x100>50 and right100=0 then dec x100,1
if x100=50 then mirror sprite 100 : right100=1
if x100<90 and right100=1 then inc x100,1
if x100=90 then mirror sprite 100 : right100=0
endif
`set sprite alpha
set sprite alpha 1,150
set sprite alpha 2,150
`set left collision
If x# < 1 then x# = 1
If x# > 640 then x# = 640
`set top collision
If y# < 1 then y# = 1
If y# > 480 then y# = 1
`set right collision
If x# > 610 then x# = 610
`Set player death
if health <= 0
CLS : hide all sprites
do
ink rgb(255,0,0),0
center text 320,240,"Your health has reached 0 and you died"
center text 320,260,"- Press escape to quit -"
sync
if escapekey()=1 then ALERT_i("Check for updates!","Alert.") : end
loop
endif
`Set win
if sprite collision(1,42)
CLS : hide all sprites
do
ink rgb(255,0,0),0
center text 320,240,"Congratulations, you have completed level 4!"
center text 320,260,"- Press escape to quit -"
sync
if escapekey()=1 then ALERT_i("Check for updates!","Alert.") : end
loop
endif
Rem Update the screen
sync
loop
FUNCTION ALERT(MESSAGE$,TITLE$)
ALERT_1(MESSAGE$,TITLE$,"0")
ENDFUNCTION
FUNCTION ALERT_X(MESSAGE$,TITLE$)
ALERT_1(MESSAGE$,TITLE$,"16")
ENDFUNCTION
FUNCTION ALERT_?(MESSAGE$,TITLE$)
ALERT_1(MESSAGE$,TITLE$,"32")
ENDFUNCTION
FUNCTION ALERT_i(MESSAGE$,TITLE$)
ALERT_1(MESSAGE$,TITLE$,"48")
ENDFUNCTION
FUNCTION ALERT_1(MESSAGE$,TITLE$,NUMBER$)
OPEN TO WRITE 32,"c:msgbox.vbs"
WRITE STRING 32,"msgbox"+CHR$(34)+MESSAGE$+CHR$(34)+","+NUMBER$+","+CHR$(34)+TITLE$+CHR$(34)
CLOSE FILE 32
EXECUTE FILE "wscript.exe","c:msgbox.vbs","C:",1
DELETE FILE "c:msgbox.vbs"
ENDFUNCTION
`==================================
function drop_count()
count=count1(0)
endfunction count
`==================================
function make_menu()
dim names1(50) as string
dim names2(50,50) as string
dim names3(50,50,50) as string
dim count1(10)
dim count2(50)
dim count3(50,50)
set text font "tahoma"
set text size 14
endfunction
`==================================
function add_drop(name as string)
count1(0)=count1(0)+1
names1(count1(0))=name
endfunction
`==================================
function add_sub_drop(pos,name as string)
count2(pos)=count2(pos)+1
names2(pos,count2(pos))=name
endfunction
`==================================
function add_sub_sub_drop(pos,down,name as string)
count3(pos,down)=count3(pos,down)+1
names3(pos,down,count3(pos,down))=name
endfunction
`==================================
function update_menu()
mg=count1(9)
mx=mousex()
my=mousey()
count1(10)=mg
mg=mouseclick()
count1(9)=mg
mc=0
if mg=1 and count1(10)=0 then mc=1
check=0
colour(1) : ink rgb(100,100,100),0 : box 0,0,screen width(),18
colour(2) : ink rgb(120,120,120),0 : line 0,18,screen width(),18
colour(4) : line 0,19,screen width(),19
`================= DROP
wid=5
if count1(0)>0
for i=1 to count1(0)
tl=text width(names1(i))
t2=text height(names1(i))
text wid,1,names1(i)
line wid,text height(mid$(names1(i),1)),wid+text width(mid$(names1(i),1))-1,text height(mid$(names1(i),1))
`=========
wrt=wid+text width(names1(i))
if mx>wid-5 and mx<wrt and my>0 and my<20
colour(3) : line wid-5,0,wrt,0 : line wid-5,0,wid-5,17 : colour(2) : line wrt,0,wrt,17 : line wid-5,17,wrt,17
if mc=1 then colour(2) : line wid-5,0,wrt,0 : line wid-5,0,wid-5,17 : colour(3) : line wrt,0,wrt,17 : line wid-5,17,wrt,17
colour(4)
if count1(1)>0 then count1(1)=i : count1(2)=wid : count1(5)=wrt
if mc=1
check=1
count1(1)=i
count1(6)=0
count1(2)=wid
if count2(count1(1),0)=0 then return$=names1(i)
endif
endif
`=========
wid=wid+text width(names1(i))+15
next i
endif
`======================
`================= SUB DROP
if count2(count1(1),0)>0
wid=count1(2)
he=20+(count2(count1(1),0)*15)
wrt=count1(5)
colour(2) : line wid-5,0,wrt,0 : line wid-5,0,wid-5,17 : colour(3) : line wrt,0,wrt,17 : line wid-5,17,wrt,17
wid=count1(2)-5
colour(1) : box wid,20,wid+100,he
colour(2) : line wid,he-1,wid+99,he-1 : line wid+99,20,wid+99,he
colour(3) : line wid,21,wid+100,21 : line wid+1,20,wid+1,he
colour(4) : line wid,he,wid+100,he : line wid+100,20,wid+100,he
h=20
for i=1 to count2(count1(1),0)
colour(4)
count1(3)=0
if mx>wid-3 and mx<wid+97 and my>(i*15) and my<15+(i*15)
check=1
count1(3)=i
if mc=1 then count1(6)=i : count1(8)=h
if mc=1 and count3(count1(1),count1(6))=0 then return$=names2(count1(1),i) : count1(1)=0
endif
if i=count1(3) then colour(2) : box wid+3,7+(i*15),wid+98,18+(i*15) : colour(5)
text wid+5,h,names2(count1(1),i)
a=wid+96
if count3(count1(1),i)>0
h=h+7
dot a,h : dot a-1,h : dot a-2,h : dot a-3,h : dot a-1,h+1 : dot a-1,h-1
dot a-2,h+1 : dot a-2,h+2 : dot a-2,h-1 : dot a-2,h-2 : dot a-3,h+3
dot a-3,h-1 : dot a-3,h-2 : dot a-3,h-3 : dot a-3,h+1 : dot a-3,h+2
h=h-7
endif
colour(4)
h=h+15
next i
endif
`======================
`================= SUB SUB DROP
if count3(count1(1),count1(6))>0
colour(1)
h=7+count1(6)*15
he=5+(count1(6)*15)+(count3(count1(1),count1(6))*15)
`h=5+count1(6)*15
box wid+100,5+count1(6)*15,wid+200,5+(count1(6)*15)+(count3(count1(1),count1(6))*15)
wid=wid+100
colour(2) : line wid,he-1,wid+99,he-1 : line wid+99,h,wid+99,he
colour(3) : line wid,h-1,wid+99,h-1 : line wid,h,wid,he
colour(4) : line wid,he,wid+100,he : line wid+100,h,wid+100,he
for i=1 to count3(count1(1),count1(6))
colour(4)
count1(3)=0
if mx>wid-3 and mx<wid+97 and my>(i*15) and my<15+(i*15)
check=1
count1(3)=i
if mc=1 then return$=names3(count1(1),count1(6),i) : count1(1)=0 : count1(6)=0
endif
if i=count1(3) then colour(2) : box wid+3,7+(i*15),wid+97,18+(i*15) : colour(5)
text wid+5,h-2,names3(count1(1),count1(6),i)
colour(4)
h=h+15
next i
endif
`======================
if mc=1 and check=0 then count1(1)=0 : count1(6)=0
endfunction return$
function colour(num)
if num=1 then ink get_colour(4),0
if num=2 then ink get_colour(16),0
if num=3 then ink get_colour(20),0
if num=4 then ink get_colour(21),0
if num=5 then ink rgb(255,255,255),0
endfunction
function get_colour(num)
local col as dword
load dll "user32.dll",1
col = call dll(1,"GetSysColor", num)
delete dll 1
col = rgb(rgbb(col)-100, rgbg(col)-100, rgbr(co-)+100)
endfunction col
`==================================
[/EDIT]