NanoSnake - 364 B
A snake game written to be as small as possible.
ffao
(ffao)
import pygame as p,random q=p.display T=16 b=q.set_mode([256]*2).fill l=[] d=a=x=1 c=p.event.get while not(x&528or x in l): l=l[a!=x:]+[x] while a&528or a in l:a=random.randrange(512) b(0);[b(99,(o%T*T,o/32*T,T,T))for o in l+[a]];q.flip();p.time.wait(99);D=d for e in c(2): v=e.key-272;n=((v&2)-1)*[1,32][v<3] if-n-D and 0<v<5:d=n c();x+=d
Changes
- Removed definition of variable D outside the loop.
NanoSnake is finally becoming stable, it's getting harder and harder to squeeze it further!
Links
- Home Page
- http://www.pygame.org
- Source
- http://stuffr.net/d/18yjm6h
Releases
NanoSnake 522 B — 30 Jul, 2008
NanoSnake 429 B — 31 Jul, 2008
NanoSnake 502 B -- The Show Must Go On — 31 Jul, 2008
NanoSnake 364 B — 12 Aug, 2008
NanoSnake 554 B — 30 Jul, 2008
NanoSnake 478 B -- The Harder They Fall — 31 Jul, 2008
NanoSnake 348 B — 16 Aug, 2008
Pygame.org account Comments
- 
          
  
    
    Guest 2014-02-28 02:15308 bytes: 
 from pygame import*;q=display;T=16;f=q.set_mode([256]*2).fill;l=[];d=a=x=n=1;E=event.get
 while not(x&528 or x in l):
 while a&528or a in l:a=a*9%512
 l=l[a!=x:]+[x];f(0);[f(-1,(o%T*T,o/32*T,T,T))for o in l+[a]];q.flip();time.wait(99);x+=d
 for e in E(2):
 v=e.key&7;n=((v&2)-1)*[1,32][v<3]
 if d+n:d=n
 E()
- 
          
  
    
    Guest 2014-02-28 02:16308 bytes (replace underscore "_" with space " "): 
 from pygame import*;q=display;T=16;f=q.set_mode([256]*2).fill;l=[];d=a=x=n=1;E=event.get
 while not(x&528 or x in l):
 _while a&528or a in l:a=a*9%512
 _l=l[a!=x:]+[x];f(0);[f(-1,(o%T*T,o/32*T,T,T))for o in l+[a]];q.flip();time.wait(99);x+=d
 _for e in E(2):
 __v=e.key&7;n=((v&2)-1)*[1,32][v<3]
 __if d+n:d=n
 _E()
 
        
       
       
       
       
       
       
       
       
      