[Tutor] Text problem

Kent Johnson kent37 at tds.net
Tue Jun 7 21:51:28 CEST 2005


EUGENE ASTLEY wrote:
> Python, pygames problem.
> 
> At the end of my game, I go back to the desk top after displaying the 
> score of the player, as follows:
> 
> Def game_over(self)
> 
> Games.Message(screen = self.screen,
> 
>             X = 400, y = 400
> 
>             Text + “Your Score is  “ + str(Game.score_value),
> 
>             Size = 60, color = color.green,
> 
>             Lifetime = 1000, after_death = self.screen.quit()
> 
>  
> 
> This works well but I would like to have several lines of text. The 
> triple quote method does not work. How can I get several lines of text 
> into the message?

It looks like you are using livewires and you have paraphrased your code. It's helpful if you copy and paste the exact code you have tried and any error message you get.

Looking at livewires.games.py I see

class Message(Text):

    def __init__ (self, screen, x, y, text, size, color,
                  a=0, dx=0, dy=0, da=0,
                  lifetime=0, after_death=None):

so I would try something like this:

def gameOver(self):
   text = “""Your Score is  %s
Thank you for playing
Please come again""“ % Game.score_value
    games.Message(x = 400, y = 400, text = text,
            size = 60, color = color.green,
            lifetime = 1000, after_death = self.screen.quit())

Kent



More information about the Tutor mailing list