CANNON

   After the title screen, choose one or two players.  You should now see
   two forts, hilly ground, and "POWER 40   ANGLE 30" on the left.  You use
   the up/down arrow keys to adjust the power, and the left/right arrow keys
   to adjust the angle.  When you have these set how you like, press ENTER.
   The path  of the cannon ball is drawn, if it hit the other fort you win,
   else it it the other forts turn.  If playing two player, pass the calc to
   your friend and repeat till someone wins.  If playing one player, after
   your turn, the calc will take it's turn.  Either  player can press CLEAR
   to redraw the screen without all the cannon ball paths.
	
	Cannon balls will no longer go through the hills.  I have not yet
	rebuilt the calc's thinking to handle this.

   ===
    Copyright 1995, Micheal Conrad Tilstra, Tadpol.
    All rights reserved.
    
    Redistribution and use in source and binary forms, with or without
    modification, are permitted provided that the following conditions
    are met:
    
    1. Redistributions of source code must retain the above copyright
       notice, this list of conditions, and the following disclaimer.
    
    2. Redistributions in binary form must reproduce the above copyright
       notice, this list of conditions, and the following disclaimer in the
       documentation and/or other materials provided with the distribution.
    
    3. The name of the author may not be used to endorse or promote products
       derived from this software without specific prior written permission.
    
    THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
    OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
    DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
    AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
    TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.    
   ===


\START82\
\COMMENT=Cannon 1.6.1 By Mike Tilstra
\NAME=CANNON
\FILE=CANNON.82p
ClrHome
ClrDraw:FnOff 
PlotsOff :Func
AxesOff:Degree
Text(10,30,"CANNON"
Text(20,38,"1.6.1"
Text(30,42,"BY"
Text(40,27,"MIKE TILSTRA"
Pause 
getKey
"10sin (H2X)"\->\\Y9\
"\(-)\A\^-1\(X-B)\^2\+C"\->\\Y0\
FnOff 
{2,3,4,2,3,4,1,2,3,4,5,1,3,5}\->\\L1\
{0,0,0,1,1,1,2,2,2,2,2,3,3,3}\->\\L2\
\L1\\->\\L3\
\L2\\->\\L4\
0\->\Xmin:1\->\\Delta-x\
0\->\Ymin:1\->\\Delta-y\
0\->\Xscl:0\->\Yscl
40\->\A:30\->\D
40\->\E:30\->\F
0\->\M:0\->\M
5\->\V
int 6rand+1\->\H
int 40rand+50\->\R
int 40rand+2\->\L
Menu("CANNON","1-PLAYER",A,"2-PLAYER",B)
Lbl A
1\->\P:0\->\Q
Goto D
Lbl B
1\->\P:1\->\Q

Lbl D
\L1\+(L-3)\->\\L1\
\L3\+(R-3)\->\\L3\
L\->\X
round(\Y9\,0\->\U
If U\<=\0
0\->\U
\L2\+(U+1)\->\\L2\
R\->\X
round(\Y9\,0\->\T
If T\<=\0
0\->\T
\L4\+(T+1)\->\\L4\
Plot1(Scatter,\L1\,\L2\,\dot icon\)
Plot2(Scatter,\L3\,\L4\,\dot icon\)
getKey
ClrDraw
Shade(0,\Y9\
Lbl 1
DispGraph
A\->\W:D\->\\@\:1\->\X
0\->\M
If P=1
prgmZPOWANG
W\->\A:\@\\->\D

int (Wtan D)\->\B
int (Btan D)+U\->\C
B+L\->\B

L\->\I:Ymin\->\J
For(X,(L+3),Xmax,\Delta-x\
If int \Y0\=int \Y9\
Xmax\->\X
int \Y0\\->\Y
Line(X,Y,I,J
X\->\I:Y\->\J
End

For(Z,1,dim \L3\
\L3\(Z\->\X
round(\Y0\,0\->\Y
If Y=\L4\(Z
Then
Text(15,60,"RIGHT DIES"
Goto 2
End
End
E\->\W:F\->\\@\:60\->\X
0\->\N
If Q=1
prgmZPOWANG
If Q=0
prgmZCALCANG
W\->\E:\@\\->\F

int (Etan F)\->\B
int (Btan F)+T\->\C
(R-2B)+B\->\B
R\->\I:Ymin\->\J
For(X,R,Xmin,-\Delta-x\
If int \Y0\=int \Y9\
Xmin\->\X
int \Y0\\->\Y
Line(X,Y,I,J
X\->\I:Y\->\J
End
For(Z,1,dim \L1\
\L1\(Z\->\X
round(\Y0\,0\->\Y
If Y=\L2\(Z
Then
Text(15,1,"LEFT DIES"
Goto 2
End
End
Goto 1
Lbl 2
Pause 
PlotsOff 
ClrList \L1\,\L2\,\L3\,\L4\
""\->\\Y0\:""\->\\Y9\
ClrHome
Stop
MIKE TILSTRA
\STOP82\


\START82\
\COMMENT=ZCALCANG for Cannon (calc's thinking)
\NAME=ZCALCANG
\FILE=ZCALCANG.82p
getKey
int (Etan F)\->\B
int (Btan F)\->\C
(R-2B)+B\->\B
int solve(\Y0\,X,O)\->\O
int ((L-O)/3)\->\S
abs S\->\S
If O<L
\(-)\S\->\S
(int Srand+1)+W\->\W
(int (int (S/2))rand+1)+\@\\->\\@\
Return
Stop
MIKE TILSTRA
\STOP82\


\START82\
\COMMENT=ZPOWANG for Cannon (human response)
\NAME=ZPOWANG
\FILE=ZPOWANG.82p
1\->\G
While G=1
getKey\->\K
If K=25
W+1\->\W
If K=34
W-1\->\W
If K=24
\@\-1\->\\@\
If K=26
\@\+1\->\\@\
If K=45
Then
ClrDraw
Shade(0,\Y9\

End
If W<15
15\->\W
If W>99
99\->\W
If \@\<20
20\->\\@\
If \@\>89
89\->\\@\
Text(1,X,"POWER ",W
Text(8,X,"ANGLE ",\@\
If K=105
0\->\G
End
Return
\STOP82\
