Help with probably basic movement controls
Posted: Sun Apr 09, 2017 11:18 pm
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.
Code: Select all
if love.keyboard.isDown('w') then
local yMovement = math.sin(math.deg(player.r)) * (player.speed * dt)
local xMovement = math.sqrt(math.pow(player.speed * dt, 2)-math.pow(yMovement, 2))
player.x = player.x - xMovement
player.y = player.y - yMovement
end
if love.keyboard.isDown('s') then
local yMovement = math.sin(math.deg(player.r)) * (player.speed * dt)
local xMovement = math.sqrt(math.pow(player.speed * dt, 2)-math.pow(yMovement, 2))
player.x = player.x + xMovement
player.y = player.y + yMovement
end