1
我需要改變對象的速度後,我改變他的旋轉。更改對象(車)的速度
function love.update(dt)
if car['speed'] > 0 then
car['x'] = car['x'] + math.cos(car['angle'])
car['y'] = car['y'] + math.sin(car['angle'])
end
if love.keyboard.isDown("w") then
car['speed'] = car['speed'] + dt
end
if love.keyboard.isDown("a") then
car['angle'] = car['angle'] - (1 * dt)
end
if love.keyboard.isDown("d") then
car['angle'] = car['angle'] + (1 * dt)
end
end
當我改變「w」的速度後,我希望它改變汽車的速度(x,y)。 但是,當我嘗試添加它只是改變旋轉,破壞它的速度..