CPC Basic

Would you like to react to this message? Create an account in a few clicks or log in to continue.
CPC Basic

Basic cross-compiler for Amstad CPC


    CPC BASIC 3 Platform Game Demo

    Out Bush
    Out Bush


    Posts : 11
    Join date : 2019-12-02

    CPC BASIC 3 Platform Game Demo Empty CPC BASIC 3 Platform Game Demo

    Post  Out Bush Sat Dec 07, 2019 8:05 pm

    Last year I wrote a Simple Platform Game in Locomotive BASIC and making variations of it with some of the Sprite Drivers available back in the day that operated using Text Coordinate positioning for the Sprites. Using the Simple Sprite Generator I had from the Simple Ball Sprite, I can use that to recreate the same simple platform. For this example the Sprite Driver runs fine, though when more and more moving sprites are added, it begins to show.

    Code:

    100 MODE 0:BORDER 0:INK 0,0:INK 1,18:INK 2,3:INK 3,11:INK 4,2:INK 5,26:INK 6,6:INK 7,15:INK 8,12:INK 9,10
    110 DEFBYTE s:GOSUB 4000:DEFWORD a-r,t-z
    130 GOSUB 1010
    140 x=RND MOD 15 + 5:y=3:LOCATE x,y:PRINT" ";:x=RND MOD 20 + 1:y=5:LOCATE x,y:PRINT" ";
    150 w=1:z=2:mx=0:my=80:p=65:d=0:x=mx:y=my:GOSUB 2010
    160 u=1:v=4:hd=1:bx=0:bc=1:p=bc:bd=4:GOSUB 1160
    170 WHILE d=0 ' Main Game Loop
    180  IF INKEY(1)=0 THEN IF mx<76 THEN p=161:x=mx:y=my:GOSUB 2010:mx=mx+4:w=w+1:GOSUB 1130:p=65:p2=p:x=mx:y=my:GOSUB 2010
    190  IF INKEY(8)=0 THEN IF mx<>0 THEN p=161:x=mx:y=my:GOSUB 2010:mx=mx-4:w=w-1:GOSUB 1130:p=97:p2=p:x=mx:y=my:GOSUB 2010
    200  GOSUB 1110
    210  p=161:GOSUB 1160:u=u+hd:bx=bx+bd:p=bc:GOSUB 1160
    220  IF u=20 THEN bd=-4:hd=-1:bc=33 ELSE IF u=1 THEN bd=4:hd=1:bc=1
    230  GOSUB 1130
    240  IF w=20 THEN IF z=6 THEN d=1
    250 WEND
    260 LOCATE 1,10:PEN 1:END
    1000 ' Draw Platforms
    1010 FOR y=&A0 TO &1E0 STEP &A0
    1020  FOR x=0 TO 76 STEP 4
    1030    p=129:GOSUB 2010
    1040  NEXT x
    1050 NEXT y
    1060 RETURN
    1100 ' Check if Character is over hole
    1110 WHILE TEST((w-1)*32,398-(z*16))=0:p=161:x=mx:y=my:GOSUB 2010:my=my+80:z=z+1:p=p2:x=mx:y=my:CALL &BD19:GOSUB 2010:WEND:RETURN
    1120 ' Check if Hazard has collided with Character
    1130 IF u=w THEN IF z=v THEN d=1:RETURN
    1140 RETURN
    1150 ' Move Hazard
    1160 x=bx:y=240:CALL &BD19:GOSUB 2010:RETURN
    2000 ' Simple Sprite Driver
    2010 FOR y1=y+0 TO y+&3800 STEP &800
    2020  FOR x1=x+0 TO x+3
    2030    POKE &C000+x1+y1,spr(p)
    2040    p=p+1
    2050  NEXT x1
    2060 NEXT y1
    2070 RETURN
    4000 DIM spr(192):RESTORE 5010
    4010 FOR p=1 TO 192
    4020  READ spr(p)
    4030 NEXT p
    4040 RETURN
    5000 REM Hazard-RightFace
    5010 DATA 0,0,0,0
    5020 DATA 0,0,128,0
    5030 DATA 20,60,120,0
    5040 DATA 0,8,128,0
    5050 DATA 0,8,0,0
    5060 DATA 16,48,48,0
    5070 DATA 0,204,136,0
    5080 DATA 0,0,0,0
    5090 REM Hazard-LeftFace
    5100 DATA 0,0,0,0
    5110 DATA 0,128,0,0
    5120 DATA 80,60,60,0
    5130 DATA 0,128,8,0
    5140 DATA 0,0,8,0
    5150 DATA 16,48,48,0
    5160 DATA 0,204,136,0
    5170 DATA 0,0,0,0
    5180 REM Man-RightFace
    5190 DATA 0,16,0,0
    5200 DATA 0,204,136,0
    5210 DATA 0,252,252,0
    5220 DATA 84,240,120,168
    5230 DATA 84,240,244,0
    5240 DATA 0,204,136,0
    5250 DATA 0,40,40,0
    5260 DATA 0,40,20,0
    5270 REM Man-LeftFace
    5280 DATA 0,0,32,0
    5290 DATA 0,68,204,0
    5300 DATA 0,252,252,0
    5310 DATA 84,180,240,168
    5320 DATA 0,248,240,168
    5330 DATA 0,68,204,0
    5340 DATA 0,20,20,0
    5350 DATA 0,40,20,0
    5360 REM Platform
    5370 DATA 3,3,3,3
    5380 DATA 67,195,195,131
    5390 DATA 67,195,195,131
    5400 DATA 67,195,195,131
    5410 DATA 0,0,0,0
    5420 DATA 0,0,0,0
    5430 DATA 0,0,0,0
    5440 DATA 0,0,0,0
    5450 REM Blank
    5460 DATA 0,0,0,0
    5470 DATA 0,0,0,0
    5480 DATA 0,0,0,0
    5490 DATA 0,0,0,0
    5500 DATA 0,0,0,0
    5510 DATA 0,0,0,0
    5520 DATA 0,0,0,0
    5530 DATA 0,0,0,0


      Current date/time is Thu Nov 21, 2024 9:59 pm