Created
          July 25, 2019 22:34 
        
      - 
      
- 
        Save simonewebdesign/b7745e9a1e7b79bdab901e9afa2e45e2 to your computer and use it in GitHub Desktop. 
    Snake in PICO-8 — work in progress
  
        
  
    
      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
    
  
  
    
  | 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