CS 1063 Programming Contest: Fall 2014
Winners Announcement
Winners Solutions
Original Assignment
Contest Rules
This solution is by Cassidy Matousek:
I enhanced AngryCircles by turning it into a game called Starship Lockdown.
Game Premise:
In Starship Lockdown, a meteor shower has caused a malfunction in the main starship and locked your satellite ship out.
To get back into the main ship, you must disable the force field surrounding it; this is done through immobilizing the moving
guard (target) by hitting it five times. If you miss the target, the force field will send your fire back at you; the satellite
ship you are on can only take three hits before it is too damaged to continue.
Using Starship Lockdown:
As explained in the introduction slide, the goal of the game is to hit the target five times, thus disabling the
force field. If the target is missed, the force field will return fire; if the return fire hits the cannon, a
life is lost. The cannon can be moved left and right by pressing the LEFT and RIGHT arrow keys. The angle of the
cannon's fire can be changed by using the UP and DOWN arrow keys. The force is still changed up or down with the
"+" and "-" keys. The spacebar is pressed to fire the cannon. "S" is pressed to start the game, and "R" can be
pressed to restart at any time.
AngryCircles Enhancements
Graphics: I enlarged the size of the drawing panel and added an introduction slide to give the premise of the game.
The moving stars in the background (to look like a meteor shower) were created by calling a method to repeatedly
produce random yellow lines. I created a variable "navy" to set up the background color and another color "lightBlue"
to show the return fire from the force field.
Moving cannon/target: Instead of the user moving the target, I had it move itself; that is, the targetTop variable
is added to and redrawn over and over until it hits the top of the drawing panel, and then starts back the other
way. It was important to allow the user to move the cannon as it will have to run from the return fire from the
force field. This was done by creating another class variable xCannon, and saving that variable equal to
xCannonAtMiss when it was determined the cannonball had not hit the target.
Return fire: This was probably the most important enhancement because it is the only obstacle the user has to overcome.
As mentioned above, the position of the cannon when the target was missed is recorded, and this is used as the
position to send the fire back to. (In early attempts, simply using the xCannon variable to send return fire failed
because the user had no way to run from the return fire.) The time at which the target was missed is also recorded,
and it is used to redraw the path of the cannon backwards by simply de-incrementing the time. A check is used to
see if the return fire has hit the cannon within five pixels by using the cannon's current position (xCannon).
Key Events: Because I could not change DrawingUtility, I created my own KeyListener within AngryCircles to make it
a little bit easier for players to use. "S" is used to start the game after the introduction is played, and "R" can
be used at any time to reset the number of lives and hits. The cannonball is fired by pressing the space bar, and
the left and right arrow keys move the cannon left and right. Finally, the up and down arrow keys were reset to
move the angle of the cannon up/down.