here is something for everyone to use if you want directional compass
type directions between to objects, such as ships; used between firing ship
and targeted ship in the game...
The values of the compass are 1 is directly to the right or east. 3 is
directly up, 5 is directly left or West. then 7 is down and 2, 4, 6, and 8
are the diagonals. The rotation is counter clockwise for an increasing
number.
VBS and Python
In Python you just use a return statement to get a function which the 2
below are. No return and it is just a procedure and only objects passed in,
or the use of global statement, will external variables be changed.
Format: global globalName1, globalName2...
Now in python it is a tab or indent language, all programs and loop
statements must stay in the same column or an error will happen.
Below 2 functions the first one converts a float number between 1.0 and
8.9999 back to an angle that is used in a sin or cos, or sine and cosine or
tangent math built in function...going in all 360 degrees or 2pi radians.
In python the math constant for pi is py
Now in the Battleship game I use a dictionary to store the row and column,
so I use the letters r and c for keys and that is why getting the y and x
values below you see the letters used for keys.
Now you could write this in vb and just use the vb equivalent for the
math functions below...
The dictionary would be the same by just using the dictionary declare
statement...
Now the use of the # character it is a comment statement just like the '
is in vbs.
After the function name line the use of "statement" or """statement"""
allows you to give comments to each function you have which can be exposed
as a document outside of the program when that function is exposed...
The use of """ allows multiple lines without having to use the # sign
for each line.
Python Code:
def Dir2Angle( Dir):
"CONVERT DIRECTION BACK TO TANGENT ANGLE IN RADIANS!"
return (float(Dir-1.0) *(pi/4.0))
def Dir4SS( S1, S2):
"PASS IN 2 SHIPS AND FIND DIRECTION 1 TO 8.999 FROM SHIP 1 TO 2"
Dy = float( S1["r"] - S2["r"]) #*9 +float( S1["r"] - S2["r"])
Dx = float( S1["c"] - S2["c"]) #*9 +float( S1["c"] - S2["c"])
if Dy==0.0: Dy=.0000001
if Dy<0: return atan( Dx/Dy)/ (pi/4.0) +7.0
else: return atan( Dx/Dy)/ (pi/4.0) +3.0
Sent: Friday, January 04, 2013 12:48 AM
Subject: Re: Fixed error: New Battleship Game Now Here!
Hi!
Thanks, now I have to fix my Trek game...
Bruce
Sent: Friday, January 04, 2013 12:01 AM
Subject: RE: Fixed error: New Battleship Game Now Here!
Hi Bruce,
Really great worek for the advanced and well working game! Thanks for
sharing.
-----Original Message-----
From: BX [mailto:[email protected]]
Sent: Thursday, January 03, 2013 9:17 PM
To: [email protected]
Subject: Fixed error: New Battleship Game Now Here!
Hi!
You can download it now and there should be no errors now.
https://www.gwmicro.com/App_Central/Apps/App_Details/?scriptid=1372
Sent: Thursday, January 03, 2013 9:01 PM
Subject: Re: New Battleship Game Now here!
Hey Bruce,
I tried installing, and got a "file not found error," on line 42.
What's up with that?
Cheers,
Rod :)
-----Original Message-----
From: BX
Sent: Thursday, January 03, 2013 8:54 PM
To:
[email protected]
Subject: Re: New Battleship Game Now here!
Hi!
OK, go to app central and you will find it, or click here:
https://www.gwmicro.com/App_Central/Apps/App_Details/?scriptid=1372
Sent: Thursday, January 03, 2013 8:40 PM
Subject: Re: New Battleship Game Now here!
where's the download link?
Legend has it that on Thursday 1/3/2013 06:08 PM, BX said:
----------------------------------------
> Hi!
>
> The new Battleship game is ready for you to play.
>I added the Windoweyes voices and the ability to adjust speaker
>positions so you don't have to move the speakers.
>All voice adjustments are done using the Delete, End, Page Up and Page
>Down keys.
> Holding the shift key down while using those keys lowers the
>setting value.
> Holding down the CTRL key adjusts the opponents voice settings.
>F2, F3, and F4 keys adjust player and speaker positions respectively.
>Home key adjusts the background sound volume and the F9 switches sound
>playing and the F10 key turns it on or off; it toggles.
> The F5, F6, and F7 keys gives the score of the player, computer,
>and player 2 respectively.
>The space bar tells you what cell you are on and if you have hit a ship
>there.
>The arrow keys navigate you around the ocean and hitting the
>alpha/numeric keys moves you faster in the horizontal or vertical position.
>
> Enjoy the game for using level 5 will be hard to beat the computer.
>
> Sincerely
> Bruce A. Babcock
----------------------------------------
<
http://www.sendspace.com/folder/i7xwg4>Click
here to check out my
sendspace offerings!