Sorry people Im completely useless atm with this bit of code.Im new to darkbasic and I cannot find this error that the IDE messages about.
Please help me find the error.
sync rate 50
set dir "Content\Textures"
gosub vars
load image "background.bmp", bgID
for i = 1 to 3
load image "platform.bmp", platformID(i)
next i
load image "mstanding.bmp", 1
load image "mstanding.bmp", 2
load image "mwalk.bmp", 3
load image "mwalk.bmp", 4
load image "mjump.bmp", 5
load image "mfall.bmp", 6
REM start of main game loop
Do
anim = 0
paste image bgID,0, 0
for i = 1 to 3
sprite platformID(i), platform1_x(i), platform1_y(i), platformID(i)
next i
if jumping = 0
old_y = playery
endif
sprite playerID, playerx, playery, imgnum
jumpmax = old_y - 150
gosub playerinput
gosub playeranim
gosub title
gosub gravity
gosub collision
sync
loop
vars:
REM player and floor variables
playerID = 1
bgID = 100
gravity# = 3
jumping = 0
jumpspeed = 2
playerx = 25
playery = 0
falling = 0
REM animation
anim = 0
fright = 1
frame = 0
imgnum = 1
dim platformID(3)
dim platform1_x(3)
dim platform1_y(3)
for i = 1 to 3
platformID(i) = 100 + i
platform1_x(1) = 20
platform1_y(1) = 50
platform1_x(2) = 50
platform1_y(2) = 150
platform1_x(3) = 100
platform1_y(3) = 250
REM tutorial title variables
ink RGB(255,0,0), 1
title$ = "gravity"
tx = screen width()
ty = 0
title:
text tx, ty, title$
tx = tx - 1
if tx+text width(title$) < 0
tx = screen width()
endif
if jumping = 0 and falling = 0
text 100, 500, "On ground"
endif
if jumping = 1
text 100, 500, "Jumping"
endif
if jumping = 3
text 100, 500, "Falling"
endif
if falling = 1
text 200, 500, "Falling"
endif
return
gravity:
if falling = 1
playery = playery + gravity#
imgnum = 6
endif
if jumping = 1
imgnum = 5
playery = playery - (jumpspeed*3)
endif
if playery <= jumpmax
falling = 1
jumping = 3
endif
return
playeranim:
if anim = 1
imgnum = 2 + (frame/2)
frame = frame + 1
if frame >= 4 then frame = 0
else
imgnum = 1
endif
collision:
if sprite collision (playerID, platformID(1)) = 1
falling = 0
jumping = 0
playery = playery
endif
if sprite collision (playerID, platformID(3)) = 1
falling = 0
jumping = 0
playery = playery
endif
if sprite collision (playerID, platformID(2)) = 1
falling = 0
jumping = 0
playery = playery
endif
if falling = 0 and sprite collision (playerID, 0) = 0
falling = 1
endif
return
playerinput:
if rightkey() = 1
if controlkey() = 1
REM running right
playex = playerx + 3
endif
playerx = playerx + 2
if fright = 0
mirror sprite 1
fright = 1
endif
anim = 1
endif
REM walking left
if leftkey() = 1
if controlkey() = 1
playerx = playerx - 3
endif
playerx = playerx - 2
if fright = 1
mirror sprite 1
fright = 0
endif
anim = 1
endif
if spacekey() = 1 and jumping = 0 and falling = 0
jumping = 1
endif
REM player reset
if inkey$() = "r"
playerx = 25
playery = 0
endif
return
Yello http://www.youtube.com/user/Rikukarasuma?feature=mhee