Rally X
ELEN3009 Project by Justin Wernick and David Schneider
|
Parent class for objects that are placed in the maze. More...
#include <GameObject.h>
Public Member Functions | |
GameObject (double x, double y, BitmapStore::Image image, Maze::Direction facing=Maze::UP) | |
Creates a GameObject with the given parameters. | |
double | x () const |
Provides access to the x coordinate of the object. | |
double | y () const |
Provides access to the y coordinate of the object. | |
bool | destroyed () const |
Checks if an object has been marked for destruction, for example through a collision. | |
BitmapStore::Image | image () const |
Provides access to the image that should be drawn to represent the object. | |
Maze::Direction | facing () const |
Provides access to the direction that the object is facing. | |
Protected Attributes | |
double | _x |
The x coordinate of the object's position. | |
double | _y |
The y coordinate of the object's position. | |
bool | _destroyed |
True if the object has been marked for destruction. | |
BitmapStore::Image | _image |
The bitmap that should be drawn on the screen to represent the object. | |
Maze::Direction | _facing |
The direction in which the object is facing, up, down, left, or right. |
Parent class for objects that are placed in the maze.
These objects are one maze block big. The image in the bitmap store will be drawn on the screen every frame at the Screen class's discression, being rotated to face in the 'facing' direction. Coordinates are given in terms of the Maze class's coordinate system. For example, increasing the x coordinate of an object by 1 will move it one maze block to the right. The number of pixels that this corresponds to is handled by the Screen class.
When an object is in a situation that it should be destroyed, it is marked for destruction. It is then the responsibility of the Game class to actually destroy it.
Definition at line 23 of file GameObject.h.
GameObject::GameObject | ( | double | x, |
double | y, | ||
BitmapStore::Image | image, | ||
Maze::Direction | facing = Maze::UP |
||
) |
Creates a GameObject with the given parameters.
[in] | x | The x coordinate of the new object. |
[in] | y | The y coordinate of the new object. |
[in] | image | The image that is drawn to represent the object. |
[in] | facing | The direction that the object is facing. If the object has no direction, such as with Checkpoint or Rock, the default value of Maze::UP should be used. |
Definition at line 3 of file GameObject.cpp.
bool GameObject::destroyed | ( | ) | const |
Checks if an object has been marked for destruction, for example through a collision.
Definition at line 16 of file GameObject.cpp.
Maze::Direction GameObject::facing | ( | ) | const |
Provides access to the direction that the object is facing.
Definition at line 24 of file GameObject.cpp.
BitmapStore::Image GameObject::image | ( | ) | const |
Provides access to the image that should be drawn to represent the object.
Definition at line 20 of file GameObject.cpp.
double GameObject::x | ( | ) | const |
Provides access to the x coordinate of the object.
Definition at line 8 of file GameObject.cpp.
double GameObject::y | ( | ) | const |
Provides access to the y coordinate of the object.
Definition at line 12 of file GameObject.cpp.
bool GameObject::_destroyed [protected] |
True if the object has been marked for destruction.
Definition at line 77 of file GameObject.h.
Maze::Direction GameObject::_facing [protected] |
The direction in which the object is facing, up, down, left, or right.
Definition at line 79 of file GameObject.h.
BitmapStore::Image GameObject::_image [protected] |
The bitmap that should be drawn on the screen to represent the object.
Definition at line 78 of file GameObject.h.
double GameObject::_x [protected] |
The x coordinate of the object's position.
Definition at line 75 of file GameObject.h.
double GameObject::_y [protected] |
The y coordinate of the object's position.
Definition at line 76 of file GameObject.h.