So I'm making a game in Lua/Love2D and have a problem with my game logic. Mainly I have a spaceship that can use boost and stuff. That part is fine, I click space and it boosts up to speed quickly.
The problem is that if the person holds down space, they stay boosted, which is not the intended behavior. How do I make sure that once boost runs out, it decelerates to normal speed? This is how it is currently:
Note: Normal speed, 1000. Max boost possible speed, 3000.
if love.keyboard.isDown('space') then if player.v < 3000 and UICounters.currentboost > 0 then player.v = player.v + 200 if player.v > 3000 then player.v = 3000 end UICounters.currentboost = UICounters.currentboost - 1 end else if player.v > 1000 then player.v = player.v - 100 end if UICounters.currentboost < UICounters.maxboost then UICounters.currentboost = UICounters.currentboost + dt end end