Hi people,
Please assit me on this one...don't know what's going on, an since I can't debug properly(bug in DBP)
The code is supposed to make a grid, load a sprite and when i us the arrow keys, move the sprite ONE square in the direction pressed, but this isn't work...it speeds all the way across the grid....
Thanks in Advance.
Fang
load image "stone02.jpg", 1
set sprite 1,0,1
sprite 1, 0, 0, 1
size sprite 1,50,50
show sprite 1
xc = sprite x (1)
yc = sprite y (1)
print xc
print yc
do
_afterkey:
drawgrid(800,600)
if leftkey()=1 then cls : gosub lk
if upkey()=1 then cls : gosub uk
if rightkey()=1 then cls : gosub rk
if downkey()=1 then cls : gosub dk
loop
lk:
if xc = 0
xc = 0
else xc = xc - 50
endif
movesprite(1,xc - 50,0)
return
uk:
if xy = 0
yc = 0
else yxc = yc - 50
endif
movesprite(1,0,yc - 50)
return
rk:
if xc > 600
xc = 600
else xc = xc + 50
endif
movesprite(1,xc + 50,0)
return
dk:
if yc = 800
yc = 800
else yc = yc - 50
endif
movesprite(1,0,yc + 50)
return
function drawgrid(xcoord as integer,ycoord as integer)
ink rgb(255,255,255),rgb(0,0,0)
for x = 0 to xcoord step 50
line x,0,x,xcoord
next x
for y = 0 to ycoord step 50
line 0,y,xcoord,y
next y
result = 0
endfunction result
function movesprite(sprite_num as integer, xcoord as integer, ycoord as integer)
set sprite 1,0,1
sprite 1, xcoord, ycoord, 1
size sprite 1,50,50
show sprite 1
result = 0
endfunction result
"I really don't know how WWIII will be fought, but WWIV will be with sticks and stones"
- Albert Einstien