2020/4/17 A7: An Avoider Game
https://utah.instructure.com/courses/601135/assignments/6993651 1/3
A7: An Avoider Game
Avoider Games
An avoider game is a class of games where you must navigate your mouse pointer past
obstacles. A basic avoider game is essentially a maze, while more complicated ones might
have moving enemies, traps, helpful tools, and so on. A simple example of this genre of game
is at
https://armorgames.com/play/519/mouse-avoider-2
(https://armorgames.com/play/519/mouse-avoider-2)
(http://www.gamesbob.com/mouseavoider) Note that you will maybe have to enable Flash in
your browser to be able to play it.
The goal for this assignment is to make an avoider game.
Getting Started
Download the AvoiderStarter PyCharm project: A7.zip. You may not use or modify the sample
map or sample characters in your own project - this is just to give an idea of how it might work.
Make your own.
Look carefully at the AvoiderGame code. It loads a map to use as a background, then reports
on the color underneath the mouse cursor and shows how to make animation cycles of different
lengths using an overall frame counter. These are key concepts you will need to make your own
game, so work to understand them.
There are two functions in the starter code. One is a sprite loader that reads a folder of images
and stores them in a list. This function can be used to read Piskel
(https://www.piskelapp.com/ (https://www.piskelapp.com/) ) sprites exported as a zip file
and then extracted to a folder.
The other function moves a rectangle between two points as a frame count increases - this can
be used to move a guard sprite, for example. You do not need to use this, but you may find it
useful.
Installing Pygame
Follow the directions and example from the lectures next week to install pygame in your
PyCharm project.
Making Your Game
The basic requirements for the game are simple (worth 100 points out of 200 total):
1. Make a background image for the avoider game. There should be a safe color, a start color,
and an end color.
2020/4/17 A7: An Avoider Game
https://utah.instructure.com/courses/601135/assignments/6993651 2/3
2. The basic mechanics are the player clicks on the start color to begin (look at
MOUSEBUTTONDOWN events in pygame), then moves the mouse to the end color. If
anything besides the start, end, or safe color is touched, the game is over. Use an if-
statement to check this.
3. If the player wins by bringing the mouse to the end color, bring up a win image or sprite. If
the player loses, bring up a lose image or sprite. Wait a sufficient amount of time and then
close the program (or go to the next level).
You must demonstrate these basic requirements during the lab on Apr 17th to receive
points for that lab. We will post more information about this requirement next week.
Additional requirements are to make the game more interesting (worth 100 points out of 200
total):
1. There should be at least 2 levels. When the end color is reached of level 1, a new
background should be loaded, and the player needs to click on the start color again to begin
that level.
2. If the player loses during a level, you should ask the player if they want to try again or quit.
3. Each level needs at least 2 animated sprites that move in different ways. The sprite can
make the player lose, or the sprite can somehow help the player. Make the sprite in Piskel
or some other program, but the files need to be in a folder and named like Piskel does to be
loaded by the starter code.
4. A timer is needed to show how fast the player completes each level. Display the time on the
screen, building on the example from the starter code.
5. You need to be creative and add something to make the game interesting. A perfectly done
game with two levels with two sprites each that bounce in different ways will be considered
a B grade game. Your creative elements are needed to move into the B+ and A range.
Think about animating the whole map (or animating a sprite that looks like part of the map
on top of the map), using image rotation, adding different kinds of sprites and triggers and
traps. Keep track of top scorers by reading and writing to a score file. Have fun with it!
6. Write a short description of the creative elements of the game so that we are sure to notice
them. A paragraph or short bullet list is fine for this. Add a pdf or txt file in the folder with the
name "CreativeParts" .txt or .pdf. Make sure it gets zipped up with the rest of the materials.
Some Suggestions
Pygame has support for colliding rectangles or checking if a point (for example, from a mouse
click) is inside a rectangle. Read documentation on pygame and google for suggestions on how
to check. This can be used for basic hit box collisions -- i.e. checking if your mouse position is
colliding with any sprites or other geometry in scene.
But you can do a lot just with color and comparing the color under the cursor to known colors
(use the starter code to look at color values). When I was trying out some code for this project, I
began by keeping track of "bad" colors that would cause me to lose. Once I started using
sprites with lots of colors, this became unwieldy. Instead I tracked the "good" colors (start, end,
2020/4/17 A7: An Avoider Game
https://utah.instructure.com/courses/601135/assignments/6993651 3/3
MAR 27 AP
1 w
APR 10 AP
FEB 19 MA
FEB 12 FE
FEB 07 FE
JAN 29 FE
COMP 1010-001 Spring 2020 Spring 2020
NAME STATUS RELEASED
A7: An Avoider Game No Submission
Practical Test 2 0.0 / 100.0
A6: Novel Analysis 81.0 / 100.0
A5: Sound Effects 100.0 / 100.0
Practical Test 1 9.5 / 100.0
A4: Loops Functions and Image Processing No Submission
Submit Programming Assignment
Upload all files for your submission
SUBMISSION METHOD
DRAG DROP
Any file(s) including .zip. Click to browse.
Upload
and path) and checked to see if I hit anything besides those to cause the lose condition. This
switch let me be much more general with what was drawn on the screen.
The starter code has some examples of variables used to track the status of the game. For
example, there is a game_started variable that isn't used, but is intended to be False before the
player clicks on the start color and True once that has happened. This "flag" variable can then
be used in the game loop in if statements to control when checks happen, for example, when to
look for touching a bad color.
Test your program carefully. Is it playable by someone besides the developers? Do things
appear and disappear properly when levels change? Is the timer done correctly?
Submitting
Keep all your code and images in a PyCharm project folder (or folders inside the folder). Your
code file should have a comment up top with your name as the author of the final code.
Zip up the PyCharm folder and submit it on Gradescope.