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:
Sat, Jan 5, 2013 9:23:49 amHi Rod,
I had sent that for you if you wanted to experiment with it. As I had
said, there are the same VBS forms of the same math functions, in fact not
much different the the Python ones. Also, in VBS you do not have to worry
about tabbing, spacing, just have to insert an end statement instead; which
is the difference from Python because Python relies on the indent level to
indicate the end of a given loop, procedure or function(which has a return
statement).
I did not add the use of the 10 key pad for the game which I will add in
the next revision for it, along with adding the fact if you want to move the
game also include the BattleShipSapi5Class.vbs file as well; since that is
the file that caused the original error when you tried to install it. That
file could have been placed inside the game .vbs dialog box file but decided
to have that portable for anyone to use it if they wanted to know the SAPI
calls and added features I placed in it.
Inside the BattleShip.vbs I added the format for an import statement
that is used in Python. Since VBS does not have that feature I added that as
well so you can import other files such the SAPI5 class I made. This can
reduce the number of code lines inside your program along with making that
class and it's properties portable to any app you may write.
So, try and keep your had facing forward, for you might get it stuck in
reverse and that might be a problem...:)
Bruce
Sent: Friday, January 04, 2013 4:06 AM
Subject: Re: New Battleship Game Now here!
Hi again Bruce,
Wow, this certainly makes my head do The Exorcist move ... spinning around,
I mean, smile. I wish I had the time to delve into your code, even though I
was crazy about trig and calculus back in high school, smile.
I do appreciate your desire to share your programming prowess with us,
Bruce, and it certainly shows the power of the Python language.
At present, I'm still learning the power of the dictionary object in
scripting, although I'm still inclined to use a two-deminsional array when I
need to. It's funny, for example, how, when you find a cool new scripting
toool, you tend to want to use it all the time, while forgetting some of
those old tools which work just fine, and maybe work better than the new
ones. A dictionary object is good for a situation when you know the key you
want to access, but how about the situation when you have to search all the
items in the dictionary to find the one you want? In this case, you might
just as wel search all the second elements of a two-dimensional array. This
is my most recent insight in my programming endeavours.
Anyway, Bruce, thanks for all your work in Battleship and Trek.
Best of everything,
Rod :)
-----Original Message-----
From: BX
Sent: Thursday, January 03, 2013 11:03 PM
To: gw-apps@gwmicro.com
Subject: Re: New Battleship Game Now here!
Hi Again Rod,
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...
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: 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!
>
>
I had sent that for you if you wanted to experiment with it. As I had
said, there are the same VBS forms of the same math functions, in fact not
much different the the Python ones. Also, in VBS you do not have to worry
about tabbing, spacing, just have to insert an end statement instead; which
is the difference from Python because Python relies on the indent level to
indicate the end of a given loop, procedure or function(which has a return
statement).
I did not add the use of the 10 key pad for the game which I will add in
the next revision for it, along with adding the fact if you want to move the
game also include the BattleShipSapi5Class.vbs file as well; since that is
the file that caused the original error when you tried to install it. That
file could have been placed inside the game .vbs dialog box file but decided
to have that portable for anyone to use it if they wanted to know the SAPI
calls and added features I placed in it.
Inside the BattleShip.vbs I added the format for an import statement
that is used in Python. Since VBS does not have that feature I added that as
well so you can import other files such the SAPI5 class I made. This can
reduce the number of code lines inside your program along with making that
class and it's properties portable to any app you may write.
So, try and keep your had facing forward, for you might get it stuck in
reverse and that might be a problem...:)
Bruce
Sent: Friday, January 04, 2013 4:06 AM
Subject: Re: New Battleship Game Now here!
Hi again Bruce,
Wow, this certainly makes my head do The Exorcist move ... spinning around,
I mean, smile. I wish I had the time to delve into your code, even though I
was crazy about trig and calculus back in high school, smile.
I do appreciate your desire to share your programming prowess with us,
Bruce, and it certainly shows the power of the Python language.
At present, I'm still learning the power of the dictionary object in
scripting, although I'm still inclined to use a two-deminsional array when I
need to. It's funny, for example, how, when you find a cool new scripting
toool, you tend to want to use it all the time, while forgetting some of
those old tools which work just fine, and maybe work better than the new
ones. A dictionary object is good for a situation when you know the key you
want to access, but how about the situation when you have to search all the
items in the dictionary to find the one you want? In this case, you might
just as wel search all the second elements of a two-dimensional array. This
is my most recent insight in my programming endeavours.
Anyway, Bruce, thanks for all your work in Battleship and Trek.
Best of everything,
Rod :)
-----Original Message-----
From: BX
Sent: Thursday, January 03, 2013 11:03 PM
To: gw-apps@gwmicro.com
Subject: Re: New Battleship Game Now here!
Hi Again Rod,
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...
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: 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!
>
>




