Small Basic Small Basic E-Books > Basic Computer Games Small Basic Edition > Bombardment

BOMBARDMENT is played on two 5x5 grids or boards with 25 outpost locations numbered 1 to 25. Both you and the computer have four platoons of troops that can be located at any four outposts on your respective grids.

At the start of the game, you locate (or hide) your four platoons on your grid. The computer does the same on its grid. You then take turns firing missiles or bombs at each other's outposts trying to destroy all four platoons. The one who finds all four opponents' platoons first, wins.

This program was slightly modified from the original written by Martin Burdash of Parlin, New Jersey.

Code Listing (Small Basic File: bombard.sb):

 

 

Basic Computer Games Small Basic Edition

This chapter is adapted from the book Basic Computer Games Small Basic Edition published by Kidware Software.

To purchase this book in its entirety, please see the Computer Science For Kids web site.


TextWindow.CursorLeft = 33
TextWindow.WriteLine("BOMBARDMENT")
TextWindow.CursorLeft = 15
TextWindow.WriteLine("BIBLEBYTE BOOKS, MAPLE VALLEY, WASHINGTON")
TextWindow.WriteLine("")
TextWindow.WriteLine("")
TextWindow.WriteLine("")
TextWindow.WriteLine("YOU ARE ON A BATTLEFIELD WITH 4 PLATOONS AND YOU")
TextWindow.WriteLine("HAVE 25 OUTPOSTS AVAILABLE WHERE THEY MAY BE PLACED.")
TextWindow.WriteLine("YOU CAN ONLY PLACE ONE PLATOON AT ANY ONE OUTPOST.")
TextWindow.WriteLine("THE COMPUTER DOES THE SAME WITH ITS FOUR PLATOONS.")
TextWindow.WriteLine("")
TextWindow.WriteLine("THE OBJECT OF THE GAME IS TO FIRE MISSLES AT THE")
TextWindow.WriteLine("OUTPOSTS OF THE COMPUTER.  IT WILL DO THE SAME TO YOU.")
TextWindow.WriteLine("THE ONE WHO DESTROYS ALL FOUR OF THE ENEMY'S PLATOONS")
TextWindow.WriteLine("FIRST IS THE WINNER.")
TextWindow.WriteLine("")
TextWindow.WriteLine("GOOD LUCK... AND TELL US WHERE YOU WANT THE BODIES SENT!")
TextWindow.WriteLine("MATRIX:")
For R=1 To 5
  I=(R-1)*5+1
  For C = 1 To 5
    TextWindow.CursorLeft = (C-1)*5
    TextWindow.Write(I + C - 1)
  EndFor
  TextWindow.WriteLine("")
EndFor
TextWindow.WriteLine("")
C=Math.GetRandomNumber(25)
LN390:
D=Math.GetRandomNumber(25)
LN400:
E=Math.GetRandomNumber(25)
LN410:
F=Math.GetRandomNumber(25)
If C=D Then
  Goto LN390
EndIf
If C=E Then
  Goto LN400
EndIf
If C=F Then
  Goto LN410
EndIf
If D=E Then
  Goto LN400
EndIf
If D=F Then
  Goto LN410
EndIf
If E=F Then
  Goto LN410
EndIf
TextWindow.WriteLine("ENTER YOUR FOUR POSITIONS")
G = TextWindow.ReadNumber()
H = TextWindow.ReadNumber()
K = TextWindow.ReadNumber()
L = TextWindow.ReadNumber()
TextWindow.WriteLine("")
LN500:
TextWindow.Write("WHERE DO YOU WISH TO FIRE YOUR MISSLE ")
Y = TextWindow.ReadNumber()
If Y=C Then
  Goto LN710
EndIf
If Y=D Then
  Goto LN710
EndIf
If Y=E Then
  Goto LN710
EndIf
If Y=F Then
  Goto LN710
EndIf
Goto LN630
LN570:
M=Math.GetRandomNumber(25)
Goto LN1160
LN580:
If X=G Then
  Goto LN920
EndIf
If X=H Then
  Goto LN920
EndIf
If X=L Then
  Goto LN920
EndIf
If X=K Then
  Goto LN920
EndIf
Goto LN670
LN630:
TextWindow.WriteLine("HA, HA YOU MISSED. MY TURN NOW ")
TextWindow.WriteLine("")
TextWindow.WriteLine("")
Goto LN570
LN670:
TextWindow.WriteLine("XXXX" + M)
TextWindow.WriteLine("I MISSED YOU, YOU DIRTY RAT. I PICKED " + M + ". YOUR TURN")
TextWindow.WriteLine("")
TextWindow.WriteLine("")
Goto LN500
LN710:
Q=Q+1
If Q=4 Then
  Goto LN890
EndIf
TextWindow.WriteLine("YOU GOT ONE OF MY OUTPOSTS!")
If Q=1 Then
  Goto LN770
EndIf
If Q=2 Then
  Goto LN810
EndIf
If Q=3 Then
  Goto LN850
EndIf
LN770:
TextWindow.WriteLine("ONE DOWN, THREE TO GO.")
TextWindow.WriteLine("")
TextWindow.WriteLine("")
Goto LN570
LN810:
TextWindow.WriteLine("TWO DOWN, TWO TO GO.")
TextWindow.WriteLine("")
TextWindow.WriteLine("")
Goto LN570
LN850:
TextWindow.WriteLine("THREE DOWN, ONE TO GO.")
TextWindow.WriteLine("")
TextWindow.WriteLine("")
Goto LN570
LN890:
TextWindow.WriteLine("YOU GOT ME, I'M GOING FAST. BUT I'LL GET YOU WHEN")
TextWindow.WriteLine("MY TRANSISTO&S RECUP%RA*E!")
Goto LN1235
LN920:
Z=Z+1
If Z=4 Then
  Goto LN1110
EndIf
TextWindow.WriteLine("I GOT YOU. IT WON'T BE LONG NOW. POST "+X+" WAS HIT.")
If Z=1 Then
  Goto LN990
EndIf
If Z=2 Then
  Goto LN1030
EndIf
If Z=3 Then
  Goto LN1070
EndIf

LN990:
TextWindow.WriteLine("YOU HAVE ONLY THREE OUTPOSTS LEFT.")
TextWindow.WriteLine("")
TextWindow.WriteLine("")
Goto LN500
LN1030:
TextWindow.WriteLine("YOU HAVE ONLY TWO OUTPOSTS LEFT.")
TextWindow.WriteLine("")
TextWindow.WriteLine("")
Goto LN500
LN1070:
TextWindow.WriteLine("YOU HAVE ONLY ONE OUTPOST LEFT.")
TextWindow.WriteLine("")
TextWindow.WriteLine("")
Goto LN500
LN1110:
TextWindow.WriteLine("YOU'RE DEAD. YOUR LAST OUTPOST WAS AT "+X+". HA, HA, HA.")
TextWindow.WriteLine("BETTER LUCK NEXT TIME.")
Goto LN1235
LN1160:
P=P+1
N=P-1
For T=1 To N
If M=MArray[T] Then
  Goto LN570
EndIf
EndFor
X=M
MArray[P]=M
Goto LN580
LN1235:

Sample Run:

Bombardment

© Copyright 2010 By BibleByte Books. All Rights Reserved. BibleByte Books, the BibleByte Books Logo, Computer Science For Kids, the Computer Science For Kids logo, and related trade dress are trademarks or registered trademarks of BibleByte Books.