pygame is
pygame.org is
|
NanoSnake
NanoSnake - 429 Bffao (ffao)Tags:DescriptionThe original NanoSnake file had 1147 B. In the process of shortening it, I've had to make several bytes/usability tradeoffs. Also, I've incorporated suggestions from several people (Vitor Bosshard, Jordan Trudgett, Uli Eggermann, roebros, Jackson Gatenby). The updated code is below, enjoy!
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- Used three of Jordan Trudgett's suggestions: - Changed (T*T,)*2 to [T*T]*2 - Removed variable y - Added crash exit (also suggested by Vitor) - Improved pellet location selection code; - Improved input handling some more; - Another slight improvement to responsiveness (which ended up fixing glitch about collisions being detected too early). - All 1-line compound statements are now in only one line; - Changed j=lambda o: to def j(o): as per Vitor's suggestion. 429 bytes! Links
ScreenshotReleases
Pygame.org account CommentsIf you wish to leave a comment with your pygame.org account, please sign in first.
|
|