'       Space Ships(c) 1995  Created By Jeremy Burk
'
'         Ship1                     Ship2
'          up       W              Use the arrow keys
'          down     S
'          right    D              shoot   0  (turn on NUM LOCK)
'          left     A
'          shoot    space
'
'
'       This is a two player game. The object is to shoot down your oppenent
' in three shots. To control the ship push the direction you want to go.
' The ship will only turn 90 degrees each time and will keep moving.
'
'   If game moves too fast, change below line "SPEED = " to a higher number
'
'

DECLARE SUB Explode ()
DECLARE SUB ZAP2 ()
DECLARE SUB ChooseLevel ()
DECLARE SUB DrawLevel ()
DECLARE SUB ZAP1 ()
DECLARE SUB MoveShip ()
DECLARE SUB DrawShips ()

DIM SHARED S1(20, 55)
DIM SHARED S2(20, 55)

TYPE SHIP
row AS INTEGER
col AS INTEGER
direction AS INTEGER
energy AS INTEGER
END TYPE

R1L = FALSE
R1R = FALSE
R1U = FALSE
R1D = FALSE

SPEED = 500     '  change number to change game speed

CONST level = 1
DIM SHARED P(1 TO 2) AS SHIP



DrawShips


ChooseLevel


KP:
MoveShip
FOR DELAY = 1 TO SPEED
NEXT DELAY

GOTO KP


SUB ChooseLevel


SELECT CASE level

  CASE 1
      P(1).direction = 3: P(2).direction = 4
      P(1).col = 700: P(2).row = 900
      P(2).col = 2: P(2).row = 300
      P(1).energy = 3: P(2).energy = 3
      ' Turns on pixels for stars
      SCREEN 12
      FOR cnt = 1 TO 200   ' 2000 pixels in all
         col = INT(RND * 639) + 1
         row = INT(RND * 479) + 1
         colr = INT(RND * 15) + 1
         PSET (col, row), 16' colr '16
      NEXT cnt
  
   CASE 2
      P(1).direction = 3: P(2).direction = 4
      P(1).col = 700: P(2).row = 900
      P(2).col = 2: P(2).row = 300
      P(1).energy = 3: P(2).energy = 3
      ' Turns on pixels for stars
      SCREEN 12
      FOR cnt = 1 TO 200   ' 2000 pixels in all
         col = INT(RND * 639) + 1
         row = INT(RND * 479) + 1
         colr = INT(RND * 15) + 1
         PSET (col, row), 16 'colr
      NEXT cnt





    CASE ELSE
  END SELECT
END SUB

SUB DrawShips

SCREEN 12

'DRAW "BM100,100;C4R50H10L30H10D20"

CIRCLE (120, 100), 20, 8, , , .2
PAINT (110, 99), 8, 8
'LINE (100, 100)-(140, 100), 4, , &HFF00
i% = 100
DO UNTIL i% = 140
i% = i% + 5
PSET (i%, 100), 4
LOOP
DO UNTIL i% = 100
i% = i% - 5
PSET (i%, 101), 4
LOOP

'END
GET (99, 95)-(141, 105), S1
GET (99, 95)-(141, 105), S2
CLS





 CLS
END SUB

SUB Explode

  
  IF P(1).energy = 0 THEN
       FOR e = 1 TO 200
       CIRCLE (P(1).col + 20, P(1).row + 5), e, 9
       NEXT e
       FOR x = 1 TO 100: NEXT x

       FOR e = 200 TO 1 STEP -1
       CIRCLE (P(1).col + 20, P(1).row + 5), e, 0
       NEXT e

   END IF



  IF P(2).energy = 0 THEN
       FOR e = 1 TO 200
       CIRCLE (P(2).col + 20, P(2).row + 5), e, 10
       NEXT e
       FOR x = 1 TO 100: NEXT x

       FOR e = 200 TO 1 STEP -1
       CIRCLE (P(2).col + 20, P(2).row + 5), e, 0
       NEXT e


   END IF


    END


END SUB

SUB MoveShip

'MOVES THE SHIP
     
a$ = INKEY$
     'IF R1L = TRUE THEN RS1L: GOTO M2
SELECT CASE a$
     CASE CHR$(0) + "M": IF P(1).direction <> 3 THEN P(1).direction = 4  '  RIGHT
     CASE CHR$(0) + "K": IF P(1).direction <> 4 THEN P(1).direction = 3: 'RS1L '  LEFT
     CASE CHR$(0) + "P": IF P(1).direction <> 1 THEN P(1).direction = 2  '   DOWN
     CASE CHR$(0) + "H": IF P(1).direction <> 2 THEN P(1).direction = 1  '   UP
     REM IF A$ = "?" THEN XM = 0: YM = 0   'STOP
     CASE "0":  ZAP1
M2:
     CASE "D", "d": IF P(2).direction <> 3 THEN P(2).direction = 4 'RIGHT
     CASE "A", "a": IF P(2).direction <> 4 THEN P(2).direction = 3: 'LEFT
     CASE "S", "s": IF P(2).direction <> 1 THEN P(2).direction = 2'DOWN
     CASE "W", "w": IF P(2).direction <> 2 THEN P(2).direction = 1'UP
     CASE " ":   ZAP2
     CASE CHR$(27): END

     CASE ELSE
   END SELECT

            FOR a = 1 TO 2
                'Move SHIPS
                SELECT CASE P(a).direction
                    CASE 1: P(a).row = P(a).row - 1
                    CASE 2: P(a).row = P(a).row + 1
                    CASE 3: P(a).col = P(a).col - 1
                    CASE 4: P(a).col = P(a).col + 1
                END SELECT
                IF P(a).row > 400 THEN P(a).row = 400
                IF P(a).col > 580 THEN P(a).col = 580
                IF P(a).row < 10 THEN P(a).row = 10
                IF P(a).col < 3 THEN P(a).col = 3
             IF P(a).energy = 0 THEN Explode
           NEXT a
             PUT (P(1).col, P(1).row), S1, PSET
            ' PUT (P(1).col, P(1).row), S1, PSET
             PUT (P(2).col, P(2).row), S2, PSET
            ' PUT (P(2).col, P(2).row), S2, PSET
END SUB

SUB RS1L
R1L = TRUE
i% = i% + 5
PUT (P(1).col, P(1).row), S1, PSET
CIRCLE (P(1).col + i%, P(1).row + 25), 2, 9
PAINT (P(1).col + i%, P(1).row + 25), 9, 9

R1L = FALSE
END SUB

SUB ZAP1

   IF P(1).direction = 4 AND P(2).row + 5 > P(1).row AND P(2).row - 5 < P(1).row AND P(1).col < P(2).col THEN
       LINE (P(1).col + 20, P(1).row + 5)-(P(2).col, P(1).row + 5), 9
       LINE (P(2).col, P(1).row + 5)-(P(2).col + 25, P(1).row + 25), 9
       LINE (P(2).col, P(1).row + 5)-(P(2).col + 25, P(1).row - 25), 9
       LINE (P(2).col, P(1).row + 5)-(P(2).col - 25, P(1).row + 25), 9
       LINE (P(2).col, P(1).row + 5)-(P(2).col - 25, P(1).row - 25), 9
       LINE (P(2).col, P(1).row + 5)-(P(2).col, P(1).row + 25), 9
       LINE (P(2).col, P(1).row + 5)-(P(2).col, P(1).row - 25), 9

       P(2).energy = P(2).energy - 1
       ELSE IF P(1).direction = 4 THEN LINE (P(1).col + 20, P(1).row + 5)-(700, P(1).row + 5), 9
    END IF
  
  
 
   IF P(1).direction = 3 AND P(2).row + 5 > P(1).row AND P(2).row - 5 < P(1).row AND P(1).col > P(2).col THEN
       LINE (P(1).col + 40, P(1).row + 5)-(P(2).col, P(1).row + 5), 9
       LINE (P(2).col + 40, P(1).row + 5)-(P(2).col + 60, P(1).row - 25), 9
       LINE (P(2).col + 40, P(1).row + 5)-(P(2).col + 60, P(1).row + 25), 9
       LINE (P(2).col + 40, P(1).row + 5)-(P(2).col, P(1).row + 25), 9
       LINE (P(2).col + 40, P(1).row + 5)-(P(2).col, P(1).row - 25), 9
       LINE (P(2).col + 40, P(1).row + 5)-(P(2).col + 40, P(1).row + 25), 9
       LINE (P(2).col + 40, P(1).row + 5)-(P(2).col + 40, P(1).row - 25), 9

       
       








       P(2).energy = P(2).energy - 1
     ELSE IF P(1).direction = 3 THEN LINE (P(1).col - 1, P(1).row + 5)-(0, P(1).row + 5), 9
  
  
   END IF
   
END SUB

SUB ZAP2
   IF P(2).direction = 4 AND P(1).row + 5 > P(2).row AND P(1).row - 5 < P(2).row AND P(2).col < P(1).col THEN
       LINE (P(2).col + 20, P(2).row + 5)-(P(1).col, P(2).row + 5), 10
       LINE (P(1).col, P(2).row + 5)-(P(1).col + 25, P(2).row + 25), 10
       LINE (P(1).col, P(2).row + 5)-(P(1).col + 25, P(2).row - 25), 10
       LINE (P(1).col, P(2).row + 5)-(P(1).col - 25, P(2).row + 25), 10
       LINE (P(1).col, P(2).row + 5)-(P(1).col - 25, P(2).row - 25), 10
       LINE (P(1).col, P(2).row + 5)-(P(1).col, P(2).row + 25), 10
       LINE (P(1).col, P(2).row + 5)-(P(1).col, P(2).row - 25), 10

       P(1).energy = P(1).energy - 1
       ELSE IF P(2).direction = 4 THEN LINE (P(2).col + 20, P(2).row + 5)-(700, P(2).row + 5), 10



     END IF





   IF P(2).direction = 3 AND P(1).row + 5 > P(2).row AND P(1).row - 5 < P(2).row AND P(2).col > P(1).col THEN
       LINE (P(2).col + 40, P(2).row + 5)-(P(1).col, P(2).row + 5), 10
       LINE (P(1).col + 40, P(2).row + 5)-(P(1).col + 60, P(2).row - 25), 10
       LINE (P(1).col + 40, P(2).row + 5)-(P(1).col + 60, P(2).row + 25), 10
       LINE (P(1).col + 40, P(2).row + 5)-(P(1).col, P(2).row + 25), 10
       LINE (P(1).col + 40, P(2).row + 5)-(P(1).col, P(2).row - 25), 10
       LINE (P(1).col + 40, P(2).row + 5)-(P(1).col + 40, P(2).row + 25), 10
       LINE (P(1).col + 40, P(2).row + 5)-(P(1).col + 40, P(2).row - 25), 10
    
       P(1).energy = P(1).energy - 1
     ELSE IF P(2).direction = 3 THEN LINE (P(2).col - 1, P(2).row + 5)-(0, P(2).row + 5), 10
  


   END IF

END SUB

