I am using PGELua for the PlaystationPortable. I would just like to know how to make a 2D sprite move in the direction that the sprite is facing.
When the sprite is blitted to the screen it should be heading down the y axis (like it's moving up the screen) but it doesn't appear to be working that way. As far as I am aware, the angles of the images use radians for the rotations.
I have this in a function
function FUNC_MOVE_SHIP(speed,angles) VAR_SHIPX = VAR_SHIPX + pge.math.sin(angles) * speed VAR_SHIPY = VAR_SHIPY + pge.math.cos(angles) * speed end
and I call it in my main program like
FUNC_ST_DR() if pge.controls.held(PGE_CTRL_LEFT) then VAR_SHIP_ANGLE=VAR_SHIP_ANGLE-0.01 elseif pge.controls.held(PGE_CTRL_RIGHT) then VAR_SHIP_ANGLE=VAR_SHIP_ANGLE+0.01 end FUNC_MOVE_SHIP(VAR_SHIP_SPEED,pge.math.rad(VAR_SHIP_ANGLE)) SHIP_11:activate() SHIP_11:draweasy(VAR_SHIPX,VAR_SHIPY,pge.math.rad(VAR_SHIP_ANGLE)) FUNC_EN_DR()