home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / misc / amoner02.dms / amoner02.adf / Explode.AMOS / Explode.amosSourceCode < prev    next >
Encoding:
AMOS Source Code  |  1991-11-13  |  5.3 KB  |  236 lines

  1. ' Explode  
  2. ' By Gal-on Broner 
  3. ' Barbarian Minds 1991.
  4. '
  5.   Screen Open 0,320,200,8,Lowres
  6.   Curs Off 
  7.   Dim BOARD(5,5) : Rem number of bombs in each square.
  8.   Dim BOARD$(5,5) : Rem does the square belong to the white  
  9.                     Rem or to the black? 
  10.   Dim OVERBOMB(5,5) : Rem What is the maximum number if bombs
  11.                       Rem aloud in the square? 
  12.   Global BOARD(),BOARD$(),OVERBOMB(),X,Y,PL
  13.   Screen Hide : Wait Vbl 
  14.   CREATE_ICON_BANK
  15. INIT_GAME:
  16.   CREATE_OVERBOMB_TABLE
  17.   Cls 0
  18.   CREATE_BOARD
  19.   Screen Show : Wait Vbl 
  20.   X=1 : Y=1 : PL=2
  21. Rem
  22. Rem now for the main game routine. 
  23. Rem
  24. MAIN_GAME:
  25.   PL=3-PL
  26.   CURSOR_ON
  27. 6 LETTER$="" : LETTER$=Inkey$
  28.   If(Asc(LETTER$)<28 or Asc(LETTER$)>31) and(Asc(LETTER$)<>13) Then Goto 6
  29.   LE=Asc(LETTER$)
  30.   CURSOR_OFF
  31.   If LE=28 Then Add X,1,1 To 5 : Rem Right Arrow. 
  32.   If LE=29 Then Add X,-1,1 To 5 : Rem Left Arrow.
  33.   If LE=30 Then Add Y,-1,1 To 5 : Rem Up Arrow.
  34.   If LE=31 Then Add Y,1,1 To 5 : Rem Down Arrow.
  35.   If LE=13 Then Goto PLACE_BOMB : Rem put bomb on the spot.
  36.   CURSOR_ON
  37.   Goto 6
  38. Rem
  39. Rem Placing the bomb.
  40. Rem
  41. PLACE_BOMB:
  42. Rem  
  43. Rem Illigal. Tring to put a bomb in an enemy square. 
  44. Rem
  45.   If(PL=1 and(BOARD$(X,Y)="b")) or(PL=2 and(BOARD$(X,Y)="w"))
  46.     CURSOR_ON
  47.     Goto 6
  48.   End If 
  49. Rem  
  50. Rem Move ok. Increase amount of bombs in sqaure. 
  51. Rem
  52.   Inc BOARD(X,Y)
  53.   If PL=1
  54.     BOARD$(X,Y)="w"
  55.     PLACE_WHITE_BOMB
  56.   Else 
  57.     BOARD$(X,Y)="b"
  58.     PLACE_BLACK_BOMB
  59.   End If 
  60. Rem  
  61. Rem If amount of bombs reaches the max amount of bombs aloud 
  62. Rem Blow the square up!
  63. Rem
  64.   If BOARD(X,Y)=OVERBOMB(X,Y)
  65.     KEEPY=Y
  66.     KEEPX=X
  67.     Goto BLOWUP
  68.   End If 
  69.   Goto MAIN_GAME
  70. Rem  
  71. Rem Blow up! 
  72. Rem
  73. BLOWUP:
  74.   If PL=1 Then C$="w" Else C$="b"
  75.   X1=((X-1)*34)+2 : Y1=((Y-1)*34)+2
  76. Rem  
  77. Rem create the Blow up effect. 
  78. Rem  
  79.   Ink 4 : Boom 
  80.   For CIR=1 To 15
  81.     Circle X1+16,Y1+16,CIR
  82.   Next CIR
  83.   Ink 0
  84.   For CIR=1 To 15
  85.     Circle X1+16,Y1+16,CIR
  86.   Next CIR
  87.   CREATE_BOARD
  88.   Ink 0
  89.   Bar X1,Y1 To X1+30,Y1+30
  90. Rem  
  91. Rem Increase Bombs capacity inside sqaures beside
  92. Rem the sqaure who blowed up.
  93. Rem
  94.   BOARD(X,Y)=0 : BOARD$(X,Y)=""
  95.   If Y>1
  96.     Inc BOARD(X,Y-1)
  97.     BOARD$(X,Y-1)=C$
  98.   End If 
  99.   If Y<5
  100.     Inc BOARD(X,Y+1)
  101.     BOARD$(X,Y+1)=C$
  102.   End If 
  103.   If X>1
  104.     Inc BOARD(X-1,Y)
  105.     BOARD$(X-1,Y)=C$
  106.   End If 
  107.   If X<5
  108.     Inc BOARD(X+1,Y)
  109.     BOARD$(X+1,Y)=C$
  110.   End If 
  111. Rem  
  112. Rem Ok, Now go thourgh the whole board and redraw bombs position.
  113. Rem
  114.   For Y=1 To 5
  115.     For X=1 To 5
  116.       If BOARD(X,Y)>OVERBOMB(X,Y) Then BOARD(X,Y)=OVERBOMB(X,Y)
  117.       If BOARD$(X,Y)="w" Then PLACE_WHITE_BOMB
  118.       If BOARD$(X,Y)="b" Then PLACE_BLACK_BOMB
  119.     Next X
  120.   Next Y
  121. Rem  
  122. Rem Since a Blow has accured, I need to check for win! 
  123. Rem
  124.   ALIVE$="n"
  125.   For X=1 To 5
  126.     For Y=1 To 5
  127.       If PL=1 and(BOARD$(X,Y)="b") Then ALIVE$="y"
  128.       If PL=2 and(BOARD$(X,Y)="w") Then ALIVE$="y"
  129.     Next Y
  130.   Next X
  131.   If ALIVE$="n" Then Goto FINITO
  132. Rem
  133. Rem Ok, if the game is still going, check for a chain-reaction.
  134. Rem
  135.   For Y=1 To 5
  136.     For X=1 To 5
  137.       If BOARD(X,Y)=OVERBOMB(X,Y) Then Goto BLOWUP
  138.     Next X
  139.   Next Y
  140.   Y=KEEPY
  141.   X=KEEPX
  142.   Goto MAIN_GAME
  143. FINITO:
  144.   Locate 23,8
  145.   If PL=1
  146.     Print "Brown";
  147.   Else 
  148.     Print "White";
  149.   End If 
  150.   Print " Wins!"
  151.   Locate 23,10 : Print "Another Game?"
  152.   Locate 23,11 : Print "    (Y/N)    "
  153. 1
  154.   YN$=""
  155.     While YN$=""
  156.       YN$=Inkey$
  157.     Wend 
  158.   YN$=Upper$(YN$)
  159.   If YN$="Y" Then Goto INIT_GAME
  160.   Run "Amoner002:Autoexec.Amos"
  161. End 
  162. Procedure CREATE_ICON_BANK
  163.   Cls 0
  164.   Ink 1 : Circle 10,10,3 : Paint 10,10
  165.   Ink 2 : Circle 30,10,3 : Paint 30,10
  166.   Ink 4
  167.   Plot 10,6 : Plot 10,5 : Plot 11,4
  168.   Plot 30,6 : Plot 30,5 : Plot 31,4
  169.   Erase 2
  170.   Get Icon 1,6,4 To 14,14
  171.   Get Icon 2,26,4 To 34,14
  172.   Make Icon Mask 
  173. End Proc
  174. Procedure CREATE_OVERBOMB_TABLE
  175.   For X=1 To 5
  176.     For Y=1 To 5
  177.       If(X=1 or Y=1 or X=5 or Y=5) and(X=Y or X-4=Y or X+4=Y)
  178.         OVERBOMB(X,Y)=2
  179.         Goto 5
  180.       End If 
  181.       If Y=1 or X=1 or Y=5 or X=5
  182.         OVERBOMB(X,Y)=3
  183.         Goto 5
  184.       End If 
  185.       OVERBOMB(X,Y)=4
  186.     5 BOARD$(X,Y)="" : BOARD(X,Y)=0
  187.     Next Y
  188.   Next X
  189. End Proc
  190. Procedure CREATE_BOARD
  191.   Ink 6
  192.   For LOO=0 To 170 Step 34
  193.     Draw LOO,0 To LOO,170
  194.     Draw 0,LOO To 170,LOO
  195.   Next LOO
  196.   For LOO=1 To 171 Step 34
  197.     Draw LOO,1 To LOO,171
  198.     Draw 1,LOO To 171,LOO
  199.   Next LOO
  200.   Pen 4 : Paper 0
  201.   Locate 23,1 : Print "   Explode!    "
  202.   Locate 23,2 : Print "By Galon Broner"
  203.   Locate 23,3 : Print "Barbarian Minds"
  204.   Locate 23,4 : Print "     1991      "
  205.   Paper 0 : Pen 5
  206. End Proc
  207. Procedure CURSOR_ON
  208.   Ink PL
  209.   X1=((X-1)*34)+2 : Y1=((Y-1)*34)+2
  210.   Box X1+14,Y1+2 To X1+17,Y1+14
  211.   Box X1+2,Y1+14 To X1+14,Y1+17
  212.   Box X1+14,Y1+17 To X1+17,Y1+29
  213.   Box X1+17,Y1+14 To X1+29,Y1+17
  214. End Proc
  215. Procedure CURSOR_OFF
  216.   Ink 0
  217.   X1=((X-1)*34)+2 : Y1=((Y-1)*34)+2
  218.   Box X1+14,Y1+2 To X1+17,Y1+14
  219.   Box X1+2,Y1+14 To X1+14,Y1+17
  220.   Box X1+14,Y1+17 To X1+17,Y1+29
  221.   Box X1+17,Y1+14 To X1+29,Y1+17
  222. End Proc
  223. Procedure PLACE_WHITE_BOMB
  224.   X1=((X-1)*34)+2 : Y1=((Y-1)*34)+2
  225.   If BOARD(X,Y)>0 Then Paste Icon X1+2,Y1+2,1
  226.   If BOARD(X,Y)>1 Then Paste Icon X1+21,Y1+2,1
  227.   If BOARD(X,Y)>2 Then Paste Icon X1+2,Y1+21,1
  228.   If BOARD(X,Y)>3 Then Paste Icon X1+21,Y1+21,1
  229. End Proc
  230. Procedure PLACE_BLACK_BOMB
  231.   X1=((X-1)*34)+2 : Y1=((Y-1)*34)+2
  232.   If BOARD(X,Y)>0 Then Paste Icon X1+2,Y1+2,2
  233.   If BOARD(X,Y)>1 Then Paste Icon X1+21,Y1+2,2
  234.   If BOARD(X,Y)>2 Then Paste Icon X1+2,Y1+21,2
  235.   If BOARD(X,Y)>3 Then Paste Icon X1+21,Y1+21,2
  236. End Proc