Yeah it will be covered. I'm just tweaking the numbers now, and I'm about to add some enemies and A.I.
The jumping in Super Mario Bro.'s is a little more complex than one might first think. I think that I have gotten pretty close to the orignal. I'm still running some comparisons. If you'd like I can post the code for just the jumping/and drift section in a day or so. I would post it now, but somewhere in my input handler I'm not correctly counting the players position when running right and left. So I'm just trying to figure out where I the problem is.
ahhh what the heck. Here's the code. Mind you there it contains a problem in the move code above. and I don't have the sound implemented. Some of the code will change when I release the tutorial, so keep an eye out for it.
This is the input handler subroutine that get's called from the main loop every loop cycle
getinput:
if controlkey()=1 and PlayerAction<>jumping then gosub chjumpmov
if controlkey()=0 then released=1
if downkey()=1 then gosub chdwmov
if leftkey()=1 and rightkey()=0 then gosub chltmov
if rightkey()=1 and leftkey()=0 then gosub chrtmov
if rightkey()=0 and leftkey()=0 then gosub chstill
if escapekey()=1 then end
return
These subroutines are called from the input handler. It set's all the values for the jumping code below, and handles all other movement as well
rem **** Verify that Vario can move jump *****
chjumpmov:
if PlayerAction<>falling
PlayerAction=jumping
pressed=1
endif
if loopcounter>25
loopcounter=0
if controlkey()=1 and PlayerAction=jumping
height=8
pressed=1
endif
endif
return
rem **** Verify that Vario can move down ****
chdwmov:
return
rem **** Verify that player can move left ****
chltmov:
if PlayerAction<>jumping and PlayerAction<>falling
PlayerMovRt=0
inc anim
if anim<2 or anim=5 then anim=2
if Ar_World(PWLocX-1,PWLocY,1)=0 then FL_Walkable=1
rem **** if player sprite isn't mirrored then mirror it for left direction ****
mirrored=sprite mirrored(CurrSpr)
if mirrored=0
mirror sprite CurrSpr
endif
if FL_Walkable=1 and PGridLocX>MaxLeft
PLocX=PLocX-(speed#*speed#)
xgt#=xgt#-(speed#*speed#)
if abs((xgt#/31))=>1
dec PWLocX
dec PGridLocX
xgt#=0.0
endif
if speed#<4
inc speed#
endif
endif
if FL_Walkable=0
speed#=0
anim=1
endif
FL_Walkable=0
FL_Moved=1
else
inc drift,2
if drift>8 then drift =8
endif
return
rem **** Verify that player can move right ****
chrtmov:
if PlayerAction<>jumping and PlayerAction<>falling
PlayerMovRt=1
inc anim
if anim<2 or anim=5 then anim=2
if Ar_World(PWLocX,PWLocY,1)=0 then FL_Walkable=1
rem **** if player sprite was mirrrored rest mirroring for right direction ***
mirrored=sprite mirrored(CurrSpr)
if mirrored=1
mirror sprite CurrSpr
endif
if PGridLocX=>MaxRight and FL_Walkable=1
xgt#=xgt#+(speed#*speed#)
print "maxright"
if (xgt#/31)>=1.0
inc LeftMost
inc RightMost
inc PWLocX
xgt#=0.0
endif
if speed#<4
inc Speed#
endif
endif
if FL_Walkable=1 and PGridLocX<MaxRight
PLocX=PLocX+(speed#*speed#)
xgt#=xgt#+(speed#*speed#)
if (xgt#/31)>=1.0
inc PWLocX
inc PGridLocX
xgt#=0.0
endif
if speed#<4
speed#=speed#+1
endif
endif
if FL_Walkable=0
speed#=0
anim=1
endif
FL_Walkable=0
FL_Moved=1
else
inc drift,2
if drift>8 then drift=8
endif
return
chstill:
if PlayerAction<>falling and PlayerAction<>jumping
if anim<>3 or anim<>4
if speed#>0
speed#=speed#-.6
if PlayerMovRt=1
rem PLocX=PlocX+speed#
endif
if PlayerMovRt=0
rem PLocX=PLocX-speed#
endif
anim=1
endif
if Speed#<=0
Speed#=0.0
endif
endif
endif
return
This is the code in the main loop that actually performs the jump
if PlayerAction=jumping and released=1; rem jumping
anim=5
PLocY=PLocY-(jump*jump)
vgt#=vgt#+(jump*jump)
if (vgt#/32)+1>1
dec PWLocY
dec PGridLocY
vgt#=0
endif
if PlayerMovRt=1
if PLocX<MaxRight
PLocX=PLocX+speed#+drift
endif
xgt#=xgt#+speed#+drift
if (xgt#/31.0)>=1.0
inc PWLocX
if PLocX<maxright
inc PGridLocX
endif
xgt#=0.0
endif
endif
if PlayerMovRt=0
PLocX=PlocX-speed#-drift
xgt#=xgt#-speed#-drift
if abs((xgt#/31.0))>=1.0
dec PWLocX
dec PGridLocX
xgt#=0.0
endif
endif
inc jump
if jump>height then PlayerAction=falling
endif
if PlayerAction=falling
PLocY=PLocY+(fall*fall)
vgt#=vgt#+(fall*fall)
if (vgt#/32)+1>1
inc PWLocY
inc PGridLocY
vgt#=0.0
endif
if PlayerMovRt=1
if PLocX<MaxRight
PLocX=PLocX+speed#+drift
endif
xgt#=xgt#+speed#+drift
if (xgt#/31.0)>=1.0
inc PWLocX
if PLocX<MaxRight
inc PGridLocX
endif
xgt#=0.0
endif
endif
if PlayerMovRt=0
PLocX=PloCX-speed#-drift
xgt#=xgt#-speed#-drift
if abs((xgt#/31.0))>=1.0
dec PWLocX
dec PGridLoc
xgt#=0.0
endif
endif
jump=0
inc fall
if fall>height
PlayerAction=still
released=0
fall=0
speed#=0
anim=1
height=6
pressed=0
drift=0
endif
endif
As is, I haven't yet added the accounted for the slow down drift/skid in updating my the characters grid position.