here you go (better commented now) :
set display mode 800,600,32
sync on
sync rate 0
sync
set window on
randomize timer()
set text font "lucida console"
ink rgb(255,222,128),0
set text size 20
color backdrop rgb(0,22,0)
autocam off
` object 1 is the player object:
make object sphere 1,2
position object 1,90,5,25
color object 1,rgb(255,0,0)
` object 2 is the goal object
make object sphere 2,5
color object 2,rgb(255,255,0)
` this makes the level.
` it reads from data statements, and any non-zero value will create a platform of a specified height.
Level_Length=80
for t=17 to Level_Length
read a
if a
make object box t,5,2,10
position object t,t*5,(a-1)*5-15,25
color object t,rgb(11,11,11)
if t = Level_Length
position object 2,t*5,(a-1)*5-12,25
endif
endif
next t
start_level:
` this is timer based movement, and is the start of the main loop:
t1=timer()
do
gs#=(timer()-t1)*0.025
t1=timer()
position camera object position x(1),10,-40
` here is 'checking to see if you're on a platform.
` it moves you down a little, and checks for collision.
` and the end of the loop, it moves you back up.
move object down 1,.1
if object collision(1,0)=0
` you are NOT on a platform, so this applies "gravity":
move object down 1,gs#*0.75
else
` you Are on a platform. did you just land from a jump?
if JUMP=1 and hite#<0.01
if spacekey()=0 and upkey()=0
` yes. mark you as "not jumping"
JUMP=0
endif
endif
endif
move object up 1,.1
` this moves you UP according to how far you are into a jump:
if JUMP
dec hite#,gs#*0.50
if hite#>0
move object up 1,hite#
endif
endif
` simple player movement:
move object right 1,(rightkey()-leftkey())*gs#
` JUMP activation:
if UPKEY() or spacekey()
if JUMP=0
JUMP=1
hite#=0.65
endif
endif
C=object collision(1,0)
` this makes you fall thru the floor if you don't land on top
if c>0
if object position y(1)<=object position y(c)
move object down 1,1
endif
endif
` if you've reached the end:
if c=2
center text 400,200,"You Win!"
endif
` display:
text 0,0,"Deaths : "+str$(deaths)
text 0,580,"FPS : "+str$(screen fps())
sync
` this is if you fall off:
if object in screen(1)=0
position object 1,90,5,25
inc DEATHS
goto start_level
endif
loop
` here is the level data:
` 16
data 1,1,1,0,1,1,1,0,0,1,1,1,0,1,0,1
` 32 (48)
data 2,3,4,5,0,5,5,0,0,4,0,5,0,0,0,5
` 48 (64)
data 6,7,8,9,9,0,0,0,0,0,0,0,0,0,1,1
` 64 (80)
data 1,3,5,0,0,0,0,1,3,4,5,6,7,8,9,10
arrowkeys to move, space to jump
compressed:
set display mode 800,600,32:sync on:sync rate 0:sync: set window on:randomize timer():set text font "lucida console":ink rgb(255,222,128),0:set text size 20:color backdrop rgb(0,22,0):autocam off
make object sphere 1,2 : position object 1,90,5,25 : color object 1,rgb(255,0,0) : make object sphere 2,5 : color object 2,rgb(255,255,0) : Level_Length=80 : for t=17 to Level_Length : read a : if a : make object box t,5,2,10 : position object t,t*5,(a-1)*5-15,25 : color object t,rgb(11,11,11) : if t = Level_Length : position object 2,t*5,(a-1)*5-12,25 : endif : endif : next t
start_level: : t1=timer() : do : gs#=(timer()-t1)*0.025 : t1=timer() : position camera object position x(1),10,-40 : move object down 1,.1 : if object collision(1,0)=0 : move object down 1,gs#*0.75 : else : if JUMP=1 and hite#<0.01 : if spacekey()=0 and upkey()=0 : JUMP=0 : endif : endif : endif : move object up 1,.1
if JUMP : dec hite#,gs#*0.50 : if hite#>0 : move object up 1,hite# : endif : endif : move object right 1,(rightkey()-leftkey())*gs# : if UPKEY() or spacekey() : if JUMP=0 : JUMP=1 : hite#=0.65 : endif : endif
C=object collision(1,0) : if c>0 : if object position y(1)<=object position y(c) : move object down 1,1 : endif : endif : if c=2 : center text 400,200,"You Win!" : endif
text 0,0,"Deaths : "+str$(deaths) : text 0,580,"FPS : "+str$(screen fps()) : sync : if object in screen(1)=0 : position object 1,90,5,25 : inc DEATHS : goto start_level : endif : loop
data 1,1,1,0,1,1,1,0,0,1,1,1,0,1,0,1,2,3,4,5,0,5,5,0,0,4,0,5,0,0,0,5,6,7,8,9,9,0,0,0,0,0,0,0,0,0,1,1,1,3,5,0,0,0,0,1,3,4,5,6,7,8,9,10
feel free to build off of this model. make it better!