Fwd: [Tutor] crash - switching between text window and graphics/gamewindow (high score)

D. Hartley denise.hartley at gmail.com
Thu Apr 21 19:34:32 CEST 2005


Thanks for the encouragement!!

I'm going to be completing some further updates today and hope to post
a url where anyone can get the whole game and try it out.  I made a
fall-back version where the game displays not a high score list
requiring input in the text window, but only keeps track of the one
highest score and displays that (i.e., no names = no user input into
the console window = no crash).  That way if I can't find an answer to
the crash problem by next Thursday (holy crap, only one week), I'll
still have a working game I can give to him.

I'll let you guys know if I find anything, and will post the url as
soon as the game is uploaded.  And let me know if any ideas come to
you about the crash!

Thanks,
Denise

---------- Forwarded message ----------
From: Alberto Troiano <albertito_g at hotmail.com>
Date: Apr 21, 2005 6:21 AM
Subject: Re: [Tutor] crash - switching between text window and
graphics/gamewindow (high score)
To: denise.hartley at gmail.com
Cc: tutor at python.org


Hi

Sorry about that, I'm using Python 2.3.4 cause when Python 2.4 was released
there wasn't libraries like MySQLdb and ReportLab (and I needed those)

I agree with Max, the problem is somewhere else but it'll take time (I don't
have to do a report but I do have to finish a web-based system over Linux)

In the mean time only have to say that your game rocks!!
I'll send you mine next week

Regards

Alberto

<html><div><IMG height=12 src="http://graphics.hotmail.com/emvamp.gif"
width=12>Gaucho</div></html>

>From: "D. Hartley" <denise.hartley at gmail.com>
>Reply-To: "D. Hartley" <denise.hartley at gmail.com>
>To: Alberto Troiano <albertito_g at hotmail.com>
>Subject: Re: [Tutor] crash - switching between text window and
>graphics/gamewindow (high score)
>Date: Wed, 20 Apr 2005 16:10:02 -0700
>
>Alberto,
>
>The sorting works just fine on mine (and on my friends' computers
>too).  sort CAN take no arguments, but it can also take three - key,
>cmp, and reverse.  Perhaps you have an older version of something?
>
>~Denise
>
>On 4/20/05, Alberto Troiano <albertito_g at hotmail.com> wrote:
> > Hi
> >
> > The thing is this
> >
> > I get an error that says sort() has no arguments
> >
> > Th error is in the sentence
> > high_score.sort(reverse=TRUE)
> >
> > If you put just sort() it will work but the list will show from low to
>high
> > and we don't want that 'cause if you make a high score it won't be able
>to
> > know so you have to figure out another way to reverse the list
> >
> > Regards
> >
> > Alberto
> > >From: "D. Hartley" <denise.hartley at gmail.com>
> > >Reply-To: "D. Hartley" <denise.hartley at gmail.com>
> > >To: Alberto Troiano <albertito_g at hotmail.com>
> > >Subject: Re: [Tutor] crash - switching between text window and
> > >graphics/gamewindow (high score)
> > >Date: Wed, 20 Apr 2005 14:22:24 -0700
> > >
> > >Alberto,
> > >
> > >Thank you for replying! I sent answers to the general questions to the
> > >tutor list, so that hopefully the extra clarification might help
> > >someone else answer (I havent had much luck with this thread,
> > >unfortunately).  But I wanted to reply to you personally to send a
> > >copy of the game.  It's a "mod" of a game from pygame, but I've added
> > >a lot of stuff to it.  I'll send it as a zip file with two different
> > >"play" files - run the one simply called "play" to test out the game
> > >without the crash (oh, a side-note: the enemy ships will change
> > >graphics on levels 2 and 3, but they're not pretty - i just put those
> > >graphics in there as a place holder until i make their prettier
> > >replacements).  Anyway, the play file called "copy of play
> > >wscorelist2" is the copy with the scorelist that is crashing.  If you
> > >just want to see the *code*  you can look at either of those two
> > >files, but I thought you might want to play the actual game so I'm
> > >sending it all. Have fun :) Any comments/ideas/suggestions are very
> > >welcomed!! I'm having a couple friends test it out. But since I'm new
> > >I might not be able to take ALL of the suggestions before I have to
> > >have the game done next week, ha ha.
> > >
> > >Anyway thanks so much for replying, and for any help or suggestions
> > >you might have about the crash.
> > >
> > >~Denise
> > >
> > >P.S. if you dont have them, you'll need pygame and the livewires
> > >module, available at http://www.livewires.org.uk/python/lwpackage.html
> > >.  Thanks again!
> > >
> > >On 4/20/05, Alberto Troiano <albertito_g at hotmail.com> wrote:
> > > > Hey
> > > >
> > > > I'm curious
> > > >
> > > > What extension are you using on your game???????????
> > > > is it .py???????????????
> > > >
> > > > And what OS are you running the game???????????????
> > > >
> > > > Another thing. I made a space ship game to learn Python. Is there a
> > > > possibility that we exchange the games so we can know differents
>points
> > >of
> > > > view????????
> > > >
> > > > I'll wait your reply
> > > >
> > > > Regards
> > > >
> > > > Alberto
> > > >
> > > > >From: "D. Hartley" <denise.hartley at gmail.com>
> > > > >Reply-To: "D. Hartley" <denise.hartley at gmail.com>
> > > > >To: Python tutor <tutor at python.org>
> > > > >Subject: [Tutor] crash - switching between text window and
> > > > >graphics/gamewindow (high score)
> > > > >Date: Tue, 19 Apr 2005 15:29:42 -0700
> > > > >
> > > > >Ok. I got in the working code to have a high score list, and it
>even
> > > > >saves/loads one now (!!).  The only problem is, clicking back from
>the
> > > > >text window to the game window (only after you entered in your name
>to
> > > > >go onto the high score list), closes the program. you dont get to
>say
> > > > >y/n to another game, it just shuts down. i cant run a debugger on
>it,
> > > > >because the error doesnt happen when I F5-run the game from the
>python
> > > > >IDLE script, only when i have ran it by doubleclicking on it (which
>is
> > > > >how you're supposed to run it. otherwise it doesnt shut down
> > > > >properly). i really really REALLY want to keep the high score part
>of
> > > > >my program, because i worked really hard to get this to work. but i
> > > > >have to have this program running with NO crashes in like a week
>(it's
> > > > >a birthday present, and the birthday is approaching fast!)
> > > > >
> > > > >Here's the "end of game" code:
> > > > >
> > > > >             #game over..
> > > > >             if lives == 0:
> > > > >### trying addscore
> > > > >
> > > > >                 def add_score():
> > > > >  #                   high_scores = [(1000,"Denise"),
>(945,"Denise"),
> > > > >   #                                 (883,"Denise"),(823,"Grant"),
> > > > >    #                                (779,"Aaron"), (702,"Pete"),
> > > > >     #                               (555,"Tom"), (443,"Tom"),
> > > > >      #                              (442,"Robin"), (4,"Pete")]
> > > > >                     high_scores = pickle.load(file("scores.pik"))
> > > > >                     score = total_enemy_hits
> > > > >                     if score > high_scores[-1][0]:
> > > > >                         print "Ta da! You got", total_enemy_hits,
> > > > >"Ranch Delivery Devices!"
> > > > >                         name = read_string("You made the high
>score
> > > > >list! What's your name? ")
> > > > >                         user_score = (score,name)
> > > > >                         high_scores.append(user_score)
> > > > >                         high_scores.sort(reverse=True)
> > > > >                         del high_scores[-1]
> > > > >                         pickle.dump(high_scores,
>file("scores.pik",
> > >"w"))
> > > > >                         for score, name in high_scores:
> > > > >                             slip = 30 - len(name)
> > > > >                             slip_amt = slip*" "
> > > > >                             prefix = 5*" "
> > > > >                             print prefix,name,slip_amt,score
> > > > >                     else:
> > > > >                         print "Sorry, you only got",
>total_enemy_hits,
> > > > >"Ranch Delivery Devices."
> > > > >                         print "You didn't quite make the high
>score
> > >list!"
> > > > >                         for score, name in high_scores:
> > > > >                             slip = 30 - len(name)
> > > > >                             slip_amt = slip*" "
> > > > >                             prefix = 5*" "
> > > > >                             print prefix,name,slip_amt,score
> > > > >                         print "Better luck next time!"
> > > > >
> > > > >  #               pdb.set_trace()
> > > > >                 add_score()
> > > > >
> > > > >                 end.play()
> > > > >                 showGameOver(screen, background_image)
> > > > >                 pygame.display.flip()
> > > > >
> > > > >
> > > > >                 answer = ""
> > > > >                 while not answer in ("y","n"):
> > > > >                    for event in pygame.event.get():
> > > > >                       if event.type == KEYDOWN:
> > > > >                          if event.key == K_n:
> > > > >                             answer = "n"
> > > > >                          elif event.key == K_y:
> > > > >                             answer = "y"
> > > > >                 if answer == "n":
> > > > >                     running = 0
> > > > >                 else:
> > > > >                     return 1
> > > > >
> > > > >             #refresh the display
> > > > >             pygame.event.pump()
> > > > >             pygame.display.flip()
> > > > >
> > > > >     #well, nice playing with you...
> > > > >     screen = pygame.display.set_mode((640, 480))
> > > > >     return 0
> > > > >
> > > > >
> > > > >Can anyone tell me why it crashes? you click to the text window
>when
> > > > >there's the "congrats, you made the high score list, enter your
>name"
> > > > >prompt, enter your name and hit enter, and it displays the high
> > > > >scores, with your name in it, just as it should. but then when you
> > > > >click back to the game screen, poof! it all closes.  Of course if
>you
> > > > >dont make the high score list, you can click to the text window and
> > > > >click back to the game window and it operates like it should.
> > > > >
> > > > >Any suggestions would be appreciated!!  Again, I'd like to have it
>do
> > > > >all this score stuff in the game/graphics window, and then it
>wouldnt
> > > > >have that crash at all. But I dont know how to do that.
> > > > >
> > > > >Please help!
> > > > >
> > > > >Thanks again :)
> > > > >
> > > > >~Denise
> > > > >_______________________________________________
> > > > >Tutor maillist  -  Tutor at python.org
> > > > >http://mail.python.org/mailman/listinfo/tutor
> > > >
> > > > Gaucho
> > > >
> > > >
> > ><< zmine.zip >>
> >
> > Gaucho
> >
> >


More information about the Tutor mailing list