Lab 9: Arcade Game
An Epic CS151 Final Project
In this week's lab, we will start working on a final game project of your choosing. The goal of this assignment is to demonstrate independent problem solving and synthesis of old projects and ideas into new ones. Therefore, your best resource is the collection of games and projects that we have built throughout the semester. I recommend that you start working on this project today. As always, let me know if you have any questions or if you need any help.
Check the list of games below, and select a game to implement as your final project. Find a video of the game to understand it better.
Game | Possible points | Resources |
Asteroids* | 26 | |
Tron (Light Cycles) | 26 | |
Lunar Lander | 27 | |
Pole Position | 27 | |
Arkanoid* | 28 | |
Xevious | 28 | |
Grand Theft Auto | 29 | |
Tetris* | 30 | |
Super Mario Bros. | 30 |
*Popular choice
Every game is expected to be implemented using classes, and inheritance should be used when needed. Any time you find yourself repeating code in two classes you should consider using inheritance. You can use any concept that we have covered in class, but you can NOT use lambda functions, list comprehension, or any concept that we did not cover.
top-down design is the decomposition of a system into smaller parts in order to comprehend its compositional sub-systems. In this step, you are expected to make a list of the classes and objects needed to implement your game. Then, think about how the objects will interact with each other and define the behaviour of each object.
I recommend that you talk to other students who are implementing the same game to brainstorm together. Add your name and email address under the game that you plan to develop here: Link
Feel free to continue to talk to each other after this lab, a mailing list or a chat group is not a bad idea. Keep in mind that you are encouraged to talk to others, but sharing code is not allowed.
You are expected to implement the main features of the game. If some features of the game are not possible, please confirm that with me through email.
By the end of this lab, you are expected to draft a list of objects and a list of behaviours for each object. For example, the Asteroids game, has the following objects:
The list of behaviour should include (but not limited to) the following:
You can make additions to the game other than the original implementation to gain extra extension points on top of the possible points listed in the table above. As always, extensions that focus on functionality are worth more than extensions that focus on aesthetics. Make sure you write about your extensions in detail in your project report. Be creative!
If you decide to implement a version of the game Asteroids, below you can find some a walkthrough of the main code components. You can use the steps below as a guide for organizing your code for other games as well.
Create a Lab09 folder on your computer where you store CS151 projects and labs, hopefully somewhere that is backed up (e.g. in Dropbox, Google Drive, Microsoft One Drive, etc.)
Create the file asteroid_mining.py in your Lab09 folder, and open it in VS Code.
Open up a Terminal (e.g. Control+` in VS Code) and change the directory (cd) to the Lab09 folder.
Start by writing the typical docstring at the top of the file and import the turtle, time, and random modules into your code.
First, let’s make a Spaceship class:
class Spaceship:
# implements the spaceship in the game
Next, let’s write the __init__ method that initializes the Spaceship object and takes x_pos, y_pos, and color as arguments. The method is expected to initialize the following attributes:
Next, let’s add two methods to control the spaceship with keyboard buttons:
def left(self):
#your code goes here
def right(self):
#your code goes here
The two methods rotate the turtle “ship” object to the right or left by 20 degrees.
Finally, let’s build a “move” method that can be called repeatedly to move the spaceship across the window. The method is a single line of code that moves the turtle forward by the speed attribute of the spaceship.
First, let’s make a Asteroid class:
class Asteroid :
# implements the Asteroid in the game
Next, let’s write the __init__ method that initializes the Asteroid object without taking any arguments (other than self). The method is contains the following attributes:
When initializing the “rock” object, remember that a circle is 20 x 20 px by default, but you can change that size using the following code:
self.rock.shapesize(0.4, 0.4)
Finally, let’s add a method called “relocate” to move the Asteroid to a random location on the screen. You can reuse your random position code from __init__ in this method. As a challenge, let’s see if you can write it as a single line of code.
In your main function, add the following:
You are expected to add the following to the Spaceship class for your project:
You are expected to add the following to the main function:
Here are a few ideas for project extensions: