tags:

views:

45

answers:

1

I am using pygame and livewires (though I don't think that part is relevant here) to create a game. I've got the game working, but I'm trying to make something akin to a title screen before the game starts. However, it doesn't recognize when I try to make a new line appear. Here is what I have:

    begin_message=games.Message(value="""      Destroy the Bricks!\n
                                    In this game, you control a paddle,\n
                                    controlled by your mouse,\n
                                    and attempt to destroy all the rows of bricks.\n
                                    Careful though, you only have 1 life.\n
                                    Don't mess up! The game will start in\n
                                    5 seconds.""",
                            size=30,
                            x=games.screen.width/2,
                            y=games.screen.height/2,
                            lifetime=500,
                            color=color.white,
                            is_collideable=False)
games.screen.add(begin_message)

The message appears on the screen, but the newline doesn't happen, so I can only read the first part of the message. Is there a way to make this message actually appear, or can I not use the 'Message' for this?

+1  A: 

The livewires games.Message class cannot do this.

Going through the source code for games.Message shows that it inherits from games.Text, which has a method _create_surface(). Finally, this calls pygame.font.Font.render() to draw the text to a surface. If you look at the documentation for render(), it states

"The text can only be a single line: newline characters are not rendered."

As for how you'd do what you want, I'd suggest making several Message objects, one for each line. Then display them on the screen one after the other.

Dan