DEFINT A-Z
SCREEN 13
CONST MAXBULLETS = 16
AMBX = 199
DIM bullets(MAXBULLETS - 1, 1) AS INTEGER
DIM a(30, 30)'pixel array -- make it bigger for a bigger sprite
delay% = 8
RESTORE shooterdata
FOR J = 0 TO 30
FOR I = 0 TO 30
READ a(I, J)
NEXT
NEXT
RESTORE blooddata
FOR y = 0 TO 9
FOR x = 0 TO 8
READ blood
PSET (x, y), blood
NEXT x
NEXT y
DIM blood%(90)
GET (0, 0)-(9, 10), blood%
FOR y = 0 TO 9
FOR x = 0 TO 8
READ needle
PSET (x, y), needle
NEXT x
NEXT y
DIM needle%(90)
GET (0, 0)-(9, 10), needle%
FOR y = 0 TO 9
FOR x = 0 TO 8
READ cross
PSET (x, y), cross
NEXT x
NEXT y
DIM cross%(90)
GET (0, 0)-(9, 10), cross%
FOR y = 0 TO 9
FOR x = 0 TO 17
READ barrier
PSET (x, y), barrier
NEXT x
NEXT y
DIM barrier%(153)
GET (0, 0)-(17, 10), barrier%
CLS
ex = -24: REM start 24 spaces to the left
inc = 2
DO
GOSUB drawenemies
IF ex = 48 OR ex = -24 AND inc < 0 THEN ey = ey + 2: inc = -inc
ex = ex + inc
IF ey = 66 THEN STOP: REM hits base
GOSUB delay
CLS
GOSUB redrawbase
GOSUB shooter
LOOP
drawenemies:
PUT (ex + 85, ey + 0), needle
PUT (ex + 100, ey + 0), needle
PUT (ex + 115, ey + 0), needle
PUT (ex + 130, ey + 0), needle
PUT (ex + 145, ey + 0), needle
PUT (ex + 160, ey + 0), needle
PUT (ex + 175, ey + 0), needle
PUT (ex + 190, ey + 0), needle
PUT (ex + 205, ey + 0), needle
PUT (ex + 220, ey + 0), needle
PUT (ex + 75, ey + 15), cross
PUT (ex + 90, ey + 15), cross
PUT (ex + 105, ey + 15), cross
PUT (ex + 120, ey + 15), cross
PUT (ex + 135, ey + 15), cross
PUT (ex + 150, ey + 15), cross
PUT (ex + 195, ey + 15), cross
PUT (ex + 210, ey + 15), cross
PUT (ex + 85, ey + 30), blood
PUT (ex + 100, ey + 30), blood
PUT (ex + 115, ey + 30), blood
PUT (ex + 130, ey + 30), blood
PUT (ex + 145, ey + 30), blood
PUT (ex + 160, ey + 30), blood
PUT (ex + 175, ey + 30), blood
PUT (ex + 190, ey + 30), blood
PUT (ex + 205, ey + 30), blood
PUT (ex + 220, ey + 30), blood
PUT (ex + 75, ey + 45), needle
PUT (ex + 90, ey + 45), needle
PUT (ex + 105, ey + 45), needle
PUT (ex + 120, ey + 45), needle
PUT (ex + 135, ey + 45), needle
PUT (ex + 150, ey + 45), needle
PUT (ex + 165, ey + 45), needle
PUT (ex + 180, ey + 45), needle
PUT (ex + 195, ey + 45), needle
PUT (ex + 210, ey + 45), needle
PUT (ex + 85, ey + 60), cross
PUT (ex + 100, ey + 60), cross
PUT (ex + 115, ey + 60), cross
PUT (ex + 130, ey + 60), cross
PUT (ex + 145, ey + 60), cross
PUT (ex + 160, ey + 60), cross
PUT (ex + 175, ey + 60), cross
PUT (ex + 190, ey + 60), cross
PUT (ex + 205, ey + 60), cross
PUT (ex + 220, ey + 60), cross
PUT (ex + 75, ey + 75), blood
PUT (ex + 90, ey + 75), blood
PUT (ex + 105, ey + 75), blood
PUT (ex + 120, ey + 75), blood
PUT (ex + 135, ey + 75), blood
PUT (ex + 150, ey + 75), blood
PUT (ex + 165, ey + 75), blood
PUT (ex + 180, ey + 75), blood
PUT (ex + 195, ey + 75), blood
PUT (ex + 210, ey + 75), blood
RETURN
shooter:
'Setup program and data
'Make each slot empty (set both coordinates to -1)
FOR bul = 0 TO UBOUND(bullets, 1)
bullets(bul, 0) = -1
bullets(bul, 1) = -1
NEXT bul
'Main loop
DO
IF OLDAMBX <> AMBX THEN
LINE (OLDAMBX, 150)-(OLDAMBX + 35, 170 + 35), 0, BF
END IF
OLDAMBX = AMBX
'Update objects
'For each bullet
FOR bul = 0 TO UBOUND(bullets, 1)
'If it's not an empty slot
IF NOT (bullets(bul, 0) = -1 AND bullets(bul, 1) = -1) THEN
'Erase the bullet from it's old position
PSET (bullets(bul, 0), bullets(bul, 1)), 0
'Move the bullet up one pixel
bullets(bul, 1) = bullets(bul, 1) - 1
'If it's off the screen, make it an empty slot again
IF bullets(bul, 1) < 0 THEN
bullets(bul, 0) = -1
bullets(bul, 1) = -1
'Otherwise, draw it in it's new spot
ELSE
'Draw the bullet
PSET (bullets(bul, 0), bullets(bul, 1)), 15
END IF
END IF
NEXT bul
FOR J = 0 TO 30
FOR I = 0 TO 30
PSET (I + AMBX, 170 + J), a(I, J)
NEXT
NEXT
'Get user input
a$ = INKEY$
IF a$ <> "" THEN
REM allows a redraw even when key is held down
nodelay = 1
switchvar = switchvar + 1: IF switchvar > 1 THEN switchvar = 0: a$ = "": nodelay = 0
END IF
SELECT CASE a$
'Fire a bullet
CASE CHR$(32)
FOR bul = 0 TO UBOUND(bullets, 1)
'Create a new bullet if it's an empty slot
IF (bullets(bul, 0) = -1 AND bullets(bul, 1) = -1) THEN
bullets(bul, 0) = INT(AMBX + 9)
bullets(bul, 1) = 170
EXIT FOR
END IF
NEXT bul
CASE CHR$(27)
SYSTEM
CASE CHR$(0) + CHR$(75)
IF AMBX > 0 THEN AMBX = AMBX - 5
CASE CHR$(0) + CHR$(77)
IF AMBX < 320 THEN AMBX = AMBX + 5
CASE "": RETURN
END SELECT
'Delay for 1/10th of a second
''''''''IF switchvar = 0 THEN RETURN
STime! = TIMER
WHILE TIMER - STime! < .01: WEND
LOOP
'End program
RETURN
redrawbase:
'***PUT***
CLS
PUT (75, 150), barrier
PUT (125, 150), barrier
PUT (175, 150), barrier
PUT (225, 150), barrier
RETURN
delay:
IF nodelay = 1 THEN nodelay = 0: RETURN
FOR Reps% = 1 TO delay%
WAIT &H3DA, 8
WAIT &H3DA, 8, 8
NEXT Reps%
RETURN
shooterdata:
DATA 00,00,00,00,00,00,00,00,00,04,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
DATA 00,00,00,00,00,00,00,00,00,04,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
DATA 00,00,00,00,15,00,00,04,00,04,00,04,00,00,15,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
DATA 00,00,00,00,15,15,00,04,15,04,15,04,00,15,15,00,00,00,14,04,14,00,00,00,00,00,00,00,00,00,00
DATA 00,00,00,00,15,15,15,04,04,04,04,04,15,15,15,00,00,00,04,14,04,00,00,00,00,00,00,00,00,00,00
DATA 00,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,00,00,00,00,00,00,00,00,00,00
DATA 00,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,03,17,03,15,00,00,00,00,00,00,00,00,00
DATA 00,15,15,15,15,15,15,04,04,04,04,04,15,15,15,15,15,15,03,17,03,15,00,00,00,00,00,00,00,00,00
DATA 00,15,15,15,15,15,15,04,04,04,04,04,15,15,15,15,15,15,03,17,17,15,00,00,00,00,00,00,00,00,00
DATA 00,15,15,15,15,15,15,04,04,04,04,04,15,15,15,15,15,15,03,17,03,15,00,00,00,00,00,00,00,00,00
DATA 00,15,15,15,15,15,15,04,04,04,04,04,15,15,15,15,15,15,15,15,15,15,15,15,15,15,12,12,00,00,00
DATA 00,15,15,04,04,04,04,04,04,04,04,04,04,04,04,04,15,15,15,15,15,15,15,15,15,15,12,12,12,00,00
DATA 00,15,15,04,04,04,04,04,04,04,04,04,04,04,04,04,15,15,15,15,15,15,15,15,15,15,12,12,12,00,00
DATA 00,15,15,04,04,04,04,04,04,04,04,04,04,04,04,04,15,15,15,15,15,15,15,15,15,15,12,12,12,00,00
DATA 00,15,15,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,08,08,00,00
DATA 00,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,08,00,00
DATA 00,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,08,08,00,00
DATA 00,15,15,15,15,15,15,04,04,04,04,04,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,08,00,00
DATA 00,15,15,15,15,15,15,04,04,04,04,04,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,08,08,00,00
DATA 00,15,15,15,17,17,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,17,17,15,15,15,00,00
DATA 00,06,06,17,08,08,17,06,06,06,06,06,06,06,06,06,06,06,06,06,06,04,06,17,08,08,17,06,00,00,00
DATA 00,15,17,08,08,08,08,17,15,15,15,15,15,15,15,15,15,15,15,15,15,15,17,08,08,08,08,17,00,00,00
DATA 00,00,00,08,08,08,08,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,08,08,08,08,00,00,00,00
DATA 00,00,00,00,08,08,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,08,08,00,00,00,00,00
DATA 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
DATA 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
DATA 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
DATA 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
DATA 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
DATA 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
DATA 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
'**BLOOD**
blooddata:
DATA 17,17,17,17,04,17,17,17,17
DATA 17,17,17,04,04,04,17,17,17
DATA 17,17,04,04,04,04,04,17,17
DATA 17,04,04,04,04,04,04,04,17
DATA 04,04,04,04,04,04,04,04,04
DATA 04,04,04,04,04,04,04,04,04
DATA 04,04,04,04,04,04,04,04,04
DATA 04,04,04,04,04,04,04,04,04
DATA 17,04,04,04,04,04,04,04,17
DATA 17,17,17,04,04,04,17,17,17
'**NEEDLE**
needledata:
DATA 00,00,00,00,00,00,00,00,15
DATA 00,00,00,00,15,00,15,15,00
DATA 00,00,00,00,00,15,04,15,00
DATA 00,00,00,00,15,04,15,00,00
DATA 00,15,00,15,04,15,00,15,00
DATA 00,00,15,04,15,00,00,00,00
DATA 00,00,04,15,00,00,00,00,00
DATA 00,04,00,00,15,00,00,00,00
DATA 04,00,00,00,00,00,00,00,00
DATA 00,00,00,00,00,00,00,00,00
'**CROSS**
crossdata:
DATA 15,15,15,15,15,15,15,15,15
DATA 15,15,15,04,04,04,15,15,15
DATA 15,15,15,04,04,04,15,15,15
DATA 15,04,04,04,04,04,04,04,15
DATA 15,04,04,04,04,04,04,04,15
DATA 15,04,04,04,04,04,04,04,15
DATA 15,15,15,04,04,04,15,15,15
DATA 15,15,15,04,04,04,15,15,15
DATA 15,15,15,04,04,04,15,15,15
DATA 15,15,15,15,15,15,15,15,15
'*** Barrier
barrierdata:
DATA 00,00,00,02,02,02,02,02,02,02,02,02,02,02,02,00,00,00
DATA 00,00,02,02,02,02,02,02,02,02,02,02,02,02,02,02,00,00
DATA 00,02,02,09,09,09,09,09,09,09,09,09,09,09,09,02,02,00
DATA 02,02,02,09,02,02,12,12,12,12,12,12,02,02,09,02,02,00
DATA 02,02,02,09,02,02,12,00,00,00,00,12,02,02,09,02,02,02
DATA 02,02,02,09,02,02,12,00,00,00,00,12,02,02,09,02,02,02
DATA 02,02,02,09,02,02,00,00,00,00,00,00,02,02,09,02,02,02
DATA 02,02,02,09,02,00,00,00,00,00,00,00,00,02,09,02,02,02
DATA 02,02,02,09,00,00,00,00,00,00,00,00,00,00,09,02,02,02
DATA 02,02,02,00,00,00,00,00,00,00,00,00,00,00,00,02,02,02
---------------------------------------------
Pete
Here's the deal. Combining just takes making the new addition into a SUB. Then, you have to do things like RESTORE to tell the program which data to read. I like to stack all data statements at the end. OK, you do have to take out extra CLS and screen statements and it alos helps to move constant variables to the top of the program.
Most importantly is to make the program cycle through everything. I included a new case in INKEY for this. If no key is selected, it cycles. If a key is held down, the cycle is still possible because of a new variable, called SWITCHVAR.
Now your part is to concentrate on the next task, which is trying to figure out how to keep that bullet going!
- Notice that it is in a for loop and to make it functional, it has to cycle out of that loop every time to redraw the rest of the screen.
Good luck,
Pete