Snake

Date: 198
Type: Program
Platform(s): TS 2068
Tags: Game

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.

Content

Appears On

Related Products

Related Articles

Related Content

Image Gallery

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 

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

People

No people associated with this content.

Scroll to Top