class AlienInvasion:
"""Overall class to manage game assets and behavior."""
def __init__(self):
--snip--
[Link].set_caption("Alien Invasion")
1 [Link] = Ship(self)
def run_game(self):
--snip--
# Redraw the screen during each pass through the loop.
[Link]([Link].bg_color)
2 [Link]()
# Make the most recently drawn screen visible.
[Link]()
[Link](60)
--snip--
We import Ship and then make an instance of Ship after the screen has
been created 1. The call to Ship() requires one argument: an instance
of AlienInvasion. The self argument here refers to the current instance of
AlienInvasion. This is the parameter that gives Ship access to the game’s
resources, such as the screen object. We assign this Ship instance to [Link].
After filling the background, we draw the ship on the screen by calling
[Link](), so the ship appears on top of the background 2.
When you run alien_invasion.py now, you should see an empty game
screen with the rocket ship sitting at the bottom center, as shown in
Figure 12-2.
Figure 12-2: Alien Invasion with the ship at the bottom center of the screen
236 Chapter 12