I have made a short program I call Block Shoot to explore some blitter capabilities through the GSCROLL command. This demo also explores a technique to remove collided pixels without having to keep track of each one.
Controls are Left/Right arrows and Z button to shoot. Also supports the PSX controller.
Make sure you have the soundfont file 1mgm.sf2 from https://github.com/uli/basicengine-demos
installed in the root of the SD card.
I have a video up at https://youtu.be/XWKiQuArvIU
Below is the source code:
100 REM blockshoot.bas
110 CLS:SCREEN 4
120 DIM bulletsense(2,1):REM for bullet sensing
130 xp=155:yp=190:x1p=205:y1p=200
140 ys=189:xs=160:pxl=0
150 scrol=0:direc=2:bullet=0:REM off
160 REM setup screen
170 xb=200:yb=95:x1b=205:y1b=100:REM block
180 RECT xb,yb,x1b,y1b,100,100:REM block
190 GPRINT xp,yp,"A";:REM player
200 GPRINT 0,0,"Shots fired ";
210 GPRINT 0,10,"Hits ";
220 REM main loop
230 GOSUB &input
240 GOSUB &player
260 GOSUB &shot
270 GOSUB &block
290 REM update loop
300 GOTO 220
310 &input
320 cursor=PAD(0)
360 IF cursor AND 1 THEN xp=xp-1:x1p=x1p-1
370 IF cursor AND 4 THEN xp=xp+1:x1p=x1p+1
380 IF cursor AND 256 THEN
390 IF bullet=0 THEN
400 bullet=1:xs=xp+11
410 shot=shot+1
420 SOUND 0,0,10,100
430 GPRINT 120,0,shot;
440 ENDIF
450 ENDIF
460 RETURN
470 &player
480 IF xp<=110 THEN xp=110
490 IF xp>=200 THEN xp=200
500 GPRINT xp,yp," A ";
510 RETURN
520 &shot
530 IF bullet=1 THEN PSET xs,ys,75
560 IF ys<=101 THEN
570 bulletsense(0,0)=xs:bulletsense(0,1)=ys-1
580 bulletsense(1,0)=xs-1:bulletsense(1,1)=ys-1
590 bulletsense(2,0)=xs+1:bulletsense(2,1)=ys-1
600 WHILE pxl<3
610 px=POINT(bulletsense(pxl,0),bulletsense(pxl,1))
620 IF px=100 THEN
630 PSET bulletsense(pxl,0),bulletsense(pxl,1),0:bullet=0
640 PSET xs,ys,0:ys=189
650 SOUND 0,0,10,1000
660 hit=hit+1:GPRINT 60,10,hit;
670 pxl=3:REM get out of/loop
680 IF hit=25 THEN SOUND 1,110,50,1000:GPRINT 50,70,"YOU WIN!";
690 ENDIF
700 pxl=pxl+1
710 WEND
720 ENDIF
730 pxl=0:REM reinitialize while/pxl/loop
740 VSYNC
750 IF ys<=94 THEN
760 PSET xs,ys,0
770 bullet=0:ys=189
780 ENDIF
790 IF bullet=1 THEN
800 PSET xs,ys,0
810 ys=ys-1
820 ENDIF
840 RETURN
850 &block
860 scrol=scrol+1
880 GSCROLL 120,95,207,99,direc:REM left
890 IF scrol>=80 THEN
900 IF direc=3 THEN
910 direc=2
920 ELSE
930 direc=3
940 ENDIF
950 scrol=0
960 ENDIF
970 RETURN