Created
March 28, 2019 01:24
-
-
Save KinoAR/fcee1f675d0a890905674fe1c2377917 to your computer and use it in GitHub Desktop.
An example of movement for the player including gravity.
This file contains 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
function move_player(p) | |
local mspd = p.mvspd | |
if (btn(0)) then p.dx=-mspd end | |
if (btn(1)) then p.dx=mspd end | |
-- jump function | |
jump(p) | |
-- process gravity | |
p.dy+=gravity | |
-- apply physics | |
p.x += p.dx | |
p.y += p.dy | |
p.dx = 0 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment