Last active
November 1, 2021 23:33
-
-
Save eguneys/96e8f8ce701e0ae2fb4743e2b13f0ed4 to your computer and use it in GitHub Desktop.
Top down movement in pico8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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