Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Think of three classes that would be used in an Asteroids game. At least one of

ID: 3661947 • Letter: T

Question

Think of three classes that would be used in an Asteroids game. At least one of these classes must have multiple instances in the game. For each of these classes, describe two attributes (instance variables) and two operations (methods). A one line, simple description is sufficient for each attribute and operation. Do not worry about all the details that would be involved in finally implementing these classes in C++. Concentrate on modeling the objects. Represent each class using the class diagram notation described during lecture. Send me your class information by drawing out a diagram as a table in Word or a set of rows in Excel or by snapping a photo of what you scribbled on paper.

If you are not familiar with Asteroids, here is a brief description:
A Player controls a spaceship using arrow keys to aim left or right as well as the spacebar which controls the thrusters. A Breakout ball bounces around the game board. Your mission is to reduce the floating asteroids down to rubble and finally dust. Each asteroid when shot breaks into two smaller ones. As you destroy asteriods, you must avoid enemy flying saucers that will try and shoot you down. The saucers come in two flavors, large and small. The large ones of course are easier to hit and are much less accurate with their lasers, while the smaller saucers are quick and accurate. Everything you hit earns you points. After clearing away all the asteriods, the player is advanced to higher and higher levels of play. The longer you last, the more levels of play you complete and the more asteriods there are to destroy. A Player is given just three spaceships in a single game.

To help you, a screen shot of Asteroids is shown below. Look at the items in the picture. Almost anything you see on the screen could be an object. Reread the above description of the game. Objects are frequently nouns in the specification of a program.

If the game is quite unfamiliar to you, try playing the game by visiting the URL:
http://www.freeasteroids.org/

For its time (1979), Asteroids quickly became the most popular arcade game in history, selling over 70,000 arcade units, in part because it was the first use of production vector graphics in an arcade game. It was so popular within the development labs at Atari that the management literally had to pull their software programmers away from the playing the prototypes so that the actual product could be finished! The developers, of course, wanted to play the game all the time!

Explanation / Answer

The three classes that can be used for creating an Asteroid game in C++ are:

The properties and methods can be as follows:

Asteroid:

Each instance of this class an asteroid visible on the screen. Every time it is hit by a bullet, it breaks up into two. Therefore, you can keep track of the current diameter of the asteroid. In addition, you need to track the location of the asteroid in terms of its x and y co-ordinates on the screen.

Therefore, attributes could be diameter, x_coord, y_coord, speed.

Methods could be move(show the current position on screen) and show (to appear on screen)

Class Diagram:

void move(int)

void show()

double diameter

int x_coord

int y_coord

Ship:

Attributes are:

speed

x_loc

y_loc

orientation

Methods:

rotate

shoot

Class diagram:

void rotate(double)

void shoot()

double speed

int x_loc

int y_loc

Class : Bullet

Attributes:

speed

x_pos

y_pos

Methods:

did_collide()

draw()

Class diagram:

  bool did_collide()

void draw()

double speed

int x_pos

int y_pos

Asteroid

void move(int)

void show()

double diameter

int x_coord

int y_coord

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote