0001 'SNAYK (C)2024 LAUREN32 (16K VER) 0010 A=0:B=0:I=0:J=0'MISC TEMP VARS 0013 X=0:Y=0:HD=0:TX=0:TY=0:TH=0:TV=0:XD=0:YD=0 0020 CLEAR 10 0045 DC=9'MAX DOT COUNT 0070 LV=3:SC=0:HS=0'LIVES,SCORE,HISCORE 0075 DL=1:NL=10'DIFFICULTY,NEXT LVL PTS 0080 GOSUB 8000'TITLE SCREEN 0085 GOSUB 2000'MAKE SURE OTHER VARS ARE EARLY 0170 QS=500:DIM Q(QS,2) 'MOVE QUEUE: 500=ABOUT 8K 0180 FOR I=0 TO DC:D(I,0)=-1:NEXT'EMPTY DOT SLOTS 0200 '***LBL: BEGIN MAIN CODE 0205 CLS 0 0210 GOSUB 5100 'DRAW BORDER 0215 GOSUB 5000 'DRAW SCORE DISPLAY 0217 FOR I=TX TO X:SET(I,Y,1):NEXT'DRAW INITIAL SNAKE 0220 '***LBL: MAINLOOP 0221 'SCAN KEY ROLLOVER BITS FOR INPUT. HOW PORTABLE IS THIS? 0223 'DIR VALUES: 0=NONE, 1=UP, 2=LEFT, 3=DOWN, 4=RIGHT 0230 IF PEEK(345)=251 AND HD<>1 AND HD<>3 THEN HD=1:GOTO 255'W:UP 0235 IF PEEK(339)=254 AND HD<>2 AND HD<>4 THEN HD=2:GOTO 255'A:LEFT 0240 IF PEEK(341)=251 AND HD<>3 AND HD<>1 THEN HD=3:GOTO 255'S:DOWN 0245 IF PEEK(342)=254 AND HD<>4 AND HD<>2 THEN HD=4:GOTO 255'D:RIGHT 0247 IF PEEK(342)=253 THEN CLS:PRINT "QUITTING SNAYK...":END'L:QUIT 0248 'IF PEEK(339)=253 THEN 600'I;DEBUG;LEVEL UP 0249 'IF PEEK(343)=251 THEN GOSUB 4580'U;DEBUG;SCORE UP 0250 GOTO 285'GOTO UPDATE HEAD POS 0255 MOD=(QW+1)-INT((QW+1)/QS)*QS 'ADD TO TURN QUEUE 0258 IF HD=1 THEN YD=-1:XD=0 ELSE IF HD=2 THEN YD=0:XD=-1 ELSE IF HD=3 THEN YD=1:XD=0 ELSE IF HD=4 THEN XD=1:YD=0 0260 IF MOD=QR THEN 600'FULL; NEXT LEVEL 0265 Q(QW,0)=X 0270 Q(QW,1)=Y 0275 Q(QW,2)=HD 0280 QW=MOD 0285 Y=Y+YD:X=X+XD'UPDATE HEAD POS 0300 A=POINT(X,Y)'IF POINT=-1 CELL IS TEXTMODE 0305 IF A=0 THEN 355'NO COLLISION: GOTO DRAW HEAD 0310 IF A=-1 THEN 335'WALL COLLISION: GOTO LOSE A LIFE 0315 'CHECK FOR DOT COLLISION AND MARK SLOT EMPTY IF SCORING 0320 FOR I=0 TO DC: 0325 IF X=D(I,0) AND Y=D(I,1) THEN D(I,0)=-1:DT=100:GOSUB 4580:GOTO 355'SCORE AND GOTO DRAW HEAD 0330 NEXT 0335 LV=LV-1:IF LV=0 THEN GOSUB 6000'LOSE A LIFE 0340 SOUND 9,3 0350 GOSUB 2000:GOTO 200'RESET PLAY 0355 SET(X,Y,1) 'DRAW HEAD 0360 IF GR>0 THEN GR=GR-1:GOTO 470 ELSE RESET(TX,TY)'GROW OR GOTO ADD_DOT 0370 TX=TX+TH:TY=TY+TV'UPDATE TAIL POS 0380 '**CHECK TAIL DIR CHANGE 0390 IF QR=QW THEN 470'QUEUE EMPTY: GOTO ADD DOT 0399 'IF THE NEXT ITEM IN THE QUEUE IS THE TAIL, TURN 0400 IF NOT (Q(QR,0)=TX AND Q(QR,1)=TY) THEN 470'GOTO ADD DOT 0410 A=Q(QR,2) 0420 IF A=1 THEN TH=0:TV=-1:GOTO 460'UP 0425 IF A=2 THEN TH=-1:TV=0:GOTO 460'LEFT 0430 IF A=3 THEN TH=0:TV=1:GOTO 460'DDWN 0435 IF A=4 THEN TH=1:TV=0:GOTO 460'RIGHT 0459 'REMOVE ITEM FROM QUEUE 0460 QR=(QR+1)-INT((QR+1)/QS)*QS 0470 '**LBL: ADD DOT? 0475 IF DL<12 THEN A=15-DL ELSE A=3 0480 IF DT-1 THEN RESET(D(I,0),D(I,1))'IF DOT IS ALREADY SET, GET READY TO MOVE IT 0510 SET(A,B,1):D(I,0)=A:D(I,1)=B:GOTO 220'SET RANDOM DOT AND MOVE 0520 NEXT 0530 GOTO 220'NO ROOM: GOTO MAINLOOP 0540 END 0600 '***LEVEL UP (ALSO QUEUE EXHAUSTED) 0610 NL=SC+10+(DL*5):DL=DL+1 0620 IF DL>12 AND DC>5 THEN DC=DC-1 0650 ?@171,"LEVEL UP!"; 0660 FOR I=100 TO 200 STEP 10:SOUND I,1:NEXT 0670 ?@297,"PRESS SPACEBAR"; 0680 EXEC 44539:IF PEEK(135)<>32 THEN 0680 0690 GOSUB 2000:GOTO 200'RESET PLAY 2000 '***SUB: SET UP VARS FOR NEW LIFE 2005 POKE 345,255:POKE 339,255:POKE 341,255:POKE 342,255'RESET KEY BITS 2010 QW=0:QR=0'QUEUE WRITE,READ INDEX 2030 X=35:Y=15'LOCATION OF HEAD 2040 TX=30:TY=15'TAIL X/Y 2050 TH=1:TV=0'TAIL X/Y DIR 2060 GR=0'GROWTH TIMER 2065 DT=100'DOT TIMER 2070 HD=4:XD=1:YD=0'HEAD DIR,X/Y DIR 2080 RETURN 4580 '***SUB: SCORE 4582 SC=SC+1 4583 SOUND 210,1 4585 GR=GR+5'INCREASE GROWTH TIMER 4587 GOSUB 5000'REDRAW SCORE 4590 IF SC>=NL THEN 600'LEVEL UP EVERY 25 PTS 4595 RETURN 5000 '***SUB: DRAW SCORE DISPLAY 5010 ?@480," SCORE:";SC,"LIVES:";LV;" "; 5020 ?@1,"LEVEL ";DL; 5030 POKE 1535,96'CLEAR LAST CHAR ON SCREEN W/O NEWLINE 5040 RETURN 5100 '***SUB:DRAW BORDER 5110 FOR I=0 TO 31 5120 ?" "; 5130 NEXT 5140 FOR I=1 TO 14 5150 ?@I*32," "; 5160 ?@(I*32)+31," "; 5170 NEXT 5180 RETURN 6000 '***SUB: GAME OVER 6015 SOUND 200,5:SOUND 100,5:SOUND 50,5 6020 IF SC>HI THEN HI=SC'SET NEW HIGH SCORE 6025 ?@169,"WOW! YOU LOST!"; 6030 ?@355,"PRESS ENTER TO PLAY AGAIN"; 6035 ?@496,"HI:";HI;" ";:POKE 1535,96 6040 EXEC 44539'WAIT KEYPRESS 6050 IF PEEK(135)<>13 THEN CLS:END 6060 LV=3:SC=0'RESET LIVES AND SCORE 6070 RETURN 8000 '***SUB: TITLE SCREEN 8010 CLS 0 8015 ?TAB(7);"LAUREN32 PRESENTS" 8020 FOR I=1 TO 4 8030 READ C1 8040 ?@(100+(32*I)),""; 8050 FOR J=1 TO 22 8060 READ G1 8070 ?CHR$(G1+C1); 8080 NEXT J,I 8090 ?@295,"move";:PRINT@302,"W";:PRINT@306,"quit";:PRINT@312,"L"; 8100 ?@333,"ASD"; 8110 ?@391,CHR$(161);:FOR I=1TO14:PRINT CHR$(163);:NEXT:PRINT CHR$(162); 8120 ?@423,CHR$(165);"PRESS SPACEBAR";CHR$(170); 8130 ?@455,CHR$(164);:FOR I=1TO14:PRINT CHR$(172);:NEXT:PRINT CHR$(168); 8140 EXEC 44539'WAIT KEYPRESS 8145 IF PEEK(135)<>32 THEN 8140 8150 RETURN 8500 '*LOGO DATA: FIRST ITEM OF ROW IS COLOR 8501 DATA 64,134,140,140,128,128,128,128,128,129,131,130,128,128,128,128,128,130,128,128,129,131,130 8502 DATA 16,137,131,130,128,142,140,137,128,129,131,135,128,138,128,133,128,138,134,128,139,131,134 8503 DATA 80,128,128,133,128,138,128,133,128,138,128,133,128,132,140,141,128,142,130,128,138,128,128 8504 DATA 96,140,140,136,128,136,128,132,128,132,140,140,128,131,131,134,128,136,132,128,132,140,136