0% found this document useful (0 votes)
20 views1 page

Python 026

Uploaded by

darkflux514
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views1 page

Python 026

Uploaded by

darkflux514
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Next, we make an instance of Scoreboard in __init__():

alien_invasion.py def __init__(self):


--snip--
pygame.display.set_caption("Alien Invasion")

# Create an instance to store game statistics,


# and create a scoreboard.
self.stats = GameStats(self)
self.sb = Scoreboard(self)
--snip--

Then we draw the scoreboard onscreen in _update_screen():

alien_invasion.py def _update_screen(self):


--snip--
self.aliens.draw(self.screen)

# Draw the score information.


self.sb.show_score()

# Draw the play button if the game is inactive.


--snip--

We call show_score() just before we draw the Play button.


When you run Alien Invasion now, a 0 should appear at the top right of
the screen. (At this point, we just want to make sure the score appears in
the right place before developing the scoring system further.) Figure 14-2
shows the score as it appears before the game starts.
Next, we’ll assign point values to each alien!

Figure 14-2: The score appears at the top-right corner of the screen.

288 Chapter 14

You might also like