
THIS IS THE CODE USED IN THE GAMEBASIC DEMONSTRATION PROGRAM GBDEMO.BAS
THIS PROGRAM FILE WILL NOT RUN SINCE THE GAMEBASIC ROUTINES ARE MISSING. WILL N
IT IS DISTRIBUTED TO SHOW HOW EASY IT IS TO MAKE GAMES WITH GAMEBASIC.

'|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ALIEN57:
'|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
CLS
CALL COLOUR("0", "background", 55, 40, 30)

  gb.line$(2) = "                        ALIEN INVADERS  57-line Program"
  gb.line$(3) = "                        -------------------------------"
  gb.line$(5) = "                        BY:   Duke Slywalker"
  gb.line$(7) = "   Excluding character definitions and comment lines, this program has been "
  gb.line$(8) = "       coded in only 57 lines !     THIS IS THE  POWER  OF GAMEBASIC. "
  gb.line$(10) = "             Direction keys move cannon, space bar fires missile."

gb.screen = 1
gb.screen.start.col = 0: gb.screen.start.row = 0
gb.screen.end.col = 303: gb.screen.end.row = 187

CALL TEXTSCREEN(2, "Y", "")

'----------------------------------DRAW CHARACTERS----------------------
'-------------------------------CANNON  DEFINITION-------------------------
 char$(1, 5) = "       7        "
 char$(1, 6) = "       7        "
 char$(1, 7) = "      373       "
 char$(1, 8) = " 33333333333333 "
 char$(1, 9) = "333 3 3 3 3 3 33"
char$(1, 10) = " 33333333333333 "
char$(1, 11) = "  6 6      6 6  "
char$(1, 12) = "   6        6   "

'----------------------REGULAR  ALIEN  DEFINITION--------------------------
 char$(2, 1) = "       7        "
 char$(2, 2) = "      747       "
 char$(2, 3) = "    7744477     "
 char$(2, 4) = "   774444477    "
 char$(2, 5) = "  77444444477   "
 char$(2, 6) = " 7777777777777  "
 char$(2, 7) = "848484848484848 "
 char$(2, 8) = "848484848484848 "
 char$(2, 9) = " 4 4 4 4 4 4 4  "

'---------------------------------MISSILE  DEFINITION------------------------
 char$(3, 1) = "       F        "
 char$(3, 2) = "       F        "
 char$(3, 3) = "       F        "
 char$(3, 4) = "       F        "
 char$(3, 5) = "       F        "
 char$(3, 6) = "      F4F       "
 char$(3, 7) = "       4        "

 '..........................ALIEN'S FIREBALL DEFINITION.........................
 char$(4, 3) = "        4       "
 char$(4, 4) = "     4  4  4    "
 char$(4, 5) = "       444      "
 char$(4, 6) = "      44444     "
 char$(4, 7) = "        4       "
 char$(4, 8) = "      4   4     "

'-----------------------------------------------------
'----------------------Define characters
'-----------------------------------------------------
1  CALL DEFINECHAR

  '----Create Cannon, and Alien Sprites
2  CALL CREATE(1, 1, 160, 180, 0, 5, 90, "S", "S", " ")     'cannon sprite

  ' ------- following block sets up alien sprites
3  alien.spriteno = 10
4  FOR row = 10 TO 50 STEP 20
5      FOR col = 30 TO 300 STEP 30
6         CALL CREATE(alien.spriteno, 2, col, row, 3 + (level * 2), 5, 180, "W", "W", " ")
7         alien.spriteno = alien.spriteno + 1
8      NEXT col
9  NEXT row

  '----------- set up keyboard-controlled sprite (Cannon)---------
10  CALL CONTROL(1, "Y", "N", 5, "Up", 0, 0, 0, 0, "Down", 0, 0, 0, 0, "Left-arrow", 75, 1, 0, 3, "Right arrow", 77, 1, 0, 3)
11  next.missile.no = 40

  '**********************************************************************
  '-----MAIN PROGRAM LOOP-----------------------
12   end.of.game$ = "N"
13   DO WHILE end.of.game$ = "N"
14        CALL MOVE
15        LOCATE 1, 1: PRINT "Score: "; score

        'test if space bar pressed and we have to fire a missile
        '----------------------------------------------------------
16        IF inkey = 32 THEN
17           CALL SHOOT(next.missile.no, 3, 1, 0, 40, 7, "D", "D")
18           next.missile.no = next.missile.no + 1
19           IF next.missile.no > 44 THEN next.missile.no = 40
20        END IF

        'test if any missiles have hit any aliens
        '----------------------------------------------------------
21        FOR missile.no = 40 TO 44
22                CALL CHECKHIT(missile.no, 10, 39, 12, alien.no)
23                IF alien.no > 0 THEN
24                         score = score + 1
25                         CALL DELETE(missile.no, 0)
26                         CALL DELETE(alien.no, 0)
27                END IF
28        NEXT missile.no

        'test if alien has reached the bottom of the screen
        '----------------------------------------------------------
29        FOR alien.no = 10 TO 39
30            CALL INFO(alien.no, col, row, speed, direct, charno, edge$, ppm)
31            IF row >= 180 THEN
32                 gb.line$(10) = "  We landed - you lose!                   Press Y to continue."
33                 end.of.game$ = "Y"
34                 CALL TEXTSCREEN(1, "N", end.of.game$)
35            END IF
36         NEXT alien.no

         'test to see if we've hit all the aliens
         '----------------------------------------------------------
37         CALL ACTIVE(10, 39, aliens.left)
38         IF aliens.left = 0 THEN
39                 gb.line$(10) = "You got us all - GOOD SHOOTING.           Press Y to continue."
40                 end.of.game$ = "Y"
41                 CALL TEXTSCREEN(1, "N", end.of.game$)
42         END IF

         'test if we should get alien to shoot a fireball
         ' but first, test if a fireball is active
         '----------------------------------------------------------
43         CALL ACTIVE(4, 0, fireball.active)
44         IF fireball.active = 0 THEN
45            CALL RAND(10, 39, random.alien)
46            CALL ACTIVE(random.alien, 0, alien.active)
47            IF alien.active = 1 THEN
48               CALL SHOOT(4, 4, random.alien, 1, 40, 7, "D", "D")
49            END IF
50         END IF

         'test to see if a fireball has hit our cannon
         '----------------------------------------------------------
51         CALL CHECKHIT(1, 4, 0, 8, hit)
52         IF hit > 0 THEN
53                 gb.line$(10) = " We hit your cannon - you're DEAD!        Press Y to continue! "
54                 end.of.game$ = "Y"
55                 CALL TEXTSCREEN(1, "N", end.of.game$)
56         END IF
57  LOOP

'|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
INVADERS:
'|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
gb.screen = 1
gb.screen.start.col = 0: gb.screen.start.row = 0
gb.screen.end.col = 303: gb.screen.end.row = 187

CLS
CALL COLOUR("0", "background", 55, 40, 30)

  gb.line$(2) = "                        ALIEN INVADERS   Demo Game"
  gb.line$(3) = "                        --------------------------"
  gb.line$(5) = "                        BY:   Duke Slywalker"
  gb.line$(10) = "             Direction keys move cannon, space bar fires missile."
  gb.line$(11) = "             There are 6 levels of increasing difficulty."
  gb.line$(12) = "             You only have so many missiles each level  "
  gb.line$(13) = "                      PLEASE SAVE THE WORLD !!  "

CALL TEXTSCREEN(2, "Y", "")

'----------------------------------DRAW CHARACTERS----------------------
'-------------------------------CANNON  DEFINITION-------------------------
 char$(1, 5) = "       7        "
 char$(1, 6) = "       7        "
 char$(1, 7) = "      373       "
 char$(1, 8) = " 11111111111111 "
 char$(1, 9) = "111 1 1 1 1 1 11"
char$(1, 10) = " 11111111111111 "
char$(1, 11) = "  6 6      6 6  "
char$(1, 12) = "   6        6   "

'--------------------------------ALIEN  DEFINITION--------------------------
 char$(2, 1) = "       7        "
 char$(2, 2) = "      747       "
 char$(2, 3) = "    7744477     "
 char$(2, 4) = "   774444477    "
 char$(2, 5) = "  77444444477   "
 char$(2, 6) = " 7777777777777  "
 char$(2, 7) = "848484848484848 "
 char$(2, 8) = "848484848484848 "
 char$(2, 9) = " 4 4 4 4 4 4 4  "

'---------------------------------MISSILE  DEFINITION------------------------
 char$(3, 1) = "       F        "
 char$(3, 2) = "       F        "
 char$(3, 3) = "       F        "
 char$(3, 4) = "       F        "
 char$(3, 5) = "       F        "
 char$(3, 6) = "      F4F       "
 char$(3, 7) = "       4        "

'..........................ALIEN'S FIREBALL DEFINITION.........................
 char$(4, 3) = "        4       "
 char$(4, 4) = "     4  4  4    "
 char$(4, 5) = "       444      "
 char$(4, 6) = "      44444     "
 char$(4, 7) = "        4       "
 char$(4, 8) = "      4   4     "

'----------------------HIT    ALIEN  DEFINITION--------------------------
 char$(5, 1) = "       5        "
 char$(5, 2) = "      545       "
 char$(5, 3) = "    5544455     "
 char$(5, 4) = "   554444455    "
 char$(5, 5) = "  55444444455   "
 char$(5, 6) = " 5555555555555  "
 char$(5, 7) = "848484848484848 "
 char$(5, 8) = "848484848484848 "
 char$(5, 9) = " 4 4 4 4 4 4 4  "

'----------------------Define characters
CALL DEFINECHAR

level = 0
score = 0
next.level$ = "Y"

DO WHILE next.level$ = "Y"

  level = level + 1
  CALL DELETE(1, 90)  'delete sprites from other games before starting
  CLS
  CALL MUSIC("C", "L64", "T255", "O1", "ABAB")

  '----Create Cannon, Alien and Missile Sprites so we can view them ---------
  CALL CREATE(1, 1, 160, 174, 0, 5, 90, "S", "S", "")      'cannon sprite

                    ' ------- following block sets up alien sprites
  alien.spriteno = 10
  FOR row = 10 TO 50 STEP 20
        FOR col = 30 TO 300 STEP 30
        CALL CREATE(alien.spriteno, 2, col, row, 7 + (level * 2), 5, 180, "W", "W", "")
        alien.spriteno = alien.spriteno + 1
        NEXT col
  NEXT row

  '----------- set up control sprite (Cannon)---------
  CALL CONTROL(1, "Y", "N", 5, "Up", 0, 0, 0, 0, "Down", 0, 0, 0, 0, "Left-arrow", 75, 1, 0, 3, "Right arrow", 77, 1, 0, 3)

'draw ground
CALL COLOUR("E", "ground", 0, 3, 18)
CALL TRACK("ROW", 187, 1, 320, 3, "E")

  next.missile.no = 40
  missiles.left = 60 + (15 * (7 - level))

  '-----MAIN PROGRAM LOOP ---------------------
  end.of.game$ = "N"
  DO WHILE end.of.game$ = "N"
        CALL MOVE
        CALL MUSIC("C", "L54", "T255", "O4", "GAGAGA")
        LOCATE 1, 1: PRINT "Level"; level; "Score"; score; "Missiles left"; missiles.left

        'test if space bar pressed and we have to fire a missile
        IF inkey = 32 AND missiles.left > 0 THEN
           CALL MUSIC("S", "L64", "T255", "O1", "ABCDEFG>ABCDEFG>ABCDEFG")
           CALL SHOOT(next.missile.no, 3, 1, 0, 40, 7, "D", "D")
           next.missile.no = next.missile.no + 1
           IF next.missile.no > 44 THEN next.missile.no = 40
           missiles.left = missiles.left - 1
        END IF

        'test if any missiles have hit any aliens
        FOR missile.no = 40 TO 44
            CALL ACTIVE(missile.no, 0, missile.active)
            IF missile.active = 1 THEN
                CALL CHECKHIT(missile.no, 10, 39, 8, alien.no)
                IF alien.no > 0 THEN
                    CALL INFO(alien.no, col, row, speed, direct, charno, edge$, ppm)
                    IF charno = 2 THEN
                        'change character & motion and get random new direction
                         CALL CHANGECHAR(alien.no, 5)
                         CALL RAND(120, 240, newdirection)
                         CALL MOTION(alien.no, speed * 2, newdirection, -1)
                         CALL DELETE(missile.no, 0)
                         score = score + 10
                      ELSE
                         CALL DELETE(missile.no, 0)
                         CALL DELETE(alien.no, 0)
                    END IF
                END IF
            END IF
        NEXT missile.no

        'test if alien has reached the bottom of the screen
        FOR alien.no = 10 TO 39
            CALL INFO(alien.no, col, row, speed, direct, charno, edge$, ppm)
            IF row >= 180 THEN
                 gb.line$(10) = "        We landed - you lose! "
                 gb.line$(12) = "        Play again? (Y/N)"
                 choice$ = "YN"
                 CALL TEXTSCREEN(1, "N", choice$)
                 end.of.game$ = "Y": next.level$ = "N": score = 0: level = 0
                 IF choice$ = "Y" THEN next.level$ = "Y"
             END IF
         NEXT

         'test to see if we've hit all the aliens
         CALL ACTIVE(10, 39, aliens.left)
         IF aliens.left = 0 THEN
           gb.line$(10) = "     Well done, you got them all!"
           IF level < 6 THEN
              gb.line$(11) = "     Want to go to next level? (Y/N)"
              choice$ = "YN"
            ELSE
              gb.line$(11) = "   Congratulations ; you got to the"
              gb.line$(12) = "                 end of the game"
              gb.line$(14) = "   Press M for Menu"
              choice$ = "M"
           END IF
           CALL TEXTSCREEN(2, "N", choice$)
           end.of.game$ = "Y": next.level$ = "N"
           IF choice$ = "Y" THEN next.level$ = "Y"
         END IF


         'test if we should get alien to shoot a fireball
         'first; test if a fireball is active
         CALL ACTIVE(4, 0, fireball.active)
         IF fireball.active = 0 THEN
            CALL RAND(10, 39, random.alien)
            CALL ACTIVE(random.alien, 0, alien.active)
            IF alien.active = 1 THEN
               CALL SHOOT(4, 4, random.alien, 1, 37 + (level / 2), 7, "D", "D")
            END IF
         END IF

         'test to see if a fireball has hit our cannon
         CALL CHECKHIT(1, 4, 0, 8, hit)
         IF hit > 0 THEN
            gb.line$(10) = "     We hit your canon - you lose!"
            gb.line$(12) = "     Play again? (Y/N)"
            choice$ = "YN"
            CALL TEXTSCREEN(1, "N", choice$)
            end.of.game$ = "Y": next.level$ = "N": score = 0: level = 0
            IF choice$ = "Y" THEN next.level$ = "Y"
         END IF
   LOOP
LOOP

'|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
DUCKS:
'|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
gb.screen = 1
gb.screen.start.col = 0: gb.screen.start.row = 0
gb.screen.end.col = 303: gb.screen.end.row = 187

CLS
CALL COLOUR("0", "background", 53, 58, 58)
CALL COLOUR("F", "text", 0, 0, 0)
  gb.line$(2) = "                       DUCKS in SPACE   Demo Game"
  gb.line$(3) = "                       --------------------------"
  gb.line$(5) = "                       BY:   Rubber Duckie"
  gb.line$(10) = "           Direction keys move duck, space bar fires missile."
  gb.line$(11) = "           There are 6 levels of increasing difficulty."
  gb.line$(12) = "           You have unlimited missiles, but watch for the fireballs, "
  gb.line$(13) = "            and don't let the aliens ram you!!!  "

CALL TEXTSCREEN(2, "Y", "")

'................................ALIEN  DEFINITION..............................
 char$(2, 1) = "       7        "
 char$(2, 2) = "      747       "
 char$(2, 3) = "    7744477     "
 char$(2, 4) = "   774444477    "
 char$(2, 5) = "  77444444477   "
 char$(2, 6) = " 7777777777777  "
 char$(2, 7) = "8484848484848480"
 char$(2, 8) = "8484848484848480"
 char$(2, 9) = " 4 4 4 4 4 4 4  "

'.................................MISSILE  UP DEFINITION.........................
 char$(3, 1) = "       7        "
 char$(3, 2) = "       7        "
 char$(3, 3) = "       7        "
 char$(3, 4) = "       7        "
 char$(3, 5) = "       7        "
 char$(3, 6) = "      747       "
 char$(3, 7) = "       4        "

'..........................ALIEN'S FIREBALL DEFINITION.........................
 char$(4, 3) = "        4       "
 char$(4, 4) = "     4  4  4    "
 char$(4, 5) = "       444      "
 char$(4, 6) = "      44444     "
 char$(4, 7) = "        4       "
 char$(4, 8) = "      4   4     "

'.......................MISSILE  DOWN  DEFINITION.........................
 char$(5, 6) = "       4        "
 char$(5, 7) = "      747       "
 char$(5, 8) = "       7        "
 char$(5, 9) = "       7        "
char$(5, 10) = "       7        "
char$(5, 11) = "       7        "
char$(5, 12) = "       7        "

'..........................MISSILE LEFT  DEFINITION.........................
 char$(6, 5) = "     7          "
 char$(6, 6) = "7777744         "
 char$(6, 7) = "     7          "

'.........................MISSILE RIGHT DEFINITION.........................
 char$(7, 5) = "          7     "
 char$(7, 6) = "         4477777"
 char$(7, 7) = "          7     "

'........................DUCK UP  DEFINITION.........................
 char$(8, 1) = "       4        "
 char$(8, 2) = "       4        "
 char$(8, 3) = "     77777      "
 char$(8, 4) = "    77 7 77     "
 char$(8, 5) = "   77 7 7 77    "
 char$(8, 6) = "7777 7 7 7 77777"
 char$(8, 7) = "   77 7 7 777   "
 char$(8, 8) = "    77 7 7 7    "
 char$(8, 9) = "     777777     "
char$(8, 10) = "      6666      "
char$(8, 11) = "     6    6     "
char$(8, 12) = "    6      6    "

'.......................DUCK DOWN  DEFINITION.........................
 char$(9, 1) = "    6      6    "
 char$(9, 2) = "     6    6     "
 char$(9, 3) = "      6666      "
 char$(9, 4) = "     777777     "
 char$(9, 5) = "    77 7 77     "
 char$(9, 6) = "   77 7 7 77    "
 char$(9, 7) = "7777 7 7 7 77777"
 char$(9, 8) = "   77 7 7 77    "
 char$(9, 9) = "    77 7 77     "
char$(9, 10) = "     77777      "
char$(9, 11) = "       4        "
char$(9, 12) = "       4        "

'......................DUCK LEFT DEFINITION.........................
 char$(10, 1) = "     7          "
 char$(10, 2) = "     7          "
 char$(10, 3) = "   7777   6     "
 char$(10, 4) = "  77 7 7 6      "
 char$(10, 5) = "  7 7 776       "
 char$(10, 6) = "4477 7 7        "
 char$(10, 7) = "  7 7 776       "
 char$(10, 8) = "  77 7 7 6      "
 char$(10, 9) = "   77 77  6     "
char$(10, 10) = "     77         "
char$(10, 11) = "     7          "

'.......................DUCK  RIGHT DEFINITION.........................
 char$(11, 1) = "           7    "
 char$(11, 2) = "           7    "
 char$(11, 3) = "     6   7777   "
 char$(11, 4) = "      6 7 7 77  "
 char$(11, 5) = "       6777  7  "
 char$(11, 6) = "       7  777744"
 char$(11, 7) = "       6777  7  "
 char$(11, 8) = "      6 7 7 77  "
 char$(11, 9) = "     6   7777   "
char$(11, 10) = "           7    "
char$(11, 11) = "           7    "

CALL DEFINECHAR

'-------------------------------------------------------------------------
'......................Main Program Loop - Controls Menu and Level Set Up
'-------------------------------------------------------------------------
'......................MENU...........................................

level = 0
score = 0
next.level$ = "Y"

DO WHILE next.level$ = "Y"
  level = level + 1

  '------------Delete all sprites on screen from previous games
  CALL DELETE(1, 90): CLS

  '----------------------------Set Up Aliens, Duck, etc ----------------
  alien.pixspermove = 3   'alien.direct and speed set up randomly later
                          'in Create Alien sprites

  '......create keyboard-controlled sprite (DUCK)
  CALL CREATE(1, 8, 160, 100, 0, 5, 0, "S", "S", "")
  '......define the keys that control the duck
  CALL CONTROL(1, "Y", "Y", 6, "UP", 72, 8, 0, 3, "DOWN", 80, 9, 180, 5, "LEFT", 75, 10, 270, 6, "RIGHT", 77, 11, 90, 7)

        '............create alien sprites
  FOR alien = 0 TO 9
  'get RAND alien row,col,speed,direction
     CALL RAND(1, 180, row)
     CALL RAND(1, 300, col)
     CALL RAND(24 + level, 34 + level, speed)
     CALL RAND(0, 360, Direction)
     'create alien
     CALL CREATE(10 + alien, 2, col, row, speed, 5, Direction, "W", "W", "")
     NEXT alien

  next.missile.num = 40      'there can be 5 missiles from sprite #'s 40-44
  starttime! = TIMER
  timetofire = 8 - level

  end.of.game$ = "N"
  '.....................MAIN PROGRAM LOOP .......................
  DO WHILE end.of.game$ = "N"

        LOCATE 1, 1: PRINT "Level"; level; "SCORE"; score
        CALL MOVE

        '...............launch aliens fireball
        '-------------------------------------------------------
        fireball = 0
        timenow! = TIMER

        'is it time to fire a fireball?
        IF timetofire <= (timenow! - starttime!) THEN
           fireball = 1
           starttime! = TIMER
           'set up next time-delay for firing at the duck...
           CALL RAND(.2, .5, timetofire)
           timetofire = timetofire * (6 - (level / 2))

           'check if there's already a fireball active
           CALL ACTIVE(4, 0, fireball.active)

           IF fireball.active = 0 THEN
           'there's no active fireball, so get RAND number for alien
              alien.active = 0
              DO WHILE alien.active = 0
                   CALL RAND(10, 19, firingalien)
                   'check if RAND alien is active
                   CALL ACTIVE(firingalien, 0, alien.active)
              LOOP

              IF alien.active = 1 THEN
                  CALL SHOOT(4, 4, firingalien, 1, 36 + (level / 2), 14, "D", "D")
              END IF
           END IF
        END IF

        '..............see if we should launch a missile
        '-------------------------------------------------------
        IF inkey = 32 THEN
           '...........get canon location to start missile from
           CALL INFO(1, can.col, can.row, S, d, c, e$, ppm)

           '...........create the missile sprite
           CALL SHOOT(next.missile.num, 3, 1, 0, 40, 9, "D", "D")

           '...........update next.missile.num
           next.missile.num = next.missile.num + 1
           IF next.missile.num = 45 THEN next.missile.num = 40
        END IF

        '.............check if any missiles have hit any targets.....
        '------------------------------------------------------------
        FOR missile = 40 TO 44
            'check if missile active
            CALL ACTIVE(missile, 0, missile.active)
            IF missile.active = 1 THEN
               z.hit = 0

               'has missile hit?
               CALL CHECKHIT(missile, 10, 39, 12, z.hit)
               IF z.hit > 0 THEN
                    ' yup, missile has hit one of them thar critters!
                    ' now we're going to delete the alien sprite,
                    ' the missile, and add to score
                    CALL DELETE(missile, 0)
                    CALL DELETE(z.hit, 0)
                    score = score + 10
               END IF
            END IF
        NEXT missile

        '.............check if any aliens have collided with the
        '.............DUCK .....
        '-----------------------------------------------------------
            z.hit = 0
            CALL CHECKHIT(1, 10, 39, 6, z.hit)
            IF z.hit > 0 THEN
                 ' yup, aliens have got us!!
                 'CLS
                 gb.line$(10) = "    You got squished!"
                 gb.line$(12) = "    Play again? (Y/N)"
                 choice$ = "YN"
                 CALL TEXTSCREEN(1, "n", choice$)
                 end.of.game$ = "Y": next.level$ = "N": score = 0: level = 0
                 IF choice$ = "Y" THEN next.level$ = "Y"
            END IF

        '.............check if a fireball has hit the duck....
        '-----------------------------------------------------------
            z.hit = 0
            CALL CHECKHIT(1, 4, 0, 12, z.hit)
            IF z.hit > 0 THEN
                 ' yup, fireball got us!!
                 gb.line$(10) = "   You just got frizzed!"
                 gb.line$(12) = "   Play again? (Y/N) "
                 choice$ = "YN"
                 CALL TEXTSCREEN(1, "n", choice$)
                 end.of.game$ = "Y": next.level$ = "N": score = 0: level = 0
                 IF choice$ = "Y" THEN next.level$ = "Y"
                 END IF

       '......................check if we've hit all the aliens
       '---------------------------------------------------------------

        CALL ACTIVE(10, 39, aliens.left)
        IF aliens.left = 0 THEN
           gb.line$(10) = "     Well done, you got them all!"
           IF level < 6 THEN
              gb.line$(12) = "     Want to go to next level? (Y/N)"
              choice$ = "YN"
            ELSE
              gb.line$(11) = "   Congratulations ; you got to the end"
              gb.line$(12) = "                     of the game"
              gb.line$(14) = "   Press M for Menu"
              choice$ = "M"
           END IF
           CALL TEXTSCREEN(2, "Y", choice$)
           end.of.game$ = "Y": next.level$ = "N"
           IF choice$ = "Y" THEN next.level$ = "Y"
        END IF

        '............ now lets go back and repeat this main program loop
        '--------------------------------------------------------------
  LOOP
LOOP

'|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
QUESTION:
'|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
CALL COLOUR("0", "background", 50, 45, 50)
CALL COLOUR("F", "text", 0, 0, 0)
CALL COLOUR("8", "Skin", 25, 48, 63)

gb.line$(2) = "                       GEOGRAPHY  QUIZ  Demo Game"
gb.line$(3) = "                       --------------------------"
gb.line$(5) = "                       BY:   I. Knowitall"
gb.line$(10) = "               This is a two-player game. Take it in turns to "
gb.line$(11) = "               answer the questions. You have three tries for each   "
gb.line$(12) = "               question. If you miss on the third try, or your runner gets "
gb.line$(13) = "               to the next hurdle before you answer correctly, then your "
gb.line$(14) = "               runner falls and your opponent then gets to answer a question."
gb.line$(16) = "   There are only 10 questions, asked randomly, so there will be duplicates"
CALL TEXTSCREEN(2, "Y", "")

 char$(1, 2) = "                 6666       "
 char$(1, 3) = "               6666666      "
 char$(1, 4) = "              6668886666    "
 char$(1, 5) = "              66888118888   "
 char$(1, 6) = "               888888888 8  "
 char$(1, 7) = "               888888444    "
 char$(1, 8) = "                888888888   "
 char$(1, 9) = "               888888       "
char$(1, 10) = "            2222222222      "
char$(1, 11) = "          22222222288888     888"
char$(1, 12) = "         8222222222288888  8888"
char$(1, 13) = "        888222222222228888888"
char$(1, 14) = "        88882222222222  888  "
char$(1, 15) = "      8888 22222222222       "
char$(1, 16) = "     8888   555555555        "
char$(1, 17) = "    888    555555555         "
char$(1, 18) = "    88    5555   55555       "
char$(1, 19) = "         8888     88888      "
char$(1, 20) = " 11     8888        88888    "
char$(1, 21) = "188    8888          88888   "
char$(1, 22) = "1188  8888           88888   "
char$(1, 23) = "118888888            88888   "
char$(1, 24) = "1   8888             88888   "
char$(1, 25) = "                    188888   "
char$(1, 26) = "                     1188111 "
char$(1, 27) = "                       111111"

 char$(2, 2) = "                    6666     "
 char$(2, 3) = "                  66666666   "
 char$(2, 4) = "                 6668886666  "
 char$(2, 5) = "                 66888118888 "
 char$(2, 6) = "                 888888888  8"
 char$(2, 7) = "                 888884444   "
 char$(2, 8) = "                 88888888    "
 char$(2, 9) = "                888888       "
char$(2, 10) = "            8882222222288    "
char$(2, 11) = "            22222222288822   "
char$(2, 12) = "           222222222888882   "
char$(2, 13) = "          22222222288888228   88"
char$(2, 14) = "         2222222228888222888888 "
char$(2, 15) = "         22222228888222   8888  "
char$(2, 16) = "         5555555555555        "
char$(2, 17) = "        5555555555555         "
char$(2, 18) = "       5555555  555555        "
char$(2, 19) = "      888888     888888       "
char$(2, 20) = "     888888        888888     "
char$(2, 21) = "    888888           888888   "
char$(2, 22) = "   888888              888888 "
char$(2, 23) = "  888888             888888   "
char$(2, 24) = " 888888             888888    "
char$(2, 25) = "188111             888888     "
char$(2, 26) = "111111           1888881      "
char$(2, 27) = "  1111             111111     "
char$(2, 28) = "    1111              11111   "

char$(5, 14) = "               CF               "
char$(5, 15) = "               CFFFF            "
char$(5, 16) = "               CC FFFFF         "
char$(5, 17) = "               CC    FFFFF      "
char$(5, 18) = "               CC       FFFFF   "
char$(5, 19) = "               CC          FFFFF"
char$(5, 20) = "               CFF            FF"
char$(5, 21) = "               CCFFFF         CC"
char$(5, 22) = "               CC   FFFF      CC"
char$(5, 23) = "               CC      FFFF   CC"
char$(5, 24) = "               CC         FFFFCC"
char$(5, 25) = "               CC            FCC"
char$(5, 26) = "               CC             CC"
char$(5, 27) = "                              CC"
char$(5, 28) = "                              CC"
char$(5, 29) = "                              CC"
char$(5, 30) = "                              CC"

 '    -------------------------fallen runner....
char$(6, 22) = "         888   2222          66 "
char$(6, 23) = "           8855222222     888866"
char$(6, 24) = "   88888855555522222222228888886"
char$(6, 25) = " 11188888555555888888222288 886 "
char$(6, 26) = " 111888888  55588888822   8866  "
char$(6, 27) = " 11                             "

gb.screen = 2
gb.screen.start.col = 0: gb.screen.start.row = 0
gb.screen.end.col = 607: gb.screen.end.row = 449

CALL DEFINECHAR

play.again$ = "Y"

DO WHILE play.again$ = "Y"
 CALL DELETE(1, 90): CLS       'delete sprites from last game
 gb.question$(1) = "What is the|capital city of|France?"
 gb.answer$(1) = "Paris"
 gb.question$(2) = "What is the|population of Canada|a) 2 million ?|b) 170 million ?|c) 28 million ?"
 gb.answer$(2) = "c 28 "
 gb.question$(3) = "Name one country that|borders Italy"
 gb.answer$(3) = "France Switzerland Austria"
 gb.question$(4) = "What is the capital|city of Australia?"
 gb.answer$(4) = "Canberra"
 gb.question$(5) = "In which continent would|you find Tasmania?"
 gb.answer$(5) = "Australia Australasia Australian"
 gb.question$(6) = "In which country is|the city of Calcutta?"
 gb.answer$(6) = "India"
 gb.question$(7) = "In which ocean is|the island of Fiji?"
 gb.answer$(7) = "Pacific"
 gb.question$(8) = "Name the large island|off the east coast of Africa"
 gb.answer$(8) = "Madagascar"
 gb.question$(9) = "Name one major|export of New Zealand"
 gb.answer$(9) = "sheep wool"
 gb.question$(10) = "Which country hosts the|headquarters of the EEC?"
 gb.answer$(10) = "Belgium"

 'set gamebasic question-outstanding variable to zero & reset other variables.
 gb.quest.os = 0
 runner.speed = 12

 'print headings.
 LOCATE 4, 2: PRINT " Player 1:"
 LOCATE 7, 2: PRINT " Player 2:"
 LOCATE 10, 10: PRINT "Player 1 Question"
 LOCATE 10, 50: PRINT "Player 2 Question"

 ' set up runners....
 CALL CREATE(1, 1, 100, 33, runner.speed, 3, 90, "W", "W", "")
 CALL CREATE(2, 1, 100, 83, 0, 3, 90, "W", "W", "")

 'draw running track...
 CALL TRACK("ROW", 61, 100, 999, 2, "C")
 CALL TRACK("ROW", 111, 100, 999, 2, "C")

 'DRAW HURDLES
 hurdle.pair = 0
 FOR col = 170 TO 570 STEP 100
     hurdle.pair = hurdle.pair + 1
     CALL CREATE(10 + hurdle.pair, 5, col, 29, 0, 0, 0, "S", "S", "")
     CALL CREATE(20 + hurdle.pair, 5, col, 79, 0, 0, 0, "S", "S", "")
 NEXT col

 'set up arrays for question.number,....
 REDIM current.quest(2)                   ' index is player number
 REDIM tries(2)                           ' index is player number
 REDIM question.number(2)                 ' index is player number

 'set up first random question for both players
 CALL RAND(1, 10, question.number(1))
 CALL RAND(1, 10, question.number(2))

 'initialise current.question and other variables
 current.quest(1) = 1: current.quest(2) = 1
 current.player = 1
 next.player = 2
 end.of.game$ = "N"


 '-------------------- Main Program Loop --------------------------------
 DO WHILE end.of.game$ = "N"
    CALL MOVE
    player.fell$ = "N"
    change.player$ = "N"

    'change runner's character every 20 times through
    no.loops = no.loops + 1
    IF no.loops > 20 THEN
       no.loops = 1
       runner.char = runner.char + 1
       IF runner.char > 2 THEN runner.char = 1
       CALL CHANGECHAR(current.player, runner.char)
       CALL MUSIC("S", "L64", "T230", "O0", "GF")
    END IF

    'ask the question or check the answer....
    IF current.player = 1 THEN
        CALL QUESTION(15, 5, 20, 5, question.number(1), ans$)
      ELSE
        CALL QUESTION(15, 45, 20, 45, question.number(2), ans$)
    END IF

    'if player just got question correct, then do this....
    IF ans$ = "Y" THEN

       'update question number.
       current.quest(current.player) = current.quest(current.player) + 1

       ' draw character past the next hurdle
       IF current.player = 1 THEN
           CALL CREATE(current.player, 1, current.quest(1) * 100, 33, 0, 3, 90, "W", "W", "")
         ELSE
           CALL CREATE(current.player, 1, current.quest(2) * 100, 83, 0, 3, 90, "W", "W", "")
       END IF

       'test if we've just jumped last hurdle...
       IF current.quest(current.player) = 6 THEN
           PRINT "Well done. Player "; current.player; " WINS"
           CALL MUSIC("S", "L12", "T100", "O4", "CCCGGGGGGGG")
           end.of.game$ = "Y"
         ELSE
           PRINT "That's right!  Well done.  Now it's player "; next.player; "'s turn."
           CALL MUSIC("S", "L34", "T130", "O3", "CCGGG")
       END IF

       change.player$ = "Y"
    END IF

    'check if runner has got to next hurdle before question answered.....
    CALL CHECKHIT(current.player, (10 * current.player) + current.quest(current.player), 0, 10, reached.hurdle)
    IF reached.hurdle = 1 THEN player.fell$ = "Y"

    'check if answer is wrong...
    IF ans$ = "N" THEN
        tries(current.player) = tries(current.player) + 1
        IF tries(current.player) < 3 THEN
            PRINT "Sorry, that's wrong, try again.  Hit any key"
            CALL MUSIC("S", "L64", "T230", "O1", "CBAGFED")
            CALL PAUSE(0)
          ELSE
            player.fell$ = "Y"
        END IF
    END IF

    ' check if we have to change the player
    IF change.player$ = "Y" OR player.fell$ = "Y" THEN
       tries(current.player) = 0: gb.quest.os = 0

       IF player.fell$ = "Y" THEN
           CALL CHANGECHAR(current.player, 6)
           CALL MUSIC("S", "L34", "T130", "O1", "GFEDCBA")
           PRINT "Sorry, you fell at the hurdle! "
           PRINT "The correct answer is "; gb.answer$(question.number(current.player))
           PRINT "Now it's Player "; next.player; "'s turn"
         ELSE
           PRINT "Press any key to continue"
       END IF

       'get next random question for current player.
       CALL RAND(1, 10, question.number(current.player))

       'freeze current player's character
       CALL MOTION(current.player, 0, -1, -1)

       ' create next player's character , and start it moving.
       IF next.player = 2 THEN
           current.player = 2: next.player = 1
           CALL CREATE(2, 1, current.quest(2) * 100, 83, runner.speed, 3, 90, "W", "W", "")
         ELSE
           current.player = 1: next.player = 2
           CALL CREATE(1, 1, current.quest(1) * 100, 33, runner.speed, 3, 90, "W", "W", "")
       END IF

       ' wait for any key to be pressed
       CALL PAUSE(0)
    END IF

 LOOP

 gb.line$(10) = "     Play again?  Y/N: "
 play.again$ = "YN"
 CALL TEXTSCREEN(2, "Y", play.again$)
 play.again$ = UCASE$(play.again$)

LOOP

''|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
HACKMAN:
'|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
CALL COLOURRESET
CALL COLOUR("0", "background", 50, 45, 50)
CALL COLOUR("D", "block colour", 50, 10, 10)
CALL COLOUR("F", "text", 0, 0, 0)

'SCREEN 13


gb.line$(2) = "                       HACK-MAN     Demo Game"
gb.line$(3) = "                       ----------------------"
gb.line$(5) = "                       BY:   I. Gobble'em"
gb.line$(10) = "                You have to get all the yellow ghosties,    "
gb.line$(11) = "                all the dots and the 4 cups of gold without "
gb.line$(12) = "                getting eaten by the purple people eaters!"
CALL TEXTSCREEN(2, "Y", "")

 char$(1, 2) = "   FFFFF      "
 char$(1, 3) = "  FF11FFFF   "
 char$(1, 4) = "FFFFFFF       "
 char$(1, 5) = "FFFFF44  4    "
 char$(1, 6) = "FFFFFF4444  "
 char$(1, 7) = "  FFFFFF    "

 char$(2, 2) = "    55     "
 char$(2, 3) = "  555555   "
 char$(2, 4) = " 55 55 55  "
 char$(2, 5) = "55  55  55 "
 char$(2, 6) = "55  55  55 "
 char$(2, 7) = "55  55  55 "

 char$(3, 1) = " 44     44 "
 char$(3, 2) = " 448888844 "
 char$(3, 3) = " 448888844 "
 char$(3, 4) = " 448888844 "
 char$(3, 5) = " 444444444 "
 char$(3, 6) = "    444    "
 char$(3, 7) = "    444    "
 char$(3, 8) = "   44444   "
 char$(3, 9) = " 444444444 "

 char$(4, 2) = "    ee     "
 char$(4, 3) = "  eeeeee   "
 char$(4, 4) = " ee ee ee  "
 char$(4, 5) = "ee  ee  ee "
 char$(4, 6) = "ee  ee  ee "
 char$(4, 7) = "ee  ee  ee "

 char$(5, 4) = "    66     "
 char$(5, 5) = "    66     "

gb.screen = 1
gb.screen.start.col = 0: gb.screen.start.row = 0
gb.screen.end.col = 320: gb.screen.end.row = 199

CALL DEFINECHAR

play.again$ = "Y"
DO WHILE play.again$ = "Y" OR play.again$ = "y"

 CALL DELETE(1, 90): CLS   'delete sprites from last game
 r = 12: c = 12   'row and column increments (makes TRACK command easier!)

 dot.no = 20
 '1
 CALL TRACK("row", 1 * r, 1 + 1 * c, 4 * c, 1 * r, "D")
 CALL TRACK("row", 1 * r, 1 + 5 * c, 12 * c, 1 * r, "D")
 CALL TRACK("row", 1 * r, 1 + 13 * c, 1 + 16 * c, 1 * r, "D")

 '2
 CALL TRACK("col", 1 + 1 * c, 2 * r, 4 * r, 1 * c, "D")
 CALL TRACK("col", 1 + 8 * c, 2 * r, 6 * r, 1 * c, "D")
 CALL TRACK("col", 1 + 15 * c, 2 * r, 4 * r, 1 * c, "D")

 '3
 CALL TRACK("col", 1 + 3 * c, 3 * r, 9 * r, 1 * c, "D")
 CALL TRACK("col", 1 + 5 * c, 3 * r, 6 * r, 2 * c, "D")
 CALL TRACK("col", 1 + 10 * c, 3 * r, 6 * r, 2 * c, "D")
 CALL TRACK("col", 1 + 13 * c, 3 * r, 9 * r, 1 * c, "D")

 '4
 CALL TRACK("col", 1 + 1 * c, 5 * r, 6 * r, 2 * c, "D")
 CALL TRACK("col", 1 + 5 * c, 6 * r, 9 * r, 1 * c, "D")
 CALL TRACK("col", 1 + 11 * c, 6 * r, 9 * r, 1 * c, "D")
 CALL TRACK("col", 1 + 14 * c, 5 * r, 6 * r, 2 * c, "D")

 '5
 CALL TRACK("col", 1 + 1 * c, 7 * r, 13 * r, 1 * c, "D")
 CALL TRACK("col", 1 + 15 * c, 7 * r, 13 * r, 1 * c, "D")

 '6
 CALL TRACK("col", 1 + 2 * c, 10 * r, 13 * r, 2 * c, "D")
 CALL TRACK("col", 1 + 5 * c, 10 * r, 13 * r, 2 * c, "D")
 CALL TRACK("col", 1 + 8 * c, 10 * r, 13 * r, 1 * c, "D")
 CALL TRACK("col", 1 + 10 * c, 10 * r, 13 * r, 2 * c, "D")
 CALL TRACK("col", 1 + 13 * c, 10 * r, 13 * r, 2 * c, "D")

 '7
 CALL TRACK("col", 1 + 1 * c, 14 * r, 15 * r, 7 * c, "D")
 CALL TRACK("col", 1 + 9 * c, 14 * r, 15 * r, 7 * c, "D")

 'middle
 CALL TRACK("col", 1 + 7 * c, 7 * r, 8 * r, 3 * c, "D")
 CALL TRACK("col", 1 + 7 * c, 8 * r, 9 * r, 1 * c, "D")
 CALL TRACK("col", 1 + 9 * c, 8 * r, 9 * r, 1 * c, "D")

 'outside lines
 CALL TRACK("col", 0, 0, 16 * r, 1, "D")
 CALL TRACK("col", 1 + 17 * c, 0, 16 * r, 1, "D")
 CALL TRACK("row", 0, 0, 1 + 17 * c, 1, "D")
 CALL TRACK("row", 16 * r, 0, 1 + 17 * c, 4, "D")


 'create the dots (uses POINT instruction to find colour on screen at top left
 ' position of where we would place dot. If 15, then it's a border, 0 is OK)
 dot.no = 20
 FOR row = 0 TO 12 STEP 2
   FOR col = 0 TO 16 STEP 2
     IF POINT(2 + (col * c), 2 + (row * r)) = 0 THEN
        CALL CREATE(dot.no, 5, 2 + (col * c), 2 + (row * r), 0, 12, 270, "S", "S", "0")
        dot.no = dot.no + 1
     END IF
   NEXT col
 NEXT row
 'do same again for last five rows.
 FOR row = 13 TO 17 STEP 2
   FOR col = 0 TO 16 STEP 2
     IF POINT(2 + (col * c), 2 + (row * r)) = 0 THEN
        CALL CREATE(dot.no, 5, 2 + (col * c), 2 + (row * r), 0, 12, 270, "S", "S", "0")
        dot.no = dot.no + 1
     END IF
   NEXT col
 NEXT row

 'set up all the characters
 CALL CREATE(1, 1, 2 + 8 * c, 2 + 8 * r, 0, 0, 90, "S", "S", "0")      'hackman
 CALL CREATE(2, 2, 2, 2, 32, 12, 270, "S", "S", "0")                   'gobbler1
 CALL CREATE(3, 2, 1 + 15 * c, 2, 32, 12, 90, "S", "S", "0")           'gobbler2
 CALL CREATE(4, 2, 2, 2 + 15 * r, 32, 12, 90, "S", "S", "0")           'gobbler3
 CALL CREATE(5, 2, 2 + 16 * c, 2 + 15 * r, 32, 12, 90, "S", "S", "0")  'gobbler4
 CALL CREATE(6, 3, 2, 2, 0, 0, 0, "S", "S", "0")                       'cup1
 CALL CREATE(7, 3, 1 + 15 * c, 2, 0, 0, 0, "S", "S", "0")              'cup2
 CALL CREATE(8, 3, 2, 2 + 15 * r, 0, 0, 0, "S", "S", "0")              'cup3
 CALL CREATE(9, 3, 2 + 16 * c, 2 + 15 * r, 0, 0, 0, "S", "S", "0")     'cup4
 CALL CREATE(10, 4, 2, 2 + 2 * c, 20, 12, 0, "S", "S", "0")            'ghost1
 CALL CREATE(11, 4, 2, 2 + 6 * c, 22, 12, 180, "S", "S", "0")          'ghost2
 CALL CREATE(12, 4, 2, 2 + 10 * c, 24, 12, 0, "S", "S", "0")           'ghost3
 CALL CREATE(13, 4, 2 + 16 * c, 2 + 2 * r, 26, 12, 0, "S", "S", "0")   'ghost4
 CALL CREATE(14, 4, 2 + 16 * c, 2 + 6 * r, 28, 12, 180, "S", "S", "0") 'ghost5
 CALL CREATE(15, 4, 2 + 16 * c, 2 + 10 * r, 30, 12, 0, "S", "S", "0")  'ghost6

 'control hack-man.
 CALL CONTROL(1, "Y", "Y", 12, "UP", 72, 1, 0, 0, "DOWN", 80, 1, 0, 0, "LEFT", 75, 1, 0, 0, "RIGHT", 77, 1, 0, 0)

 score = 0
 end.of.game$ = "N"
 DO WHILE end.of.game$ = "N"
   LOCATE 10, 30: PRINT score
   CALL MOVE

   'check if hack-man been eaten
   CALL CHECKHIT(1, 2, 5, 6, hit)
   'yes, he's been eaten!
   IF hit > 0 THEN
      gb.line$(10) = "   Sorry, you're lunch!   "
      gb.line$(13) = "   Play again?  Y/N   "
      play.again$ = "YN"
      CALL TEXTSCREEN(1, "n", play.again$)
      end.of.game$ = "Y"
   END IF

   'check if hack man has got a pot of gold.
   CALL CHECKHIT(1, 6, 9, 6, gold)
   IF gold > 0 THEN
      CALL MUSIC("S", "L64", "T255", "O4", "GABCDEF")
      CALL DELETE(gold, 0)
      score = score + 100
   END IF

   'check if hack man has eaten a ghost.
   CALL CHECKHIT(1, 10, 15, 6, ghost)
   IF ghost > 0 THEN
      CALL MUSIC("S", "L64", "T255", "O3", "GGGGCCCC")
      CALL DELETE(ghost, 0)
      score = score + 200
   END IF

   'check if hack man has eaten a dot.
   CALL CHECKHIT(1, 20, 86, 6, dot)
   IF dot > 0 THEN
      CALL MUSIC("S", "L64", "T255", "O2", "FFFFCCCC")
      CALL DELETE(dot, 0)
      score = score + 10
   END IF

  'check if we've got all the dots, gold and ghosts!
  CALL ACTIVE(6, 86, num.left)
  IF num.left = 0 THEN
     gb.line$(10) = "   WELL DONE!  You got them all!   "
     gb.line$(13) = "   Play again?  Y/N   "
     play.again$ = "YN"
     CLS
     CALL TEXTSCREEN(1, "n", play.again$)
     end.of.game$ = "Y"
  END IF


 LOOP
 inkey = 0
 endofgame$ = "Y"

LOOP

'|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
RACQUET:
'|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
CALL COLOUR("0", "background", 50, 50, 50)
CALL COLOUR("F", "text", 0, 0, 0)

gb.line$(2) = "                       Bouncing Ball Demo Game"
gb.line$(3) = "                       ----------------------"
gb.line$(5) = "                       BY:   I. Squashem"
gb.line$(10) = "              Hit the ball back and try to get all the numbers!"
CALL TEXTSCREEN(2, "Y", "")

 char$(1, 6) = "      666      "
 char$(1, 7) = "     66666     "
 char$(1, 8) = "      666      "

 char$(2, 10) = "3333333333333333"
 char$(2, 11) = "3333333333333333"

 char$(3, 1) = "8555555555555555"
 char$(3, 2) = "8555555555555555"
 char$(3, 3) = "85555    5555555"
 char$(3, 4) = "8555     5555555"
 char$(3, 5) = "855  55  5555555"
 char$(3, 6) = "8555555  5555555"
 char$(3, 7) = "8555555  5555555"
 char$(3, 8) = "8555555  5555555"
 char$(3, 9) = "8555        5555"
char$(3, 10) = "8555        5555"
char$(3, 11) = "8555555555555555"
char$(3, 12) = "8888888888888888"

 char$(4, 1) = "8222222222222222"
 char$(4, 2) = "8222222222222222"
 char$(4, 3) = "82222       2222"
 char$(4, 4) = "8222222222  2222"
 char$(4, 5) = "8222222222  2222"
 char$(4, 6) = "82222       2222"
 char$(4, 7) = "82222  222222222"
 char$(4, 8) = "82222  222222222"
 char$(4, 9) = "82222       2222"
char$(4, 10) = "82222       2222"
char$(4, 11) = "8222222222222222"
char$(4, 12) = "8888888888888888"

 char$(5, 1) = "8111111111111111"
 char$(5, 2) = "8111111111111111"
 char$(5, 3) = "8111         111"
 char$(5, 4) = "81111111111  111"
 char$(5, 5) = "81111111111  111"
 char$(5, 6) = "81111111     111"
 char$(5, 7) = "81111111     111"
 char$(5, 8) = "81111111111  111"
 char$(5, 9) = "81111111111  111"
char$(5, 10) = "8111         111"
char$(5, 11) = "8111111111111111"
char$(5, 12) = "8888888888888888"

gb.screen = 1
gb.screen.start.col = 0: gb.screen.start.row = 0
gb.screen.end.col = 303: gb.screen.end.row = 187

CALL DEFINECHAR

play.again$ = "Y"
DO WHILE play.again$ = "Y" OR play.again$ = "y"

 CALL DELETE(1, 90): CLS   'delete sprites from last game
 ball.speed = 35
 ball.pixs = 5
 bat.pixs = 11
 hit.tolerance = 12

 gb.screen.end.col = 245

 'draw sides and top
 CALL TRACK("col", 2, 0, 300, 2, "E")
 CALL TRACK("col", 245, 0, 5160, 2, "E")
 CALL TRACK("ROW", 0, 2, 245, 2, "E")

 'create bat
 CALL CREATE(2, 2, 150, 183, 0, 9, 0, "S", "S", "")
 CALL CONTROL(2, "Y", "N", bat.pixs, "UP", 0, 0, 0, 0, "DOWN", 0, 0, 0, 0, "LEFT", 75, 0, 0, 0, "RIGHT", 77, 0, 0, 0)

 'create blocks
 itno = 0
 FOR col = 4 TO 228 STEP 16
     CALL CREATE(10 + itno, 5, col, 2, 0, 0, 0, "", "", "")
     CALL CREATE(25 + itno, 4, col, 14, 0, 0, 0, "", "", "")
     CALL CREATE(40 + itno, 3, col, 26, 0, 0, 0, "", "", "")
     itno = itno + 1
 NEXT col

 'set screen limits for ball
 gb.screen.end.col = 238
 gb.screen.start.col = 0
 gb.screen.start.row = 0

 'create ball
 CALL CREATE(1, 1, 200, 64, ball.speed, ball.pixs, 320, "B", "B", "")

 end.of.game$ = "N"
 b.score = 0
 LOCATE 5, 35: PRINT "Score"

 DO WHILE end.of.game$ = "N"

    CALL MOVE

    'find out where the ball is.
    CALL INFO(1, ball.col, ball.row, S, ball.direct, c, edge$, ppm)

    'check if ball has hit any blocks if it is on row 37 or less.
    block = 0
    IF ball.row < 38 THEN CALL CHECKHIT(1, 10, 54, hit.tolerance, block)
    IF block > 0 THEN
         'yes, it has hit a block.
         CALL INFO(block, c, r, S, d, charno, e$, ppm)
         CALL DELETE(block, 0)
         IF charno = 5 THEN b.score = b.score + 3
         IF charno = 4 THEN b.score = b.score + 2
         IF charno = 3 THEN b.score = b.score + 1
         'print new score
         LOCATE 6, 35: PRINT b.score

         'now check if all the blocks have been hit.
         CALL ACTIVE(10, 54, blocks.left)
         IF blocks.left = 0 THEN
            end.of.game$ = "Y"
            gb.line$(10) = "   Well done! You hit them all. "
            gb.line$(12) = "   Play again?  Y/N "
            play.again$ = "YN"
            CALL TEXTSCREEN(1, "n", play.again$)
            end.of.game$ = "Y"
         END IF

         'make ball bounce from block
         IF ball.direct < 90 THEN newdir = 180 - ball.direct
         IF ball.direct > 270 THEN newdir = 180 + (360 - ball.direct)
         IF newdir > 360 THEN STOP
         CALL CREATE(1, 1, ball.col, ball.row, ball.speed, ball.pixs, newdir, "B", "B", "")
         CALL MUSIC("S", "L64", "T255", "O5", "CCCCC")
    END IF

    'if we've hit a side or the top then play a beep
    IF edge$ = "T" OR edge$ = "L" OR edge$ = "R" THEN CALL MUSIC("S", "L64", "T255", "O1", "CCCCC")

    'if we've hit the bottom, is the bat there?
    IF edge$ = "B" THEN
       'calc distance between ball and bat
       CALL INFO(2, bat.col, r, S, d, c, e$, ppm)
       n1 = -1 * (bat.col - ball.col)
       IF n1 < 0 THEN n1 = n1 - 1
       CALL RAND(n1 * 6, (n1 + 1) * 6, newdir)
       IF n1 < 0 THEN newdir = 360 - (newdir * -1)

       'if distance between -10 and +9 then we've hit the ball
       IF n1 >= -10 AND n1 <= 9 THEN
         CALL CREATE(1, 1, ball.col, ball.row - 2, ball.speed, ball.pixs, newdir, "B", "B", "")
         CALL MUSIC("S", "L64", "T255", "O4", "CCCCC")
        ELSE
         end.of.game$ = "Y"
         gb.line$(10) = "   Sorry, you missed."
         gb.line$(12) = "   Play again?  Y/N "
         play.again$ = "YN"
         CALL TEXTSCREEN(1, "n", play.again$)
         end.of.game$ = "Y"
        END IF
    END IF
 LOOP

LOOP

'|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
TANK:
'|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

CALL COLOUR("0", "background", 15, 33, 13)
CALL COLOUR("1", "oil", 0, 0, 0)

gb.line$(2) = "                          TANK ATTACK  Demo Game"
gb.line$(3) = "                          ----------------------"
gb.line$(5) = "                          BY:   Desert Cat"
gb.line$(9) = "             This is a two player game (unless you think you can "
gb.line$(10) = "                  beat yourself)!"
gb.line$(11) = "             You have to shoot your opponent's tank before he "
gb.line$(12) = "                  gets yours.                                "
gb.line$(14) = "             Player 1: (Top    tank) W, A, S, D keys move, ESC fires. "
gb.line$(15) = "             Player 2: (Bottom tank) Direction keys move, space bar fires."
gb.line$(17) = "             You can fire at the mountain to create a gap. If you get into "
gb.line$(18) = "             the oil, your speed will go down. If you run out of "
gb.line$(19) = "             fuel, you'll be stopped for a few seconds while your crew "
gb.line$(20) = "             goes to the nearest SHELL station for a refill. "
gb.line$(21) = "             If you both run out of shells without the game being decided,"
gb.line$(22) = "             you'll both get re-stocked (again from the SHELL station)."
gb.line$(23) = "             You can't crash down trees - this is an ecology-friendly game! "
gb.line$(24) = "             However, you can hide behind trees.  "

CALL TEXTSCREEN(2, "Y", "")

'..........................TANK UP      DEFINITION.........................
 char$(1, 1) = "       4        "
 char$(1, 2) = "       8        "
 char$(1, 3) = "      686       "
 char$(1, 4) = "    6668666     "
 char$(1, 5) = "   866686668    "
 char$(1, 6) = "   866666668    "
 char$(1, 7) = "   866686668    "
 char$(1, 8) = "   866666668    "
 char$(1, 9) = "   866666668    "
char$(1, 10) = "    6666666     "

 '..........................TANK DOWN    DEFINITION.........................
 char$(2, 1) = "    6666666     "
 char$(2, 2) = "   866666668    "
 char$(2, 3) = "   866666668    "
 char$(2, 4) = "   866686668    "
 char$(2, 5) = "   866666668    "
 char$(2, 6) = "   866686668    "
 char$(2, 7) = "    6668666     "
 char$(2, 8) = "      686       "
 char$(2, 9) = "       8        "
char$(2, 10) = "       4        "

 '..........................TANK LEFT    DEFINITION.........................
 char$(3, 3) = "    888888      "
 char$(3, 4) = "   66666666     "
 char$(3, 5) = "  666666666     "
 char$(3, 6) = "48888686666     "
 char$(3, 7) = "  666666666     "
 char$(3, 8) = "   66666666     "
 char$(3, 9) = "    888888      "

 '..........................TANK RIGHT   DEFINITION.........................
 char$(4, 3) = "       88888    "
 char$(4, 4) = "     66666666   "
 char$(4, 5) = "     666666666  "
 char$(4, 6) = "     66668688884"
 char$(4, 7) = "     666666666  "
 char$(4, 8) = "     66666666   "
 char$(4, 9) = "       88888    "

 '.................................SHELL   DEFINITION.........................
char$(5, 6) = "       11       "
char$(5, 7) = "       11       "

'.................................OIL DEFINITION.........................
 char$(6, 1) = " 11111   111    "
 char$(6, 2) = "11111111111111  "
 char$(6, 3) = "  11111111111111"
 char$(6, 4) = " 11111111111111 "
 char$(6, 5) = "11111111111111  "
 char$(6, 6) = "  1111111111111 "
 char$(6, 7) = " 11111111111111 "
 char$(6, 8) = "11111111111111  "
 char$(6, 9) = " 11111111111111 "
char$(6, 10) = "  11111111111111"
char$(6, 11) = "111111111111111 "
char$(6, 12) = "11111   1111    "

'.................................TREE DEFINITION.........................
 char$(7, 1) = "           A    "
 char$(7, 2) = "    AA   AA2A   "
 char$(7, 3) = "   AAAAAAA22AA  "
 char$(7, 4) = " AAAA2222A2A2AA "
 char$(7, 5) = "  AA2AA2622A2AAA"
 char$(7, 6) = " AAA22A666A2AAA "
 char$(7, 7) = "AAA22A222AAA2AA "
 char$(7, 8) = " AAA2AA2A2A2A2AA"
 char$(7, 9) = "   AAAAA2AAAAAA "
char$(7, 10) = "     A2AAAAAA   "
char$(7, 11) = "      A   A  A  "
char$(7, 12) = "                "

'.................................ROCK DEFINITION.........................
 char$(9, 1) = " 2222 22   222  "
 char$(9, 2) = "2345622289123452"
 char$(9, 3) = "2678912345678912"
 char$(9, 4) = " 23456789123452 "
 char$(9, 5) = "  26789123456782"
 char$(9, 6) = " 291234567891232"
 char$(9, 7) = "245678912345672 "
 char$(9, 8) = " 28912345678912 "
 char$(9, 9) = " 2234567891232  "
char$(9, 10) = "2456789123452   "
char$(9, 11) = "26789123456782  "
char$(9, 12) = "  222  2 222222 "

gb.screen = 1
gb.screen.start.col = 0: gb.screen.start.row = 12
gb.screen.end.col = 303: gb.screen.end.row = 170

CALL DEFINECHAR

'------- control re-plays ----------------------
play.again$ = "Y"
DO WHILE play.again$ = "Y" OR play.again$ = "y"

 CALL DELETE(1, 90)  'delete sprites from last game
 CLS

'.................................create sprite characters...............

 '......create keyboard-controlled sprites (tanks)
 CALL CREATE(2, 1, 280, 163, 0, 5, 90, "S", "S", "")
 CALL CREATE(1, 1, 20, 15, 0, 5, 90, "S", "S", "")
 CALL CONTROL(2, "Y", "Y", 5, "UP", 72, 1, 0, 5, "DOWN", 80, 2, 180, 5, "LEFT", 75, 3, 270, 5, "RIGHT", 77, 4, 90, 5)
 CALL CONTROL(1, "Y", "Y", 5, "UP", 119, 1, 0, 5, "DOWN", 115, 2, 180, 5, "LEFT", 97, 3, 270, 5, "RIGHT", 100, 4, 90, 5)

 'create rocks
 FOR i = 1 TO 50
         CALL RAND(75, 95, row)
         CALL RAND(1, 300, col)
         CALL CREATE(i + 10, 9, col, row, 0, 0, 0, "S", "S", "")
 NEXT i

 'DRAW OIL  - 6 random blotches at top and bottom
 FOR i = 1 TO 6
     CALL RAND(1, 300, tcol)   'random col for top
     CALL RAND(5, 70, trow)    'random row for top
     CALL RAND(1, 300, bcol)   'random col for bottom
     CALL RAND(100, 165, brow)    'random row for bottom
     'create oil
     CALL CREATE((60 + i), 6, tcol, trow, 0, 0, 0, "S", "S", "")
     CALL CREATE((66 + i), 6, bcol, brow, 0, 0, 0, "S", "S", "")
 NEXT i

 'draw tree - 6 random trees at top and bottom
 FOR i = 1 TO 6
     CALL RAND(1, 300, tcol)   'random col for top
     CALL RAND(5, 70, trow)    'random row for top
     CALL RAND(1, 300, bcol)   'random col for bottom
     CALL RAND(100, 165, brow)    'random row for bottom
     'create trees
     CALL CREATE((72 + i), 7, tcol, trow, 0, 0, 0, "S", "S", "")
     CALL CREATE((78 + i), 7, bcol, brow, 0, 0, 0, "S", "S", "")
 NEXT i

' set up control variables
 fuel1 = 100: fuel2 = 100: shells1 = 20: shells2 = 20
 tank1.stalled$ = "N": tank2.stalled$ = "N": tank1.time! = 0: tank2.time! = 0

 '.....................MAIN PROGRAM LOOP .......................
 endofgame$ = "N"
 DO WHILE endofgame$ = "N"
         CALL MOVE
         LOCATE 1, 1: PRINT "Tank 1: FUEL-"; fuel1; "SHELLS-"; shells1
         LOCATE 24, 1: PRINT "Tank 2: FUEL-"; fuel2; "SHELLS-"; shells2;
         time.now! = TIMER

         'if both tanks have run out of shells, send for more!
         IF shells1 = 0 AND shells2 = 0 THEN shells1 = 20: shells2 = 20

         'if tank1 or 2 run out of fuel, make stationary for 10 seconds
         IF fuel1 = 0 AND tank1.stalled$ = "N" THEN
            tank1.time! = TIMER
            tank1.stalled$ = "Y"
            CALL MOTION(1, -1, -1, 0)
         END IF
         IF fuel2 = 0 AND tank2.stalled$ = "N" THEN
            tank2.time! = TIMER
            tank2.stalled$ = "Y"
            CALL MOTION(2, -1, -1, 0)
         END IF

         'if tanks stationary, test if time is up!
         IF tank1.stalled$ = "Y" AND time.now! - tank1.time! > 10 THEN
            tank1.stalled$ = "N": fuel1 = 100
            CALL MOTION(1, -1, -1, 5)
         END IF
         IF tank2.stalled$ = "Y" AND time.now! - tank2.time! > 10 THEN
            tank2.stalled$ = "N": fuel2 = 100
            CALL MOTION(2, -1, -1, 5)
         END IF

         '..............see if tank should fire
         IF inkey = 32 AND shells2 > 0 THEN
                 CALL SHOOT(3, 5, 2, 0, 40, 9, "D", "D")
                 CALL MUSIC("S", "L64", "T255", "O0", "CBAGFED")
                 shells2 = shells2 - 1
         END IF
         IF inkey = 27 AND shells1 > 0 THEN
                 CALL SHOOT(4, 5, 1, 0, 40, 9, "D", "D")
                 CALL MUSIC("S", "L64", "T255", "O0", "CBAGFED")
                 shells1 = shells1 - 1
         END IF

         '.............check if any shells have hit the trees.....
         ' if they have, just delete shell (tank can hide behind tree)
         CALL CHECKHIT(3, 73, 84, 8, z.hit)
         IF z.hit > 1 THEN
                 CALL DELETE(3, 0)
         END IF
         CALL CHECKHIT(4, 73, 84, 8, z.hit)
         IF z.hit > 1 THEN
                 CALL DELETE(4, 0)
         END IF

         '.............check if any shells have hit the mountain.....
         CALL CHECKHIT(3, 11, 60, 8, z.hit)
         IF z.hit > 1 THEN
                 CALL DELETE(z.hit, 0): CALL DELETE(3, 0)
                 CALL MUSIC("S", "L64", "T255", "O0", "CFCF")
         END IF
         CALL CHECKHIT(4, 11, 60, 8, z.hit)
         IF z.hit > 1 THEN
                 CALL DELETE(z.hit, 0): CALL DELETE(4, 0)
                 CALL MUSIC("S", "L64", "T255", "O0", "DDDD")
         END IF

         '............ check if a tank has moved...............
         IF inkey > 71 THEN
                 CALL MUSIC("S", "L64", "T250", "O0", "ACAC")
         END IF
         IF inkey > 70 AND inkey < 90 AND fuel2 > 0 THEN fuel2 = fuel2 - 1
         IF inkey > 90 AND inkey < 120 AND fuel1 > 0 THEN fuel1 = fuel1 - 1

         '.............check if any tank has hit the mountain.....
         CALL CHECKHIT(1, 11, 60, 10, z.hit)
         IF z.hit > 1 THEN
                 gb.line$(12) = "    Tank 1 hit mountain - Tank 2 wins!"
                 endofgame$ = "Y"
         END IF
         CALL CHECKHIT(2, 11, 60, 10, z.hit)
         IF z.hit > 1 THEN
                 gb.line$(12) = "    Tank 2 hit mountain - Tank 1 wins!"
                 endofgame$ = "Y"
         END IF

         'check if tank has hit tree, if so then moveback.
         CALL CHECKHIT(1, 73, 84, 13, z.hit)
         IF z.hit > 1 THEN
            CALL MOVEBACK(1)
         END IF
         CALL CHECKHIT(2, 73, 84, 13, z.hit)
         IF z.hit > 1 THEN
            CALL MOVEBACK(2)
         END IF

         '...check if any shell has hit a tank
         CALL CHECKHIT(3, 1, 0, 6, z.hit)
         IF z.hit > 0 THEN
                 gb.line$(12) = "    Tank 2 won !"
                 endofgame$ = "Y"
         END IF
         CALL CHECKHIT(4, 2, 0, 6, z.hit)
         IF z.hit > 0 THEN
                 gb.line$(12) = "    Tank 1 won !"
                 endofgame$ = "Y"
         END IF

        'check if any tank has hit an oil patch
         'tank 1
         CALL PIXELCOLOUR(1, topl, topr, botl, botr)
         IF topl = 1 OR topr = 1 OR botl = 1 OR botr = 1 THEN
             'slow tank down
             tank1.inoil$ = "Y"
             CALL MOTION(1, -1, -1, 1)
           ELSE
             'if tank 1 was in oil it is now out, reset pixels per move
             IF tank1.inoil$ = "Y" THEN CALL MOTION(1, -1, -1, 5)
             tank1.inoil$ = "N"
         END IF
         'tank 2
         CALL PIXELCOLOUR(2, topl, topr, botl, botr)
         IF topl = 1 OR topr = 1 OR botl = 1 OR botr = 1 THEN
             'slow tank down
             tank2.inoil$ = "Y"
             CALL MOTION(2, -1, -1, 1)
           ELSE
             'if tank 2 was in oil it is now out, reset pixels per move
             IF tank2.inoil$ = "Y" THEN CALL MOTION(2, -1, -1, 5)
             tank2.inoil$ = "N"
         END IF
'............ now lets go back and repeat this main program loop
  LOOP

  gb.line$(13) = "      Play again? Y/N"
  play.again$ = "YN"
  CALL TEXTSCREEN(1, "n", play.again$)

LOOP
