Skip to content

Instantly share code, notes, and snippets.

@eguneys
Last active November 1, 2021 23:33
Show Gist options
  • Save eguneys/96e8f8ce701e0ae2fb4743e2b13f0ed4 to your computer and use it in GitHub Desktop.
Save eguneys/96e8f8ce701e0ae2fb4743e2b13f0ed4 to your computer and use it in GitHub Desktop.
Top down movement in pico8
-- if you find this interesting
-- checkout the full source code at https://github.com/eguneys/pico8-jam/blob/master/alta.p8
local intheta = atan2(-ix, -iy)
local diftheta = player.theta - intheta
if ix ~= 0 or iy ~= 0 then
player.theta = appr(player.theta, intheta, 0.08)
if abs(diftheta) < 0.25 then
player.daccel = appr(player.daccel, 3, 0.3)
else
player.daccel = appr(player.daccel, 0, 1)
end
else
player.daccel = appr(player.daccel, 0, 0.3)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment