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