ok ive, modified the code a bit here:
` Setup the screen variables
mainresx=800
mainresy=600
cdepth=32
` Setup the screen
set display mode mainresx,mainresy,cdepth
set window on
set image colorkey 252,4,244
` Set the sync rate and turn syncing on (so it only SYNCs when you want it to)
sync rate 24
sync on
` Main variables
hero=1
herox=400
heroy=300
imgnum=1
footstep=0
ducking=0
jumping=0
anim=0
gforce=0
windowcompensation=20
aswespeak$=get time$()
` Load images
load image "sprites\stand.bmp",1
load image "sprites\stand.bmp",2
load image "sprites\trans.bmp",3
load image "sprites\trans.bmp",4
load image "sprites\walk.bmp",5
load image "sprites\walk.bmp",6
load image "sprites\walk.bmp",7
load image "sprites\walk.bmp",8
load image "sprites\duck.bmp",9
load image "sprites\trans_1.bmp",10
load image "sprites\jump.bmp",11
` Load Images for basic level
load image "levels\stage_1.bmp",20
load image "levels\collider.png",21
load image "levels\platform_1.bmp",22
remstart
` gravity function
function gaccel()
repeat
gforce = gforce + 1
until gforce = 10
endfunction
remend
` basic level variables
collider1=20
collider1x=400
collider1y=300
`:::::::::::
collider2=21
collider2x=400
collider2y=350
` make level with baisc level images
sprite collider1,collider1x,collider1y,21
size sprite collider1,100,1
set sprite priority collider1,2
sprite collider2,collider2x,collider2y,22
size sprite collider2,100,1
set sprite priority collider1,3
` DO this LOOP forever (no EXIT to leave it)
do
` Show the player
sprite hero,herox,heroy,imgnum
` keeping player with in screen dimensions
if sprite x(hero)<1
herox=1
endif
if sprite x(hero)>mainresx-windowcompensation
herox=mainresx-windowcompensation
endif
if sprite y(hero)<1
heroy=1
endif
if sprite y(hero)>mainresy-windowcompensation
heroy=mainresy-windowcompensation
endif
rem ## delete me asap ##
platform=sprite collision(hero,0)
rem ####################
` sprite level colision
if sprite hit(hero,platform)=1
falling=0
endif
` Check if he needs to animate (left to right)
if anim=1
imgnum=imgnum+1
if imgnum > 7 then imgnum=1
else
if anim=0 then imgnum=1
endif
` Check if he needs to animate (jump and duck)
if jumping=1
imgnum=10
imgnum=imgnum + 1
if imgnum > 11 then imgnum=11
else
if anim=0 then imgnum=1
endif
if ducking=1
imgnum=9
else
if anim=0 then imgnum=1
endif
` Check for the right arrow key
if rightkey() = 1
herox = herox + 5
footstep = 1
if fright = 1
mirror sprite hero
fright = 0
endif
anim = 1
else
footstep = 0
endif
` Check for the left arrow key
if leftkey() = 1
herox = herox - 5
footstep = 1
if fright = 0
mirror sprite hero
fright = 1
endif
anim = 1
else
footstep = 0
endif
remstart
` only goes up or down based on if its not touching anything
if sprite x(hero)-sprite height(hero)=sprite x(platform)
` Check for the down arrow key when touching a platform
if downkey() = 1
ducking = 1
else
ducking = 0
endif
endif
remend
` Check for the down arrow key
if downkey() = 1
heroy = heroy + 10
ducking = 1
else
ducking = 0
endif
` Check for the up arrow key
if upkey() = 1
heroy = heroy - 10
jumping = 1
falling = 0
else
jumping = 0
falling = 1
endif
` reseting the animation flag
if scancode()<1
anim=0
endif
` simple gravity
if platform=0
if falling=1
for gforce=1 to 5
heroy = heroy + gforce
next gforce
heroy = heroy + gforce
else
falling=0
gforce=0
endif
endif
` show sprite coord.s
text 1,1,"sprite x:__"+str$(sprite x(hero))
text 1,20,"sprite y:__"+str$(sprite y(hero))
` show flags
text 1,40 ,"timer (NB:on=1,off=0):__"+aswespeak$
text 1,60 ,"falling (NB:on=1,off=0):__"+str$(falling)
text 1,80 ,"jumping (NB:on=1,off=0):__"+str$(jumping)
text 1,100 ,"ducking (NB:on=1,off=0):__"+str$(ducking)
text 1,120,"gforce (NB:on=1,off=0):__"+str$(gforce)
text 1,140,"anim (NB:on=1,off=0):__"+str$(anim)
text 1,160,"colli...(NB:on=1,off=0):__"+str$(sprite collision(hero,0))
` reset player
if inkey$()="r" or inkey$()="R"
herox=10
heroy=10
endif
` Update the screen
sync
loop
rigth now im looking for falling with gravity but can seem to get the acceleration correct (maybe the for next loop is being processed to fast)
if platform=0
if falling=1
for gforce=1 to 5
heroy = heroy + gforce
next gforce
heroy = heroy + gforce
else
falling=0
gforce=0
endif
endif
help me!!!
i need help with acceleration due to gravity! (maybe with the timer?) and a easy way to scroll a level.
guess what