Hi i try to make my squirrel move to the right it dosen't seem to work but work perfectly with the left any idea ?
player = {}
player.x = 16
player.y = 42
player.sprite = 4
player.speed = 3
function _update()
if btn(0) then
player.x -= player.speed
end
end
if btn(1) then
player.x += player.speed
end
function _draw()
cls()
map(0,0,0,0,16,16)
spr(player.sprite,player.x,player.y,2,2)
end
player = {}
player.x = 16
player.y = 42
player.sprite = 4
player.speed = 3
function _update()
if btn(0) then
player.x -= player.speed
end
[b][i]end[/i][/b]
if btn(1) then
player.x += player.speed
end
function _draw()
cls()
map(0,0,0,0,16,16)
spr(player.sprite,player.x,player.y,2,2)
end
|
That 'end' I've highlighted is your problem. It's closing out the '_update()' function. This makes it so that the 'move right' logic you have right after it is never run.
Move it to after the line that reads 'player.x += player.speed' and it will work the way you're wanting it to.
Note: This is why it helps to indent your code to show what's inside a function or an 'if' statement if you aren't doing that already.
Thanks a lot for the help and for the tips i will take the time to make my code cleaner it burn my eyes finally after looking at it again :p
[Please log in to post a comment]



