Rally X
ELEN3009 Project by Justin Wernick and David Schneider
Public Member Functions | Protected Attributes
GameObject Class Reference

Parent class for objects that are placed in the maze. More...

#include <GameObject.h>

Inheritance diagram for GameObject:
Car Checkpoint LimitedTimeObject Rock EnemyCar PlayerCar DestroyedObjectPopup Smokescreen

List of all members.

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.

Detailed Description

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.

Author:
Justin Wernick
David Schneider

Definition at line 23 of file GameObject.h.


Constructor & Destructor Documentation

GameObject::GameObject ( double  x,
double  y,
BitmapStore::Image  image,
Maze::Direction  facing = Maze::UP 
)

Creates a GameObject with the given parameters.

Parameters:
[in]xThe x coordinate of the new object.
[in]yThe y coordinate of the new object.
[in]imageThe image that is drawn to represent the object.
[in]facingThe 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.


Member Function Documentation

bool GameObject::destroyed ( ) const

Checks if an object has been marked for destruction, for example through a collision.

Returns:
True is the object has been marked for destruction, false otherwise.

Definition at line 16 of file GameObject.cpp.

Maze::Direction GameObject::facing ( ) const

Provides access to the direction that the object is facing.

Returns:
A direction, corresponding to the rotation that should be done to the drawn image and, in the case of Cars, the direction that they move forward.

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.

Returns:
An image, corresponding to an enumerated type that can be converted into a bitmap by the BitmapStore class.

Definition at line 20 of file GameObject.cpp.

double GameObject::x ( ) const

Provides access to the x coordinate of the object.

Returns:
The x coordinate of the object, in maze blocks, where 0 is the far left column of the maze.

Definition at line 8 of file GameObject.cpp.

double GameObject::y ( ) const

Provides access to the y coordinate of the object.

Returns:
The y coordinate of the object, in maze blocks, where 0 is the top row of the maze.

Definition at line 12 of file GameObject.cpp.


Member Data Documentation

bool GameObject::_destroyed [protected]

True if the object has been marked for destruction.

Definition at line 77 of file GameObject.h.

The direction in which the object is facing, up, down, left, or right.

Definition at line 79 of file GameObject.h.

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.


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator