Skip to content

Instantly share code, notes, and snippets.

@KinoAR
Created March 28, 2019 01:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KinoAR/fcee1f675d0a890905674fe1c2377917 to your computer and use it in GitHub Desktop.
Save KinoAR/fcee1f675d0a890905674fe1c2377917 to your computer and use it in GitHub Desktop.
An example of movement for the player including gravity.
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