Comp 152 Project 5: Graphics
Due Monday May 6th at 11:59pm.
The high level objectives of this lab are:
- Use graphics
- respond to new events (keyboard/mouse events)
- use basic data structures
- To design and complete a significant project from the specification
You are going to build a graphical game based on a simplified version of the
vintage game "Yars Revenge" (note not the sequal on the xbox).
If you've never played the game on one of those retro gaming platforms you
can find a couple of screenshots below - note the two possibilities of base
You are going to implement a simplified one level 'yars revenge' like game
with the following properties:
What resources may you use:
- We are going to omit the colored
'shield' line down the center since it disappears in later levels
- There must be a ship controlled by the player.
- it begins on the left side of the screen
- the player can move it up, down left or right. The ship cannot leave
the screen. The ship cannot go through the enemy shield (shown in red
in the image above.) though there is no penalty for the player ship
touching the enemy shield.
- There must be an enemy ship
- the enemy ship starts out inside its shield on the right hand side
of the screen
- every 30 seconds the enemy ship should change its icon (the original
game used a swirl, but you can just use a diffetent ship), wait in its
base for at least one second, and then move towards the players
position, moving at 'high speed' (lets define this as taking about 2
seconds to cross a 1000 pixel screen). If the enemy hits the player
(the enemy should not change directions) in this form then the player
- If the player dodges the enemy and the enemy hits the edge of the
screen, then the enemy resets to its original form and returns to its
- The player ship must be able to shoot a shot
- shots should be able to be shot at least once a second and take at
least 2 second to cross the screen
- therefore you must support at least two shots on the screen at
- You should not allow more than 5 shots per second
- shots will destroy one 'chunk' of the enemy base for each one that
- shots will destroy the enemy ship if the shot hits the enemy while
the enemy is in its original form.
- shots should not affect the enemy ship while that ship is in attack
- shots always travel from left to right.
- You need an enemy base.
- the base should be made up of 'chunks' of shield.
- The whole shield can be any starting shape that is convenient
- I recommend a simple rectangle to start with. Place the rectangle in
front of the enemy ship.
- Whenever one of the shield chunks is hit by a player shot it is
removed from the game. It should neither be drawn nor block any shots
on the player ship.
- Your shield should have somewhere from 50 to 100 chunks.
- there should be no way to hit the enemy ship without destroying a
large part of the shield.
- You need to keep score and display the score on the screen.
- each shield chunk you destroy is worth 5 points
- kill the enemy for 200 points.
- Starting and stopping the game
- when the program starts up the game should start.
- When either the player is destroyed or the enemy is destroyed the
game should stop and put up a victory or loss message.
To make everything completely clear so there is no misunderstandings about
this project please feel free to use anything in your book for this project.
Please also feel free to use anything from the Java
6 API documentation site. Finally you may use any of the official
java tutorials from Oracle especially the
2d graphics tutorials. Anything else that you wish to use you must get
your instructors permission to use (one exception - see extra credit below)
You may use any images for this project that you are legally able to use.
For those who want some quick starter images, I've put together a
small zip file of images that you might find helpful. All
the image files included are licensed under the GPL: the short version,
you can use them, but you don't own them, and if you ship a product using
them you need to give credit and let others use them too.
Extra Credit Possible:
For those of you who would like the chance to earn extra credit here are
opportunities to do that:
Extra credit will only count for those who
have completed the basic project above. Once you have completed the
project above, you may complete any, all or none of these extra credit
items at your
For 15 extra points When the game
is over there should be a way to restart the game without restarting the
For an extra 50 points: Put sounds
into your program. For each of the major events (player shoots, player dies,
player kills enemy, shot destroys part of the shield and enemy turns into
attack form) a different sound should be played. If you do this don't forget
to send the sound files with your submission. For this part, because we have
not covered sound in the course, you may use any extra tutorials that you
wish for help on this part of the program only!!
For an extra 40 points: In the
original game, every even level the shield was static, but on odd levels the
chunks of the shield (and the holes when part of the shield was gone)
rotated through different positions. For 40 points extra, make your shield
use the rotating chunks.
For and extra 60 points: Implement
the 'zorlon cannon'. This was a large shot which would sit behind the player
ship on the left edge of the screen. The only way to get it was for the
player ship to eat/harvest at least on of the shield chunks by running
against them. This removes the shield chunk just as if it were shot, but
activates the cannon, which follows the player up and down the screen, The
cannon shot moves more slowly accross the screen when fired (by a different
control than the regular shot) If the cannot shot hits the player, the
player dies. If the cannon shot hits a shild chunk. The chunk is destroyed.
If the cannon shot hits the enemy ship in normal mode, the enemy is
destroyed. If the cannon shot hits the enemy ship in attack mode, the enemy
is reset, and the player gets an extra 'life'
You must satisfy the following constraints on your program
Your program should be well commented
No one method may be longer than 25 lines of code long
(Lines with only braces on them don't count. Since comments and
white space aren't code, they do not count either.)
Make sure each of your classes represents only a single concept.
You will need classes for at least the player ship, the enemy and
the game, and probably more than that.
When your program is ready, you need to write a readme.txt file that
provides me the following information:
The name of your java files (and the
names of any extra non-public classes that are contained in the file.
The implementation decisions that you
made. Why did you solve the problem the way that you did?
- Did you implement any extra credit? if so what?
Directions on running and using your
program. Especially anything that might not be the same for all
students. Also tell me what file name you used.
And any problems or bugs left in your program. If your program
doesn't quite work in some situations, tell me about it. If your
program doesn't run or compile, I want to know that before I try.
When your readme and your code is ready, zip up your files and submit them
online as you have done for the recent labs