Hi i need some help with the camera i don`t know what i did wrong nut it seem like my camera dosen't follow my player
Any ideas ?
Thanks a lot
Charles,
function _init()
player = {}
x= 60
y = 60
player.x = 60
player.y = 60
cam_x =60
cam_y =60
player.s = 1
end
function _update()
if (btn(0)) then player.x=player.x-10 end
if (btn(1)) then player.x=player.x+10 end
if (btn(2)) then player.y=player.y-10 end
if (btn(3)) then player.y=player.y+10 end
end
function _draw()
map(cam_x,cam_y)
camera(cam_x,cam_y)
cls()
spr(player.s,player.x,player.y)
end
Also, in addition to what @tarek said, the camera location isn't the center of the screen, but where the top-left should be. So with the code you have, your character would be pinned to the top-left of the screen. If you're using an 8x8 sprite (1 sprite), then you'd want the camera to be at camera(player.x-60,player.y-60) instead.
[Please log in to post a comment]