CPC Basic

Basic cross-compiler for Amstad CPC


    Simple Sprites with CPC BASIC 3

    Out Bush
    Out Bush

    Posts : 8
    Join date : 2019-12-02

    Simple Sprites with CPC BASIC 3 Empty Simple Sprites with CPC BASIC 3

    Post  Out Bush on Wed Dec 04, 2019 9:02 pm

    This example I made a couple of months ago as a curiosity and was rather impressed with the result when I converted it for CPC BASIC 3. In terms of it's Source Code, not much is different from the Locomotive BASIC, though with the Locomotive BASIC version, the FOR loop for Line 1000 has to have z+&4000 or the Last Line of the Sprite isn't drawn. At least I think that's what happened, for CPC BASIC 3, it counts the z+0 as the 1st line with &3800 being the last. It works fast, though I'm using it in Character Steps on a Mode 0 Screen. To move the Sprite to the next or last character add or subtract 4 and to move up or down in character steps add or subtract &50 or 80. However over the coming threads I will show where this simple character sprite driver can work effectly and where an Assembly Sprite Driver will benefit.

    Code:

    100 MODE 0:INK 0,0:INK 1,1:INK 2,2:INK 3,11
    110 GOSUB 1100
    120 p=1:w=0:z=0:a=1:b=1:GOSUB 1000
    130 WHILE 1
    140  IF INKEY(2)=0 THEN IF b<25 THEN LOCATE a,b:PRINT" ";:z=z+&50:b=b+1:p=1:CALL &BD19:GOSUB 1000
    150  IF INKEY(0)=0 THEN IF b>1 THEN LOCATE a,b:PRINT" ";:z=z-&50:b=b-1:p=1:CALL &BD19:GOSUB 1000
    160  IF INKEY(8)=0 THEN IF a>1 THEN LOCATE a,b:PRINT" ";:w=w-4:a=a-1:p=1:CALL &BD19:GOSUB 1000
    170  IF INKEY(1)=0 THEN IF a<20 THEN LOCATE a,b:PRINT" ";:w=w+4:a=a+1:p=1:CALL &BD19:GOSUB 1000
    180 WEND
    190 LOCATE 1,10:END
    1000 FOR y=z+0 TO z+&3800 STEP &800
    1010  FOR x=w+0 TO w+3
    1020    POKE &C000+x+y,b(p)
    1030    p=p+1
    1040  NEXT x
    1050 NEXT y
    1060 RETURN
    1100 DIM b(32):RESTORE 1150
    1110 FOR p=1 TO 32
    1120  READ b(p)
    1130 NEXT p
    1140 RETURN
    1150 DATA 0,64,128,0
    1160 DATA 0,132,72,0
    1170 DATA 0,132,200,0
    1180 DATA 0,132,72,0
    1190 DATA 0,132,72,0
    1200 DATA 0,132,72,0
    1210 DATA 0,132,72,0
    1220 DATA 0,64,128,0

      Current date/time is Tue Feb 18, 2020 2:59 am