earthworm256

Add to
My games
Add to
Wishlist
Save to
Collection
No reviews
Exceptional
Meh
Skip

About

a snake clone, written in <256 bytes of code

> how to play
  • arrow keys / ESDF: move
  • ctrl-r: restart
  • ctrl-m: mute
> code

just 250 bytes!

q=128h={}g=⬅️?"⁶c1⁶!5f10⬅️░" p=pset::_::flip()if(⬇️<1)◆=deli(h,1)else ⬇️-=1p(rnd(q),rnd(q),9)?"⁶j00⁷e" b=btnp()if(b>0)g=⬅️ ⬅️=b*.6&.75 if(⬅️==g+█&.9)⬅️=g ❎+=cos(⬅️)🅾️+=sin(⬅️)add(h,❎+🅾️*q)a=pget(❎,🅾️)⬇️+=a\9*2p(◆%q,◆\q,4)p(❎,🅾️,0)if(a>0)goto _ ?"⁷g.fed" ::e::goto e > some code highlights
  • never clear the screen, and use pget() for collision-checking
  • "move" the snake by tracking old head positions (inside h) and pset()ing the old positions to background color after a delay
  • convert btnp()bitfield into movement: b=btnp()if(b>0)angle=b*.6&.75 ... x+=cos(angle)y+=sin(angle)
  • prevent 180 degree turns: if(angle==last_angle+.5&.9)angle=last_angle
  • draw the snake in color 0 so that out-of-bounds checking and snake-collision checking are both checked by pget(x,y)==0
  • clever use of builtin variables to avoid 3-characters of initialization, e.g. ❎ for x position, which starts at 5
Platforms
Genre
Release date
Developer
pancelor
Age rating
Not rated

System requirements for Web

Read more...
earthworm256 screenshot, image №3456883 - RAWG
Edit the game info
Last Modified: Jul 8, 2022

Where to buy

itch.io