CS 165 Project - Asteroids

Overview

Introduced by Atari in 1979, Asteroids was one of the most successful of the first generation of arcade games and was highly influential on the video game landscape for the next decade. The basic premise of the game is that a ship moves around the screen shooting asteroids while trying not to get hit by them.

This program will be written using the same simplified OpenGL libraries as the other projects of this semester. See this link for information about how to configure your environment for OpenGL development..

Instructions

Your assignment is to create the game of asteroids. Major alterations from the original Atari game include: only one life per game, flying saucers are not required, and scoring is not required (of course, these could be opportunities to go above and beyond...).

A working version of the game is available to you at:

/home/cs165new/asteroids.out

The following shows the game in action:

Asteroids Game

Game Rules and Specification

  1. Ship
    • The ship obeys the laws of motion. When in motion, the ship will tend to stay in motion.
    • Note that the angle or orientation of the ship can be different than the direction it is traveling.
    • The right and left arrows rotate the ship 6 degrees to either direction.
    • The up arrow will increase the velocity in the direction the ship is pointed by 0.5 pixels/frame.
    • For collision detection, you can assume the ship is a circle of radius 10.
    • A drawShip function is included in the uiDraw library to assist you.
  2. Bullets
    • Pressing space bar will shoot a bullet.
    • Bullets are should start with the same velocity of the ship (speed and direction) plus 5 pixels per frame in the direction the ship is pointed. This means if the ship is traveling straight up, but pointed directly to the right, the bullet will have a velocity that is at an angle up and to the right (starting with an upward velocity from the ship, and adding to it a velocity to the right because of the direction the ship is pointed).
    • There is no limit to the number of bullets that can be fired.
    • Bullets only live for 40 frames, after which they should "die" and be removed from the game.
    • A drawDot function is included in the uiDraw library to assist you.
  3. Asteroids
    • There are 3 types of asteroids in the game:
    • Large Asteroids
      1. Moves at 1 pixel per frame, with a random initial angle.
      2. Rotates at 2 degrees per frame.
      3. For collision detection, can be treated as a circle with radius 16.
      4. If a large asteroid gets hit, it breaks apart and becomes two medium asteroids and one small one.
      5. The first medium asteroid has the same velocity as the original large one plus 1 pixel/frame in the up direction.
      6. The second medium asteroid has the same velocity as the original large one plus 1 pixel/frame in the down direction.
      7. The small asteroid has the original velocity plus 2 pixels/frame to the right.
      8. A drawLargeAsteroid function is included in the uiDraw library to assist you.
    • Medium Asteroid
      1. Rotates at 5 degrees per frame.
      2. For collision detection, can be treated as a circle with radius 8.
      3. If hit, it breaks apart and becomes two small asteroids.
      4. The small asteroid has the same velocity as the original medium one plus 3 pixel/frame to the right.
      5. The second, 3 pixels/frame to the left.
      6. A drawMediumAsteroid function is included in the uiDraw library to assist you.
    • Small Asteroid
      1. Rotates at 10 degrees per frame.
      2. For collision detection, can be treated as a circle with radius 4.
      3. If a small asteroid is hit, it is destroyed and removed from the game.
      4. A drawSmall asteroid function is included in the uiDraw library to assist you.
  4. Other game rules
    • The game begins with 5 large asteroids.
    • All elements (ship, bullets, asteroids) should "wrap" around the edges of the screen. In other words, if an object goes off the right edge of the screen, it should appear on the left edge.
    • The dimensions of the window are: (-200, -200) to (200, 200).

Architectural Design

The entire program will need to be implemented using the principles of encapsulation. Thus, you need to think about the different components (classes) that you will need in the game, and their various actions (methods) and properties (member variables). Before you start programing, you will need to produce UML class diagrams for each of the classes you will be using. Please pay special attention to the design of these components, so they can be as general-purpose as possible.

In addition, for this project you will be expected to use the principles of inheritance and polymorphism. You should identify code that is shared among classes and put it in a common base class.

Getting Started

You will use the same framework and classes that you used for MoonLander and Skeet.

With each project, you have written more of the logic of the game and (hopefully) have become more familiar with the concepts of objects interacting, the game loop, etc. At this point, using the previous projects as a guide, you will start from scratch to create your Asteroids project.

Milestones

Starting a large project like this can sometimes seem overwhelming. So to help guide you through this process, a milestone deliverable will be required at the end of each week. More detailed information is contained below, but in short these milestones will require:

Starting Code

You are provided with the same uiDraw/uiInteract functions from before. You can copy over a fresh set of these files from: /home/cs165new/asteroids/*

This contains the following:

After copying these files to your working directory, you will likely want to copy over your own Velocity class from previous assignments as a starting point. Also, while it may not completely cover all you need for asteroids, your FlyingObject class from Skeet will likely be a good start for this project as well.

You may add more files as you desire, just remember to update the makefile if you do.

Assignments

You have four weeks to complete this project, with milestone submissions due along the way. Please note that this is a challenging project that will require you to apply several new and challenging topics. If you wait until the last week, you will not have time to complete the project.

This project will be broken up into the following assignment submissions:

Expectation to Excel

As explained in more detail in the Project link above, the requirements presented here are simply a base standard. To receive up to 100% on this assignment you are expected to show creativity and excel above and beyond what is specifically required.

Hints and examples

The following examples may be helpful: