Back in 2016 I started coding this game with CPC BASIC 3 and while I got so far into it, some bits of it appeared on CPC-Rulez and CPC-Power, but I ran into problems when I was trying to Move the Graphics down the Screen with CPC BASIC 3, which ended up in a game being completed in Hisoft Pascal.
I decided to go back to what I coded in 2016 and see if I could have the graphics moving down the screen. Earlier on I was using a whole heap of User Defined Graphics to make my Graphics look like Sprites along with some Assembly, but in this post I have replaced that with the Simple Sprite Driver I created with CPC BASIC 3.
The final result is a working game, though shortly I shall be posting a CPC BASIC 3 version of the same game using an Assembly Sprite Driver I created. The advantage with this one though is I can simply tell CPC BASIC 3 to Run in the Emulator and it'll do that.
I decided to go back to what I coded in 2016 and see if I could have the graphics moving down the screen. Earlier on I was using a whole heap of User Defined Graphics to make my Graphics look like Sprites along with some Assembly, but in this post I have replaced that with the Simple Sprite Driver I created with CPC BASIC 3.
The final result is a working game, though shortly I shall be posting a CPC BASIC 3 version of the same game using an Assembly Sprite Driver I created. The advantage with this one though is I can simply tell CPC BASIC 3 to Run in the Emulator and it'll do that.
- Code:
100 ' Get the Cash! :)
110 '
120 ' Use Left / Right Arrow to Get the Cash, but avoid the Obstacles
130 '
140 DEFWORD o, x, y, w, z : DIM objects(30)
150 RANDOMIZE TIME
155 MODE 0 : BORDER 0 : INK 1,26 : INK 2,13 : INK 3,25 : INK 4,2 : INK 5,11 : INK 6,6
156 GOSUB 1910
160 yaxis = 0
170 FOR setobj=1 TO 30 STEP 3
180 x1 = setobj + 1
190 y1 = setobj + 2
200 GOSUB 540
210 objects(y1) = yaxis
220 yaxis = yaxis + &A0
230 obj = RND MOD 3+1
240 IF (obj=1 OR obj=2) THEN objects(setobj)=1 ELSE objects(setobj)=3
245 IF objects(setobj)=3 THEN p = 33 ELSE p = 1
250 w = objects(x1) : z = objects(y1) : GOSUB 1050
260 NEXT setobj
290 xp=20 : yp=1840 : w=xp : z=yp : p=65 : exit = 0 : sc = 0 : GOSUB 1050
300 FOR ys=1 TO 25 : LOCATE 13,ys : PRINT CHR$(219);: NEXT ys
310 LOCATE 14,1 : PRINT"Score:"
320 LOCATE 14,2 : PRINT Sc
330 WHILE exit = 0
331 IF INKEY(1)=0 THEN IF xp < 44 THEN p = 97 : w = xp : z = yp : GOSUB 1050 : xp = xp + 4 : p = 65 : w = xp : z = yp : GOSUB 1050 : CALL &BD19
332 IF INKEY(8)=0 THEN IF xp > 0 THEN p = 97 : w = xp : z = yp : GOSUB 1050 : xp = xp - 4 : p=65 : w = xp : z = yp : GOSUB 1050 : CALL &BD19
340 FOR ps=1 TO 30 STEP 3
350 x1 = ps + 1 : y1 = ps + 2
360 IF objects(y1)<1840 THEN GOSUB 600 : objects(y1) = objects(y1) + &50 ELSE GOSUB 600 : GOSUB 540 : objects(y1) = 0 : objects(ps) = RND MOD 3+1
365 p=65 : w = xp : z = yp : GOSUB 1050
370 IF objects(ps)=1 OR objects(ps)=2 THEN p=1 : w = objects(x1) : z = objects(y1) : GOSUB 1050 ELSE p=33 : w = objects(x1) : z = objects(y1) : GOSUB 1050
385 IF objects(y1)=1840 THEN IF xp = objects(x1) AND objects(ps) = 3 THEN p = 65 : w = xp : z = yp : GOSUB 1050 : sc=sc+10 : LOCATE 14,2 : PRINT sc;
386 IF objects(y1)=1840 THEN IF xp = objects(x1) AND objects(ps) <> 3 THEN exit = 1
390 NEXT ps
450 WEND
460 CLS : LOCATE 7,8 : PRINT "FINAL" : LOCATE 7,9 : PRINT "SCORE" : LOCATE 8,10 : PRINT sc
470 LOCATE 8,12 : PRINT "PLAY" : LOCATE 7,13 : PRINT "AGAIN" : LOCATE 7,14 : PRINT "(Y/N)" : WHILE INKEY$<>"" : WEND
480 WHILE INKEY(46)=-1
490 IF INKEY(43)<>-1 THEN GOTO 155
500 WEND
510 WHILE INKEY$<>"" : WEND : CALL &BC02 : MODE 2 : END
520 SOUND 135,0,0,0,2,,1 : RETURN
530 ' pick random number divisible by 4
540 objects(x1) = RND MOD 48
550 WHILE objects(x1) MOD 4 <> 0
560 objects(x1) = RND MOD 48
570 WEND
580 RETURN
590 ' Clear Graphics
600 p=97
610 w=objects(x1)
620 z=objects(y1)
630 GOSUB 1050
640 RETURN
1000 ' 8x8 Sprite Driver
1010 ' Entry :-
1020 ' w = x Coordinate
1030 ' z = y Coordinate
1040 ' p = Sprite Position (1 = Hazard, 33 = Money Bag, 65 = Bat, 97 = Blank)
1050 FOR y=z+0 TO z+&3800 STEP &800
1060 FOR x=w+0 TO w+3
1070 POKE &C000+x+y,b(p)
1080 p=p+1
1090 NEXT x
1100 NEXT y
1110 RETURN
1900 ' Setup Graphics
1910 DIM b(128):RESTORE 2010
1920 FOR p=1 TO 128
1930 READ b(p)
1940 NEXT p
1950 RETURN
2000 ' Hazard
2010 DATA 0,0,0,0
2020 DATA 64,128,192,128
2030 DATA 0,12,4,12
2040 DATA 64,128,192,128
2050 DATA 0,12,4,12
2060 DATA 64,128,192,128
2070 DATA 0,12,4,12
2080 DATA 0,0,0,0
2090 ' Money Bag
2100 DATA 136,0,0,68
2110 DATA 100,204,204,152
2120 DATA 112,224,192,176
2130 DATA 112,224,240,176
2140 DATA 112,192,208,176
2150 DATA 112,224,240,176
2160 DATA 112,192,192,176
2170 DATA 16,48,48,32
2180 ' Bat
2190 DATA 0,0,0,0
2200 DATA 0,0,0,0
2210 DATA 0,0,0,0
2220 DATA 0,0,0,0
2230 DATA 128,0,0,64
2240 DATA 40,0,0,20
2250 DATA 104,192,192,148
2260 DATA 60,60,60,60
2270 ' Blank
2280 DATA 0,0,0,0
2290 DATA 0,0,0,0
2300 DATA 0,0,0,0
2310 DATA 0,0,0,0
2320 DATA 0,0,0,0
2330 DATA 0,0,0,0
2340 DATA 0,0,0,0
2350 DATA 0,0,0,0