Okay so I'm working on a game where the player is able to pilot a ship. Pretty straightforward right? But now I'm working on the movement controls and for some reason something is going wrong with the code and I have no idea why. I've now spent an hour trying to figure it out but I can't find the problem. I've supplied the code for the forward and backward movement, along with the .love file, which is where the real problem is. Any help would be much appreciated.
I didn't understand the code directly dude, but it looks like one problem is you are converting the radian into degree during the move calculation. Then I got stuck with the rest.
So here is a common calculation used, If I understood what you are trying to do. Drop this snippit into your code and try it:
if love.keyboard.isDown('w') then
player.x = player.x + (math.sin(player.r) * player.speed * dt)
player.y = player.y - (math.cos(player.r) * player.speed * dt)
end
if love.keyboard.isDown('s') then
player.x = player.x - (math.sin(player.r) * player.speed * dt)
player.y = player.y + (math.cos(player.r) * player.speed * dt)
end
Some notes: this doesn't have 'velovity' but you can easily write that into the calculation (if you want to model it), also the turning speed seems sluggish compared to the momentum