--- title: "Snake" id: 69524 type: "computer_media" slug: "snake" url: "http://localhost/computer_media/snake/" markdown_url: "http://localhost/computer_media/snake.md" published_at: "2026-04-14T00:12:16+00:00" modified_at: "2026-04-14T00:39:38+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2026/04/SCR-20260413-rbnp.png" excerpt: "A Snake game that encodes the entire body as a string of position characters and uses a REM-embedded machine code routine to read screen cells for collision detection." category: - name: "Archived Media" slug: "archived-media" taxonomy: "category" url: "http://localhost/category/archived-media/" post_tag: - name: "Downloadable" slug: "downloadable" taxonomy: "post_tag" url: "http://localhost/tag/downloadable/" - name: "TS 2068" slug: "ts2068" taxonomy: "post_tag" url: "http://localhost/tag/ts2068/" model: - name: "Timex/Sinclair 2068" slug: "ts-2068" taxonomy: "model" url: "http://localhost/model/ts-2068/" genre: - name: "Game" slug: "game" taxonomy: "genre" url: "http://localhost/type/game/" media_type: "Program" download_url: "https://archive.org/download/timex-sinclair-software-archive/SNAKE%20%28198x%29%28Toland%2C%20Paul%29%28TS2068%29%28US%29%28Program%29.zip" mediadate: "198" images: - url: "http://localhost/wp-content/uploads/2026/04/SCR-20260413-rbnp.png" media_type_tags: "Game" --- # Snake Guide a growing snake around a bordered play area, collecting `\$` symbols to increase its length, with game over on wall or self-collision. The snake’s body is stored as a string of screen-position-encoded `CHR\$` values — one byte per segment — and direction is maintained between keypresses by computing the delta between the head and second segment. Collision detection uses a machine code routine embedded in a `REM` statement to read character codes directly from the display file; anything other than a space or `\$` ends the game. Controls are the standard Spectrum 5/6/7/8 layout. ## Source Code ``` 0 REM GO SUB [ON ERR\©▗\\FREE $>< RETURN RND(5 RETURN \a( RUN O02 RETURN 05*6\\$ VERIFY _# THEN # THEN # THEN GO SUB [ON ERR\\PEEK # SAVE <>y AND <>*ON ERR\\ VERIFY \a MOVE !LN VERIFY LINE LIST LIST LIST LIST COPY COPY COPY COPY LIST LIST LIST LIST COPY COPY COPY COPY LIST LIST LIST LIST LIST LIST LIST LIST LIST LIST LIST LIST LIST LIST LIST LIST COPY COPY COPY COPY LIST LIST LIST LIST COPY COPY COPY COPY COPY COPY COPY COPY LIST LIST LIST LIST COPY COPY COPY COPY COPY COPY COPY COPY COPY COPY COPY COPY 10 LET base=PEEK 23635+256*PEEK 23636+5: FOR z=0 TO 6 STEP 2: POKE USR "b"+z,85: POKE USR "b"+z+1,170: NEXT z 20 CLS 30 LET s$=CHR$ 47+CHR$ 48 40 LET l=2 50 PRINT "▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄" 60 FOR i=1 TO 6 70 PRINT "▌";TAB 31;"▐" 80 NEXT i 90 PRINT "▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀" 100 PRINT "SNAKESSNAKESSNAKESSNAKESSNAKES" 110 PRINT ,,"The money snake only grows if fed with $$$.",,"You must guide it towards the $ taking care not to hit a wall oritself."''"RECORD BY AUTHOR PAUL TOLAND IS 55 " 120 LET m=l 130 LET m=INT (RND*30)+1+INT (RND*6+1)*33 140 PRINT AT INT (m/33),m-INT (m/33)*33;: IF USR base<>32 THEN GO TO 130 150 PRINT "$" 160 FOR i=1 TO 30 170 LET s=CODE s$(1) 180 PRINT AT INT (CODE s$(l)/33),CODE s$(l)-INT (CODE s$(l)/33)*33;" " 190 LET i$=INKEY$ 200 LET s=s+(i$="8")-(i$="5")+(i$="6")*33-(i$="7")*33+(i$<"5" OR i$>"8")*(s-CODE s$(2)) 210 PRINT AT INT (s/33),s-INT (s/33)*33;: LET n=USR base 220 IF n<>CODE "$" AND n<>32 THEN GO TO 290 230 LET l=l+(n=CODE "$") 240 PRINT "0" 250 LET s$=CHR$ s+s$(1 TO l-1) 260 NEXT i 270 PRINT AT INT (m/33),m-INT (m/33)*33;: IF USR base=CODE "$" THEN PRINT "0" 280 GO TO 130 290 PRINT AT 8,0;"GAME UP--You managed to grow to","a length of ";l,"TRY AGAIN ?",,,,,,,,,,, 300 IF INKEY$<>"" THEN GO TO 300 310 IF INKEY$<>"y" AND INKEY$<>"Y" AND INKEY$<>"n" AND INKEY$<>"N" THEN GO TO 310 320 IF INKEY$="y" OR INKEY$="Y" THEN RUN ```