MONT 105S, Spring 2009
Home | | Course Schedule | | Assignments | | Lecture NotesLaboratory 10
A Simple Game Graphic
In this lab, you will create a game window with a graphic background. A sprite will
move in a square pattern on the background.
Before you begin, download the following images into the same folder that will have your
python program in it. (You can download an image by right-clicking and choosing
"Save image" from the menu).
Writing the main program
Writing the Mario class.
Test your program. If correct, the Mario sprite should move in a square on the
screen background.
What To Turn In. Reminder. Be sure to save a copy of
each program on your
Due at the end of today's class
Start by importing the games package from livewires:
from livewires import games
Next, write a main program that does the following:
The above program should create a Mario character on the background image. The
Mario sprite will move to the right until it disappears off the edge of the screen.
Next, write a Mario class. The class definition should come immediately after
the "from livewires import games" line and before the main program.
This class should inherit from the Sprite class,
so your class should begin with the line:
class Mario(games.Sprite):
Your Mario class should have a single function, named update, as follows:
def update(self):
The update function will cause the Mario
sprite to move in a square, using the following logic:
Once the class is written, change the sprite in the main program so that it is
an object of type Mario (instead of games.Sprite).