[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] vista testing...



Hi Lenard

    your not going to believe this after extensive testing, what was needed
was the import os.path for that file and only that file would not play
without the path.

    I am not joking about this, for I tested all the files inside the data
folder from the folder above and all would work but the Awes file. But when
placing that file in the same directory as the .py file it worked. So I
decided to insert the os.path.join() into the file name for the mixer and it
worked. It runs now without any problem.

    So, the question to ask is why only that file? No other file inside the
data folder had an error and I have all sizes and shapes being run in my
battleship program. All them on the list have the "data\name" filename
inside the .mixer assignment. But only the awes file would say mixer load
error of no src, for it could not find the file.

    Talk about weird situations. So your test below failed until I added the
os.path command. I inserted it into my battle.py game and it works now.
Later I will do the assignments inside a method.

    The game is attached with the awe file inside the boohoo name. I guess
you could use your own files for sound unless I send it zipped up.

        Bruce

Without calling pygame.mixer.pre_init the mixer defaults to a 22050
sample rate and a 3072 byte buffer. The following test program played
the attached wave file with problem.


import pygame

pygame.init()

sound = pygame.mixer.Sound("Awes.wav")
sound.play()

while pygame.mixer.get_busy():
    pass


Lenard


FT wrote:
> Hi!
>     I am not sure if this is related because I do not get any scratching
on
> my sounds when I only use pygame.init with no mixer init but the attached
> file, the only one of the bunch I have will not play at all. In fact it
says
> error, no src. Also it says it is a null file.
>     It is an 8 bit, 88K but I have many like this one but they play with
no
> problems or scratching. I use both 8 bit and 16 bit and one is played
> continuously, but this one dies once assigned with the null, no src error.
>
>     So, what is the difference in this file from all others when trying to
> play it with the mixer? You have to convert it back to a .wav file for the
> list rejected with the extension on it, so I sent it without it.
>
>     I am using pygame 1.8 rc 3 and SDL (1,2,12)
>
>         Bruce
>
>
> When you say "that didn't work at all", what exactly do you mean? What
> SDL prebuilts were you running with what pygame when you had a
> problem?
>
> In terms of not working - do you mean you get a python exception? seg
> fault? stuff seemed to work but no sound played?
>
> Also, while I haven't tried an older SDL with pygame 1.8. I've
> successfully used the newer SDL dll's with pygame 1.7.
>
> So if the problems you had were trying to run the SDL from 1.7 with
> pygame 1.8, then maybe you can try pygame 1.7.1 with the newer SDL
> dll's here:
> http://www3.telus.net/len_l/prebuilt-msvcr71.zip
> the result of that one test case will provide useful info on if this
> is an SDL bug or not.
>
>
> On Mon, Mar 24, 2008 at 4:05 PM, Bo Jangeborg <bo@xxxxxxxxxxx> wrote:
>
>> Did try that yesterday but that didn't work at all.
>>  I don't think the different versions of the mixer are
>>  compatible.
>>
>>  Brian Fisher skrev:
>>
>>
>>
>>> One other thing to try would be to swap out different SDL library
>>>
>>  > versions. Pygame 1.8 includes newer SDL library versions than 1.7
>>  > does, I think SDL mixer was updated as part of that.
>>  >
>>  > You should be able switch being using the dll's for 1.7 here:
>>  > http://pygame.org/ftp/win32-dependencies.zip
>>  >
>>  > and the dll's for 1.8 here:
>>  > http://www3.telus.net/len_l/prebuilt-msvcr71.zip
>>  >
>>  > just by copying the dll's over the ones in your site-packages/pygame
>>
> dir.
>
>>  >
>>  > so if you get scratchiness in both pygame 1.7 & 1.8 with the newer SDL
>>  > but not with the older SDL, it would seem to be a new SDL bug. if you

>>  > get scratchiness in pygame 1.8 with either SDL, but not in pygame 1.7
>>  > with either SDL, then it would seem to be something pygame introduced.
>>  >
>>  >
>>  > On Mon, Mar 24, 2008 at 2:20 PM, Bo Jangeborg <bo@xxxxxxxxxxx> wrote:
>>  >
>>  >> Just tried it, no differens I am afraid. One thing I noticed , and
>>
> that
>
>>  >>  was true for
>>  >>  the mingw version too, was that at 44k the music was running
>>  >>  considerally slower.
>>  >>  Not sure if that's any clue.
>>  >>  Is the interrrupt not frequent enough for it to pump out the music ?
>>
> Or
>
>>  >>  what do
>>  >>  think is happening here. Do you have any compiler options to play
>>
> around
>
>>  >>  with ?
>>  >>
>>  >>  René Dudfield skrev:
>>  >>
>>  >>
>>  >>
>>  >>> Are you able to try the pygame from here ?
>>  >>>
>>  >>  > http://thorbrian.com/pygame/builds.php
>>  >>  >
>>  >>  > I think this is compiled with visual C rather than mingw, so maybe
>>  >>  > it'll be different...
>>  >>  >
>>  >>  > cheers,
>>  >>  >
>>  >>  > On Mon, Mar 24, 2008 at 11:21 PM, Bo Jangeborg <bo@xxxxxxxxxxx>
>>
> wrote:
>
>>  >>  >
>>  >>  >> The scratching are with all music files I have tested. The music
>>
> have a
>
>>  >>  >>  native sample rate
>>  >>  >>  of 44k so there should be no need to resample, and it does work
>>
> when the
>
>>  >>  >>  output is changed
>>  >>  >>  to 22k. I have tested with 15 different pieces. Furthermore it
>>
> worked ok
>
>>  >>  >>  in pygame 1.7.
>>  >>  >>
>>  >>  >>  If I start a bit into the music I get occasional scratching for
>>
> the rest
>
>>  >>  >>  of the piece after that.
>>  >>  >>
>>  >>  >>  Brian Fisher skrev:
>>  >>  >>
>>  >>  >>
>>  >>  >>
>>  >>  >>> The change with sample rate makes me think it may actually have
>>
> to do
>
>>  >>  >>>
>>  >>  >>  > with the particular sound samples as well? I understand that
>>
> SDL is
>
>>  >>  >>  > somewhat limited on the sample rate conversions it supports -
>>
> got
>
>>  >>  >>  > particular sounds files that sound scratchy you can send to
>>
> test with?
>
>>  >>  >>  >
>>  >>  >>  > also, when you say you get scratches after starting some way
>>
> into the
>
>>  >>  >>  > music - do you mean you get like a pop when first playing the
>>
> music,
>
>>  >>  >>  > or do you mean that you get scratches throughout the music
>>
> after you
>
>>  >>  >>  > start it playing at a point in the sound?
>>  >>  >>  >
>>  >>  >>  >
>>  >>  >>  > On Sun, Mar 23, 2008 at 2:27 PM, Bo Jangeborg <bo@xxxxxxxxxxx>
>>
> wrote:
>
>>  >>  >>  >
>>  >>  >>  >> The buffer setting doesn't seem to make a differens.
>>  >>  >>  >>  The key seem to be the sampling rate. Lots of scratching at
>>
> 44k sound
>
>>  >>  >>  >>  but OK at 22k. But even then I get scratches if I start some
>>
> way into
>
>>  >>  >>  >>  the music
>>  >>  >>  >>  rather then at the start. The later problem I had in pygame
>>
> 1.7 too.
>
>>  >>  >>  >>
>>  >>  >>  >>  In pygame 1.7 music worked OK in Vista at 44k.
>>  >>  >>  >>  I have tried both ogg and mp3 in pygame 1.8.
>>  >>  >>  >>  Have you tried playing music at 44k on XP machines?  Maybe
>>
> this is a more
>
>>  >>  >>  >>  general problem.
>>  >>  >>  >>
>>  >>  >>  >>  Another thing that seem to have changed is that if a path to
>>
> a sound file
>
>>  >>  >>  >>  is wrong it doesn't cause an exception. Instead it returns
an
>>
> empty
>
>>  >>  >>  >>  sound object..
>>  >>  >>  >>  Is that really intended ?
>>  >>  >>  >>
>>  >>  >>  >>
>>  >>  >>  >
>>  >>  >>  >
>>  >>  >>
>>  >>  >>
>>  >>  >>
>>  >>  >
>>  >>  >
>>  >>
>>  >>
>>  >>
>>  >
>>  >
>>
>>
>>
>
>
> --
> No virus found in this incoming message.
> Checked by AVG.
> Version: 7.5.519 / Virus Database: 269.21.8/1340 - Release Date: 3/23/2008

> 6:50 PM
>


--
Lenard Lindstrom
<len-l@xxxxxxxxx>
#LAST MODIFIED MARCH 24, 2008.
#ADDED FIRE SEARCH OR SEEK TO CHECK AREA IF A HIT.
#MODIFIED MARCH 22, 2008.
#ADDED COMPUTER TOGGLE AND CONSOLIDATED MOVES FOR SWITCH OF PLAYER!
#MODIFIED MARCH 21, 2008.
#ADDED F KEYS FOR HELP, VOICES, AND 10 KEYPAD FOR COMPUTER MOVES!
#MODIFIED MARCH 19, 2008.
#ADDED SCORE CARD AND HELP MENU.
#MODIFIED MARCH 18, 2008.
#CHANGED FOR 2 PLAYERS.
#SETUP OF BATTLE GAME ON MARCH 8, 2008
#NEEDS TO CHANGE MAZE GAME OVER TO AN OCEAN AND RANDOM SHIP SETUP!
# Load Modules
import pygame
from pygame.locals import *
from pygame.event import Event
import random, sys, os
import time
import math
import pyTTS

tts = pyTTS.Create()
tts.Volume = 100
tts.Rate = 1

# go to the program directory if entered on command line!
mydir = os.path.dirname(sys.argv[0])
if mydir:
    os.chdir(mydir)

#constants:
HELP_MSG = """To play the game hit the enter key to fire shell at the other ship.
     To move around the battlefield use the arrow keys before firing with the enter key.
     Or enter a letter for column and number for row on battlefield.
     For score card use the 1 through 7 keys.
     Where 7 is for status for all ships fired at."""
AIRCRAFT = 5
BATTLESHIP = 4
DESTROYER = 4
CRUISER = 3
SUB = 2
PT_BOAT = 2
MISS = 99
SHIPS = 6
SHIPTYPE = "abdcsp"
SHIP = [AIRCRAFT, BATTLESHIP, DESTROYER, CRUISER, SUB, PT_BOAT, MISS]
TOTAL2WIN = AIRCRAFT +BATTLESHIP +DESTROYER +CRUISER +SUB +PT_BOAT
SHIPNUM = {"a":0, "b":1, "d":2, "c":3, "s":4, "p":5, "m":6}
SHIPNAMES = {"a":" Aircraft Carrier", "b":" Battleship", "c":" Cruiser", "d":" Destroyer", "s":" Submarine", "p":" P T Boat", "m":" Missed!"}
COLNUMS = "-abcdefghi"
ROWNUMS = "0123456789"
KEYPAD2KEY = {K_KP1:K_1, K_KP2:K_2, K_KP3:K_3, K_KP4:K_4, K_KP5:K_5, K_KP6:K_6, K_KP7:K_7, K_KP8:K_8, K_KP9:K_9, K_KP_ENTER:K_RETURN}

class Ocean:
    def __init__( self, n_rows, n_cols ):
        """Create a ocean with given number of rows and cols.
        Ocean where battle field grid is.
        """
        self.n_rows = n_rows
        self.n_cols = n_cols
        self.battlefield = {}
        self.playerBattlefield = {}
        self.c_ltr = COLNUMS
        self.r_ltr = ROWNUMS
        self.seekShip = {"c":0, "r":0, "t":0} #r=horizontal, c=verticle, t=total
        self.cr4Move = {"s":{"c":1, "r":1, "m":0, "v":"MSMary", "rl":1, "vl":100}, "c":{"c":1, "r":1, "m":0, "v":"MSSam", "rl":0, "vl":100}}
        self.SCORE4P = {"s":[0,0,0,0,0,0,0], "c":[0,0,0,0,0,0,0]}
        self.SCORE_TOTAL = {"s":0, "c":0}

    def cr_Ok(self, d,c,r,s,f):
        """Check to see if row or column is clear of ships!
           d=direction, c=column, r=row, s=ship size, f=field"""
        if d==0:
            if c+s > self.n_cols+1: return False
            for cc in range(c, c+s):
                if COLNUMS[cc] +ROWNUMS[r] +f in self.battlefield: return False
        else:
            if r+s > self.n_rows+1: return False
            for rr in range(r, r+s):
                if COLNUMS[c] +ROWNUMS[rr] +f in self.battlefield: return False
        return True


    def randomize( self ):
        # Make random ship locations!
        maxCols = self.n_cols+1
        maxRows = self.n_rows+1
        fields = "sc"
        field = 0
        while not field == 2:
            for ship in range(SHIPS):
                done = False
#                print "Ship: %d Size: %d" % (ship, SHIP[ ship])
                while not done:
                    r = random.randrange(1, maxRows)
                    c = random.randrange(1, maxCols)
                    v = random.randrange(2)
#                    print "V=%d" % v,
                    if v == 0 and self.cr_Ok( v,c,r,SHIP[ ship], fields[field]):
                        for cc in range(c, c+SHIP[ship]):
                            self.battlefield[ COLNUMS[cc] +ROWNUMS[r] +fields[field]] = SHIPTYPE[ ship]
                        done = True
                    if v == 1 and self.cr_Ok( v,c,r,SHIP[ ship], fields[field]):
                        for rr in range(r, r+SHIP[ship]):
                            self.battlefield[ COLNUMS[c] +ROWNUMS[rr] +fields[field]] = SHIPTYPE[ ship]
                        done = True
            field += 1

    def findShip( field):
        "Find the ship location!"



pygame.init()
screen = pygame.display.set_mode((320,240))

purge = pyTTS.tts_purge_before_speak
async = pyTTS.tts_async

def Game(ocean):
    rowMax = ocean.n_rows
    colMax = ocean.n_cols
    rowNum = ROWNUMS
    colNum = COLNUMS
    SCORE4P = ocean.SCORE4P
    SCORE_TOTAL = ocean.SCORE_TOTAL
    awe = os.path.join("data", "awes.wav")
    windsnd = pygame.mixer.Sound('data\wind.wav')
    success = pygame.mixer.Sound('data\success.wav')
    sucks = pygame.mixer.Sound('data\sucks.wav')
    pissed = pygame.mixer.Sound('data\pissed.wav')
    damn = pygame.mixer.Sound('data\damnit.wav')
    boohoo = pygame.mixer.Sound(awe)
    fire = pygame.mixer.Sound('data\shoot.wav')
    hit = pygame.mixer.Sound('data\hit.wav')
    drop = pygame.mixer.Sound('data\drop.wav')
    shell = pygame.mixer.Sound('data\shell.wav')
    sink = pygame.mixer.Sound('data\sink.wav')
    sink2 = pygame.mixer.Sound('data\sink2.wav')

    wind = windsnd.play(-1)
    field = "s"
    cr2Move = ocean.cr4Move
    row = cr2Move[field][ "r"]
    col = cr2Move[field][ "c"]
    moves = cr2Move[field][ "m"]
    tts.Rate = cr2Move[field][ "rl"]
    tts.Volume = cr2Move[field][ "vl"]
    tts.SetVoiceByName( cr2Move[field][ "v"])
    battlefield = ocean.battlefield
    playerBattlefield = ocean.playerBattlefield
    moved = True
    toggle = True
    goal = False
    tts.Speak(" It is players turn first!")

#    print battlefield

    while True:
        "play game by firing shells!"
        event = pygame.event.poll()

#CHECK TO SEE IF IT IS COMPUTER'S TURN!
        if toggle==True and moved==True and field=="c":
            pygame.event.post(Event(KEYDOWN, {"unicode": u"\r", "key":K_RETURN, "mod": 0}))
            moved = False
            row = random.randrange(1, rowMax+1)
            col = random.randrange(1, colMax+1)
            time.sleep(1.0)

        if event.type == pygame.QUIT:
            return 0

        elif event.type == pygame.KEYDOWN:
            key = event.key
#            keymod = event.mod

            if key == K_ESCAPE:
                msg = "moves"
                if moves == 1: msg = "move"
                tts.Speak("You have made %d %s!" % (moves, msg))
                return 0
            if key == K_F12:
                tts.Speak("You Restarting the Game!")
                return 1

            if key == K_RCTRL:
                msg=""
                if toggle==True: toggle=False; msg="not"
                else: toggle=True
                tts.Speak(" Computer is now %s playing!" % msg)

            elif key == K_LCTRL:
                msg=""
                if toggle==True: toggle=False; msg="not"
                else: toggle=True
                tts.Speak(" Computer is now %s playing!" % msg)

            elif key == K_F10:
                if wind.get_busy():
                    wind.stop() #pause()
                    msg = "Off"
                else:
                    msg = "On"
                    wind = windsnd.play(-1)  #.unpause()
                tts.Speak("Wind Sound Is %s!" % msg)

            elif key == K_HOME:
                cr2Move[field][ "vl"] += 5
                if cr2Move[field][ "vl"] > 100:
                    cr2Move[field][ "vl"] = 100
                    tts.Volume = cr2Move[field][ "vl"]
                    tts.Speak('Volume Maximum!', async, purge)
                else:
                    tts.Volume = cr2Move[field][ "vl"]
                    tts.Speak('Volume Up!', async, purge)

            elif key == K_END:
                cr2Move[field][ "vl"] -= 5
                if cr2Move[field][ "vl"] <= 0:
                    cr2Move[field][ "vl"] = 0
                    tts.Volume = 100
                    tts.Speak('Volume Minimum!', async, purge)
                    time.sleep(.2)
                    tts.Volume = cr2Move[field][ "vl"]
                else:
                    tts.Volume = cr2Move[field][ "vl"]
                    tts.Speak('Volume Down!', async, purge)

            elif key == K_PAGEUP:
                cr2Move[field][ "rl"] += .5
                tts.Rate = cr2Move[field][ "rl"]
                tts.Speak('Rate Up!', async, purge)

            elif key == K_PAGEDOWN:
                cr2Move[field][ "rl"] -= .5
                tts.Rate = cr2Move[field][ "rl"]
                tts.Speak('Rate down!', async, purge)

#PITCH FUNCTION BUT DOES NOT EXIST FOR THE MICROSOFT ENGINE.
#            elif key == K_INSERT:
#                PITCH += .5; tts.Pitch = PITCH
#                tts.Speak('Pitch Up!', async, purge)

#            elif key == K_DELETE:
#                PITCH -= .5; tts.Pitch = PITCH
#                tts.Speak('Pitch down!', async, purge)

            elif key == K_F2:
                tts.SetVoiceByName('MSMary')
                cr2Move[field][ "v"] = 'MSMary'
                tts.Speak('Mary!', async, purge)

            elif key == K_F3:
                tts.SetVoiceByName('MSMike')
                cr2Move[field][ "v"] = 'MSMike'
                tts.Speak('Mike!', async, purge)

            elif key == K_F4:
                tts.SetVoiceByName('MSSam')
                cr2Move[field][ "v"] = 'MSSam'
                tts.Speak('Sam!', async, purge)

            elif key == K_F9:
                msg = "moves"
                if moves == 1: msg = "move"
                tts.Speak("You have made %d %s so far!" % (moves, msg))

            elif key == K_RETURN:
#  do check for ship and see if sunk, and game over!
                moved = True
                spk = colNum[col] +rowNum[row]
                index = spk+field
                if index in playerBattlefield: #ALREADY PLAYED?
                    if playerBattlefield[index] == "m": #WAS IT A MISS?
                        spk += " Already a Miss, Stupid!"
                    else: #MUST BE ALREADY HIT!
                        spk = SHIPNAMES[ playerBattlefield[index]] +" Already Been Hit in " +spk +", stupid!"
                else: #OR SHOOT AT LOCATION!
                    chan = fire.play()
                    time.sleep(1.5)
                    chan = shell.play()
                    time.sleep(2.0)
                    if index in battlefield: #IS THERE A SHIP THERE?
                        chan = hit.play()
                        time.sleep(3.0)
                        spk = SHIPNAMES[ battlefield[index]] +" Has Been Hit At " +spk #YES, AND GOT HIT!
                        playerBattlefield[index] = battlefield[index] #SO, STORE ON SCORE CARD!
                        SCORE_TOTAL[field] += 1
                        if SCORE_TOTAL[field] >= TOTAL2WIN: #HAVE YOU SUNK ALL THE SHIPS?
                            goal = True #YES, YOU WIN THE GAME!
                        SCORE4P[field] [SHIPNUM[ battlefield[index]]] += 1
                        if SCORE4P[field] [SHIPNUM[ battlefield[index]]] >= SHIP[ SHIPNUM[ battlefield[index]]]: #HAVE YOU HIT THE ENTIRE SHIP?
                            spk += " and Sinking!" #YES, SINKING!
                            chan = sink2.play()
                            time.sleep(3.0)
                            chan = sink.play()
                            time.sleep(3.0)
                    else: #YOU MISSED THE SHIP!
                        chan = drop.play()
                        time.sleep(1.0)
                        p = random.randrange(1, 20)
                        if p==17: chan = boohoo.play()
                        if p==11: chan = sucks.play()
                        if p==7: chan = damn.play()
                        if p==3: chan = pissed.play()
                        if p==3 or p==7 or p==11 or p==17:
                            time.sleep(2.5)
                        spk += " You Missed!"
                        playerBattlefield[index] = "m"
                tts.Speak(spk)
                if goal == True:
                    wind.stop()
                    chan = success.play()
                    tts.Speak("You destroyed the enemy in %d moves!" % moves, purge)
                    tts.Speak("Congratulations. You finished the Game!")
                    return 1
#TOGGLED PLAYER TURN:
                if field=="s":
                    field="c"
                else:
                    field="s"
#SET THE PLAYER PARAMETERS!
                row = cr2Move[field][ "r"]
                col = cr2Move[field][ "c"]
                moves = cr2Move[field][ "m"]
                tts.Rate = cr2Move[field][ "rl"]
                tts.Volume = cr2Move[field][ "vl"]
                tts.SetVoiceByName( cr2Move[field][ "v"])
                msg=""
                msg2="Computer"
                if toggle==False: msg="1"; msg2=" Player 2"
                if field == "s":
                    tts.Speak("Player %s turn!" % msg)
                else:
                    tts.Speak(" %s turn!" % msg2)

# MANUALLY enter field position:
#            elif chr(key) in COLNUMS or chr(key) in ROWNUMS:
#                tts.Speak(" key %c" % chr(key))

#OR MOVE USING CURSOR KEYS:
# do move up!
            elif key == K_UP:
                moves += 1
                if row<2:
                    row=1
                    tts.Speak("You Hit The Shore!")
                else:
                    row -= 1
                spk = colNum[col]+rowNum[row]
                index = spk+field
                if index in playerBattlefield:
                    spk += SHIPNAMES[ playerBattlefield[ index]]
                    if SCORE4P[field] [SHIPNUM[ playerBattlefield[index]]] >= SHIP[ SHIPNUM[ playerBattlefield[index]]]:
                        spk += " destroyed!"
                    elif "Missed" not in spk:
                        spk += " Hit!"
                tts.Speak( spk)

# do move down!
            elif key == K_DOWN:
                moves += 1
                if row>=rowMax:
                    row=rowMax
                    tts.Speak("You Hit The Shore!")
                else:
                    row += 1
                spk = colNum[col] +rowNum[row]
                index = spk+field
                if index in playerBattlefield:
                    spk += SHIPNAMES[ playerBattlefield[ index]]
                    if SCORE4P[field] [SHIPNUM[ playerBattlefield[index]]] >= SHIP[ SHIPNUM[ playerBattlefield[index]]]:
                        spk += " destroyed!"
                    elif "Missed" not in spk:
                        spk += " Hit!"
                tts.Speak( spk)

# do move to the right
            elif key == K_RIGHT: # right arrow
                moves += 1
                if col>=colMax:
                    col=colMax
                    tts.Speak("You Hit The Shore!")
                else:
                    col += 1
                spk = colNum[col] +rowNum[row]
                index = spk+field
                if index in playerBattlefield:
                    spk += SHIPNAMES[ playerBattlefield[ index]]
                    if SCORE4P[field] [SHIPNUM[ playerBattlefield[index]]] >= SHIP[ SHIPNUM[ playerBattlefield[index]]]:
                        spk += " destroyed!"
                    elif "Missed" not in spk:
                        spk += " Hit!"
                tts.Speak( spk)

# do move to the left!
            elif key == K_LEFT: # left arrow
                moves += 1
                if col<=1:
                    col=1
                    tts.Speak("You Hit The Shore!")
                else:
                    col -= 1
                spk = colNum[col] +rowNum[row]
                index = spk+field
                if index in playerBattlefield:
                    spk += SHIPNAMES[ playerBattlefield[ index]]
                    if SCORE4P[field] [SHIPNUM[ playerBattlefield[index]]] >= SHIP[ SHIPNUM[ playerBattlefield[index]]]:
                        spk += " destroyed!"
                    elif "Missed" not in spk:
                        spk += " Hit!"
                tts.Speak( spk)

# do status of score!
            elif key == K_F1:
                tts.Speak(HELP_MSG)
                for n in range(SHIPS):
                    st = SHIPTYPE[n]
                    tts.Speak("%d) for %s status." % (n+1, SHIPNAMES[st]))

# do status of score!
            elif key >= K_1 and key <= K_7:
                b = 0; e = SHIPS
                if key <> K_7:
                    b = key -K_1; e = b+1
                for n in range(b,e):
                    st = SHIPTYPE[n]
                    sn = SHIPNUM[st]
                    s = SCORE4P[field][ SHIPNUM[st]]
                    msg = "hits " +str(s)
                    if s >= SHIP[sn]: msg = "Destroyed"
                    tts.Speak("%s %s" % (SHIPNAMES[st], msg))

# record the  move of the player or computer.
            if key <> K_LCTRL and key <> K_RCTRL:
                cr2Move[field][ "r"] = row
                cr2Move[field][ "c"] = col
                cr2Move[field][ "m"] = moves

#        pygame.display.flip()  #re-draw screen!

if __name__ == '__main__':
    n = 9
    bf = {}
    while True:
        tts.Speak('This ocean is %d cells on each side.' % n)
        o = Ocean(n,n)  #make ocean!
        o.randomize() #make battle field!
        if not Game(o):
            tts.Speak("Good! Bye!")
            pygame.quit()
            sys.exit()
            break