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

Alien Invasion Game Setup Guide

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)
2 views1 page

Alien Invasion Game Setup Guide

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

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

You might also like