REM DRAGON TRAINING REM by Jason Gruetzmacher, 2019 REM ***INITIALIZE VARIABLES*** REM D$=DATA statement replacement (see below for what goes where) REM B, S, and D are the locations in memory where the graphics for the bat, square, and dragon are stored REM X1 and Y1 contain the locations in memory where our seven sets of X/Y coordinates are REM XS and YS contain the X and Y starting location for the dragon REM TL=is the time limit in .017 second increments 000 DIM D$(50) 010 B=ADR(D$) 020 S=B+7 030 D=S+5 040 X1=B+36 050 Y1=X1+7 060 XS=112 070 YS=52 080 TL=116 REM Data for graphics and locations for the square/bats. 'olap' indicates I overlapped the square and dragon to save a couple of characters REM D$="\Bat(0-6) \Square(7-13) \olap \Dragon(12-35) \XY Location strings for the 4 corners (36)" 100 D$="\81\81\C3\C3\FF\5A\66\00\00\1C\1C\1C\00\00\06\0F\F3\FE\0E\04\04\1E\3F\7F\E3\C3\C3\C7\FF\3C\08\8F\E1\3F\00\00\37\37\A9\A9\37\37\A9\18\60\18\60\18\60\18" REM ***SETUP*** 110 GRAPHICS 19 120 N=PEEK(106)-8:POKE 54279,N:P=N*256+384:REM N=Page number for top of memory, which we move back to make space for graphics. P=address where missile 1 starts 130 POKE 559,46:REM DMACTL: Set to double resolution 140 POKE 53277,3:REM GRACTL: Enable P/M Graphics 150 POKE 623,16:REM Turn missiles into player 5 so that we can use a 5th colour 160 POKE 704,28:REM Yellow for Square 170 POKE 711,66:REM Red for Dragon 180 POKE 708,6:REM Dark Grey for Border 200 POKE 712,10:REM Lighter Grey for background 210 FOR I=705 TO 707:POKE I,0:NEXT I:REM Black for the three bats REM playfield 220 COLOR 1:PLOT 0,0:DRAWTO 0,23:DRAWTO 33,23:DRAWTO 33,0:DRAWTO 0,0 230 PAINT 35,0 240 DO REM reset game screen, and wait for player to press the joystick button. we reset the score last so that you can see the previous score until you start a new game 250 COLOR 1:TEXT 33,1,S1:TEXT 33,9,S2 300 S1=0:S2=0 310 WHILE STRIG(0)=1:WEND 320 REPEAT:REM REPEAT as long as the player keeps getting to the square in time 330 X=XS:Y=YS:REM reset dragon to default X/Y 340 COLOR 0:PLOT 34,20:DRAWTO 38,20:REM reset timer bar 350 FOR I=0 TO 639:POKE P+I,0:NEXT I:REM reset graphics 400 Z=INT(PEEK(53770)/64):REM random number between 0-3, to determine where square goes REM draw square 410 MOVE S,P+128+PEEK(Y1+Z),7 420 POKE 53248,PEEK(X1+Z) REM draw bats 430 FOR I=1 TO 3:REM draw bats 440 MOVE B,P+128*(I+1)+PEEK(Y1+Z+I),7 500 POKE 53248+I,PEEK(X1+Z+I) 510 NEXT I 520 J=TIME:REM capture time that this round starts 530 REPEAT:REM REPEAT moving the dragon and checking the timer and collision registers 540 Q=TIME-J:REM Q=how much time has gone by since beginning of the round 550 COLOR 3:PLOT 34,20:DRAWTO 34+INT(Q/(TL/4)),20:REM update the timer bar 560 IF Q>=TL:REM stop round if timer has expired 570 T=9 580 GOTO 900 590 ENDIF REM clear collision registers 600 POKE 53278,0 REM move the dragon 610 K=STICK(0) 620 DX=(K>4 AND K<8)-(K>8 AND K<12) 630 DY=((K-5) MOD 4=0)-((K-6) MOD 4=0) 640 X=X+2*DX:Y=Y+2*DY 700 MOVE D,P+Y,24 710 FOR I=0 TO 3:POKE 53255-I,X+2*I:NEXT I REM check for a collision 720 T=PEEK(53256)!PEEK(53257)!PEEK(53258)!PEEK(53259) 800 IF T=1 REM increase score and make sound 810 S2=S2+1 820 IF S2=10 760 S1=S1+1 770 S2=0 780 ENDIF 795 E=15:F=E:G=E:REPEAT:SOUND 0,20,8,E:SOUND 2,40,8,F:SOUND 2,70,8,G:E=E*.8:F=F*(.85):G=G*(.88):UNTIL G<1:DSOUND 800 ENDIF REM update score on the screen 900 TEXT 33,1,S1:TEXT 33,9,S2 910 UNTIL T>0:REM time has expired or the dragon has touched the square or a bat 960 UNTIL T>1:REM game is over 999 LOOP REM ***GRAPHICS*** REM xx REM xxxx REM xxxx xx REM xxxxxxx REM xxx REM x REM x REM xxxx REM xxxxxx REM xxxxxxx REM xxx xx REM xx xx REM xx xx REM xx xxx REM xxxxxxxx REM xxxx REM x REM x xxxx REM xxx x REM xxxxxx REM x REM x REM x xx REM xxxxx REM x xx REM xxxx REM x x REM x x REM x xxxx REM xxxxxx REM xxxxxxx REM xxx xx REM xx xx REM xx xx REM xx xxx REM xxxxxxxx REM xxxx REM x REM x xxxx REM xxx x REM xxxxxx REM x x REM x x REM xx xx REM xx xx REM xxxxxxxx REM x xx x REM xx xx