Skip to content

Instantly share code, notes, and snippets.

@simonewebdesign
Created July 25, 2019 22:34
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 simonewebdesign/b7745e9a1e7b79bdab901e9afa2e45e2 to your computer and use it in GitHub Desktop.
Save simonewebdesign/b7745e9a1e7b79bdab901e9afa2e45e2 to your computer and use it in GitHub Desktop.
Snake in PICO-8 — work in progress
pico-8 cartridge // http://www.pico-8.com
version 16
__lua__
x=64
y=64
dir=nil
l=0
r=1
u=2
d=3
function _init()
end
function _update()
if (btnp(l)) then dir=l end
if (btnp(r)) then dir=r end
if (btnp(u)) then dir=u end
if (btnp(d)) then dir=d end
if dir==l then left()
elseif dir==r then right()
elseif dir==u then up()
elseif dir==d then down()
else end -- no dir, initial
end
function _draw()
rectfill(x,y,x+1,y+1,12)
end
function left()
x = x-1
end
function right()
x = x+1
end
function up()
y = y-1
end
function down()
y = y+1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment