The GW-Apps is geared toward discussions of Window-Eyes and GW Micro apps. Any subscriber of the GW-Apps list has the ability to post on-topic messages.
From:
"BX" <bronx_lab@fltg.net>Subject:
Re: New Battleship Game Now here!Date:
Fri, Jan 4, 2013 10:45:26 amHi Rod,
Actually none of this is used in the battleship game but was attempting
to use it for volume control on the board, but only needed the x or
horizontal value to adjust speakers since we are only going left to right.
In Python a dictionary is setup using only {} braces for each level
inside the dictionary.
Example of player dictionary used and is a 2 dimensional key dictionary:
PlayerDict = {1: {"p": "l", "c":0, "r":10}, 2: {"p":"r", "c":10, "r":0}}
Above has 2 players just numbered 1 and 2 and each players has 3 codes for
positioning where p="l" or p="r" indicating left or right speaker; making it
easier to figure out location and changing it.
The call would be:
x1 = PL[1][ "c"]
y1 = PL[1][ "r"]
Then each player has a column or row position, or in example below it is the
x or y value to be used for directional movement calculations.
The reason for this is as you move from right to left the column value
changes and x is always the horizontal axis; which is the cosine value of a
triangle whose angle vertex is at the center horizontal axis.
Then the y value is what goes up or down from the angle vertex, thus used
below as shown.
Thus when moving right x increases above 0 and moving up y increases above 0
and so on.
Now, this code in Python will get upset because the order of declare is
important because you must first declare the calculating functions before
using them. I reversed the order to show you how the 2 functions are used
before looking at them.
Python code for plotting a ship traveling towards another:
def Plot( PL,SS, distance):
"Plot DIRECTION OF TRAVEL! Where PL=Player ship and SS=Ship targeted."
dx = float(PL[ "c"] - SS[ "c"])
dy = float(PL[ "r"] - SS[ "r"])
distance = hypot( dy, dx)# distance / 10
#Note above I use a hypotenuse instead of the passed in value.
#Also note that the passed in distance has an initial value by giving it
one in the declare statement.
#Calculate an increment value:
I = distance / 14 #Increment value using field length or width, or max
diagonal.
Dir = Dir4SS( PL, SS) #Calculate actual direction between 2 ships,
values from 1 to 8.999 returned.
Angle = Dir2Angle( Dir) #Calculate actual angle between ships in
radians.
#Note: Above I calculate that 1 to 8.999 value and that comes in handy
for only easy understanding of a direction instead of using actual degrees
and is assigned to variable dir.
#Assign variables for angle radians for movement.
Sin = sin(Angle) #opposite over hypotenuse, DY VECTOR!
Cos = cos(Angle) #ADJACENT OVER HYPOTENUSE, DX VECTOR!
#Initial starting point of vector from player ship at first value(I)
increment.
sx = round( PL["c"] +Cos * I)
sy = round( PL["r"] -Sin * I)
z = 0
#Now plot position as you travel up tangent line.
while z <= distance:
z += I
sx = round( SS["c"] +Cos * z)
sy = round( SS["r"] -Sin * z)
So the above keeps on plotting the points until maximum distance is reached,
which is the other ship after calculating the hypotenuse of the triangle
drawn between each ship.
Other 2 functions used:
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: Thursday, January 03, 2013 10:41 PM
Subject: Re: New Battleship Game Now here!
Hi Rod,
Good, I knew something was missing but was in such a hurry to get it
posted and did not pay attention to the package file and updating it to the
changes I had made...
Python has lots of packages for lots of things because it is a free
source scripting language where you have people all over the world
contributing...
So, all sounds are done using a mixer and each object is stored in a
dictionary. Granted you can do that in VBS but like I said, there more
modules and such to be able to import and use.
The only problem with Python is the display and such, as if we need to
worry about it.
I am going to modify it more later to do a display for sighted people,
which means using a different keyboard event monitoring. Experimenting with
other events and import only those PyGame modules needed for sound; where
all the mixer stuff comes from, since it was designed to be a game module
for Python...
I will also change my Trek game in the future to also do the same kind
of adjusting and such.
Enjoy, Bruce
Sent: Thursday, January 03, 2013 10:28 PM
Subject: Re: New Battleship Game Now here!
Hey Bruce,
That's quite okay. Works great now, and I like the options you've added,
especially being able to configure the background sounds, as well as it's
great that the original voice settings are restored on game exit. Good job,
my friend. :)
By the way, is Python better than VBScript, at least in your opinion? If
so, why? I would just like to get some feedback on the limitations of
VBScript, as compared to other languages.
Cheers,
Rod :)
-----Original Message-----
From: BX
Sent: Thursday, January 03, 2013 9:53 PM
To: gw-apps@gwmicro.com
Subject: Re: New Battleship Game Now here!
Hi!
Sorry about that, that is what I get for ding it in a hurry. There
should be 72 files in the package, missing the most important class file for
SAPI voice.
That is fixed now, just wait a few minutes and I will upload the new
package file.
Bruce
Sent: Thursday, January 03, 2013 9:17 PM
Subject: Re: New Battleship Game Now here!
Hi
Similar thing happens here. I installed the app, it runs and I get an
app error and Iget the usual buttons save error, ignore error... and
when i press any of those buttons the app closes. when i try to restart
it, the same thing happens. I'm certain it was just a minor mistake,
that sort of thing happens.
On 1/3/2013 9:01 PM, Rod Hutton wrote:
> 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: gw-apps@gwmicro.com
> 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/?scriptid72
>
> 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!
>
>
Actually none of this is used in the battleship game but was attempting
to use it for volume control on the board, but only needed the x or
horizontal value to adjust speakers since we are only going left to right.
In Python a dictionary is setup using only {} braces for each level
inside the dictionary.
Example of player dictionary used and is a 2 dimensional key dictionary:
PlayerDict = {1: {"p": "l", "c":0, "r":10}, 2: {"p":"r", "c":10, "r":0}}
Above has 2 players just numbered 1 and 2 and each players has 3 codes for
positioning where p="l" or p="r" indicating left or right speaker; making it
easier to figure out location and changing it.
The call would be:
x1 = PL[1][ "c"]
y1 = PL[1][ "r"]
Then each player has a column or row position, or in example below it is the
x or y value to be used for directional movement calculations.
The reason for this is as you move from right to left the column value
changes and x is always the horizontal axis; which is the cosine value of a
triangle whose angle vertex is at the center horizontal axis.
Then the y value is what goes up or down from the angle vertex, thus used
below as shown.
Thus when moving right x increases above 0 and moving up y increases above 0
and so on.
Now, this code in Python will get upset because the order of declare is
important because you must first declare the calculating functions before
using them. I reversed the order to show you how the 2 functions are used
before looking at them.
Python code for plotting a ship traveling towards another:
def Plot( PL,SS, distance):
"Plot DIRECTION OF TRAVEL! Where PL=Player ship and SS=Ship targeted."
dx = float(PL[ "c"] - SS[ "c"])
dy = float(PL[ "r"] - SS[ "r"])
distance = hypot( dy, dx)# distance / 10
#Note above I use a hypotenuse instead of the passed in value.
#Also note that the passed in distance has an initial value by giving it
one in the declare statement.
#Calculate an increment value:
I = distance / 14 #Increment value using field length or width, or max
diagonal.
Dir = Dir4SS( PL, SS) #Calculate actual direction between 2 ships,
values from 1 to 8.999 returned.
Angle = Dir2Angle( Dir) #Calculate actual angle between ships in
radians.
#Note: Above I calculate that 1 to 8.999 value and that comes in handy
for only easy understanding of a direction instead of using actual degrees
and is assigned to variable dir.
#Assign variables for angle radians for movement.
Sin = sin(Angle) #opposite over hypotenuse, DY VECTOR!
Cos = cos(Angle) #ADJACENT OVER HYPOTENUSE, DX VECTOR!
#Initial starting point of vector from player ship at first value(I)
increment.
sx = round( PL["c"] +Cos * I)
sy = round( PL["r"] -Sin * I)
z = 0
#Now plot position as you travel up tangent line.
while z <= distance:
z += I
sx = round( SS["c"] +Cos * z)
sy = round( SS["r"] -Sin * z)
So the above keeps on plotting the points until maximum distance is reached,
which is the other ship after calculating the hypotenuse of the triangle
drawn between each ship.
Other 2 functions used:
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: Thursday, January 03, 2013 10:41 PM
Subject: Re: New Battleship Game Now here!
Hi Rod,
Good, I knew something was missing but was in such a hurry to get it
posted and did not pay attention to the package file and updating it to the
changes I had made...
Python has lots of packages for lots of things because it is a free
source scripting language where you have people all over the world
contributing...
So, all sounds are done using a mixer and each object is stored in a
dictionary. Granted you can do that in VBS but like I said, there more
modules and such to be able to import and use.
The only problem with Python is the display and such, as if we need to
worry about it.
I am going to modify it more later to do a display for sighted people,
which means using a different keyboard event monitoring. Experimenting with
other events and import only those PyGame modules needed for sound; where
all the mixer stuff comes from, since it was designed to be a game module
for Python...
I will also change my Trek game in the future to also do the same kind
of adjusting and such.
Enjoy, Bruce
Sent: Thursday, January 03, 2013 10:28 PM
Subject: Re: New Battleship Game Now here!
Hey Bruce,
That's quite okay. Works great now, and I like the options you've added,
especially being able to configure the background sounds, as well as it's
great that the original voice settings are restored on game exit. Good job,
my friend. :)
By the way, is Python better than VBScript, at least in your opinion? If
so, why? I would just like to get some feedback on the limitations of
VBScript, as compared to other languages.
Cheers,
Rod :)
-----Original Message-----
From: BX
Sent: Thursday, January 03, 2013 9:53 PM
To: gw-apps@gwmicro.com
Subject: Re: New Battleship Game Now here!
Hi!
Sorry about that, that is what I get for ding it in a hurry. There
should be 72 files in the package, missing the most important class file for
SAPI voice.
That is fixed now, just wait a few minutes and I will upload the new
package file.
Bruce
Sent: Thursday, January 03, 2013 9:17 PM
Subject: Re: New Battleship Game Now here!
Hi
Similar thing happens here. I installed the app, it runs and I get an
app error and Iget the usual buttons save error, ignore error... and
when i press any of those buttons the app closes. when i try to restart
it, the same thing happens. I'm certain it was just a minor mistake,
that sort of thing happens.
On 1/3/2013 9:01 PM, Rod Hutton wrote:
> 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: gw-apps@gwmicro.com
> 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/?scriptid72
>
> 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!
>
>




