The software company you're working for is developing a game named Comets that is essentially a clone of an old popular arcade game.The player controls a spaceship that floats around in two-dimensional space, propelled by its engines and carried by its inertia. Comets are also floating around.Anything that goes off one side of the screen re-emerges on the opposite side. The player's goal is to destroy all of the comets without colliding with any of them. The situation is complicated somewhat by the fact that shooting larger comets causes them to break into several smaller comets, thus making them more difficult to avoid.

A basic game interface is already written, so you don't need to worry about drawing anything on the screen or responding to the player pressing buttons. All you need to do is write classes to represent the various objects in the game. JavaDoc specifications for these classes are provided, and here's a general outline:

SpaceObject is an abstract class representing all of the objects in game, including the comets, bullets fired by the player, and even the player's ship. This should keep track of the position, velocity, and size of the object. It provides methods for updating the object's position based on its velocity, determining whether the object is overlapping with another object, and accessors for the object's position and size.SpaceObject has static fields for the playfield width and height that are set up by the main class. These two fields should be used to determine the size of the play area for wrap-around purposes.

Shot objects represent shots fired by the player. Shots should only stay on the screen for a certain length of time, so they have an age counter that increments every time the shot is told to move. The main class will take care of removing the shot from the game based on this age.

Comet is an abstract class representing comets. LargeComet, MediumComet, and SmallComet all extend Comet. Large comets break into two medium comets when shot, and medium comets break into three small comets. Small comets are destroyed outright by being shot. Every comet has an explode() method that returns anArrayList containing newly created comets that are produced by their destruction, although SmallComet should return an empty ArrayList since it doesn't spawn additional comets.

Ship represents the player's spaceship. The ship has a direction that it is facing. The gun turret of the ship points to this direction. The ship’s directiondetermines the change in position when the ship accelerates, and the trajectory of the shots it fires. A ship has methods to turn left, turn right, accelerate, and fire shots. The fire() method returns a Shot object that originates from the tip of the ship’s gun turret and travels in the direction that the ship is facing, adjusted, of course, for the ship's own velocity.An important note about acceleration: Even though in real space objects can basically travel arbitrarily fast, it wouldn't be much fun if the ship travels so fast that you can't see it. Limit the maximum speed of the ship to 10 pixels per frame (i.e. per move()). That's fast enough for the game to be exciting, but not so fast that it's impossible to follow the ship.

CometsMain is already provided to you as part of this assignment. This is where the main method resides. This class is responsible for rendering of objects for the game, handling user input and managing space objectsinteractions. The classes you write MUST be compatible with CometsMain in its original form.You must not change the implementation of CometsMain.

Aninput file should be placed in the root directory of the project. This file specifies the initial layout of the comets. Each line in the file describes one comet. The string at the start of the line specifies the size of the comet ("Large", "Medium", or "Small"), the two numbers after that are the position of the comet (x and y coordinates), and the last two numbers are its velocity.

Game Constants

  • Shot radius – 3 pixels
  • Ship radius – 10 pixels
  • Large Comet radius – 40 pixels
  • Medium Comet radius – 30 pixels
  • Small Comet radius – 20 pixels
  • Ship acceleration – 0.1 pixels/frame2
  • Maximum ship speed – 10 pixels/frame
  • Ship turning rate – π/32 radians/frame
  • Shot speed – 3 pixels/frame in the direction of the ship + velocity of the ship when it was fired.
  • Ship gun turret length – 15 pixels. The turretoriginates from center of the ship and points towards the directionship is facing.

Useful Formulas

Determining if two objects overlap: Let objects one and two be at positions (x1, y1) and (x2, y2) and have radii r1 and r2, respectively. Objects one and two overlap if: See image.

Updating the position of an object: Let an object at position (x0, y0) be traveling with velocity (vx, vy). Its position (x, y) after being moved is: See image.

Accelerating the ship: Let the ship have direction θ in radians. The change in x and y velocity when accelerating is given by: See image.

If this speed is greater than 10, scale the velocity down by multiplying boththe x and y velocities by 10/s.

Firing a shot: If a shot is fired from a ship traveling at velocity (vship.x, vship.y) and facing at angle θ in radians, the resulting shot velocity should be: See image.


Create a folder with name CometsCode and put all seven java files (,,,,,, inside the folder. Then, zip the folder into file Submit as an attachment using the “Add Attachments” button. Assignments that are typed into the submission box will not be accepted. You must submit the files in a zipped folder. If you attached each java file separately, you will get points taken off.Note that the zipped folder must contain all seven source files and nothing else. The deadline for submission is posted on WebCourses.


Your code must include:

  • Header comments for each source file, with the following information: file name, your name, course number and date.
  • Inline comments throughout the code explaining its logic and design.
  • Javadoc comments are not required for this assignment.But you are free to include them.


  • Your program must compile using Java 6.0 or later. The programs will be run under Eclipse environment when grading.
  • Your implementation of the classes must conform to the specification given in the Javadoc.Even if your program runs fine, you may still lose points if you did not implement all the methods specified in the Javadoc.
  • Your classes must follow the inheritance hierarchy given in the Javadoc.
Academic Honesty!
It is not our intention to break the school's academic policy. Projects posted are only used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly fill out the form. Please provide a valid email address and we'll get back to you in less than 24 hours. We will be sending an invoice through PayPal upon confirmation. We are a non profit organization however we need an amount to keep this organization running, and to be able to complete our research and development.