Rally X
ELEN3009 Project by Justin Wernick and David Schneider
|
Class for accessing images in ALLEGRO_BITMAP format and low level drawing. More...
#include <BitmapStore.h>
Public Types | |
enum | Image { PLAYER, ENEMY, ROCK, CHECKPOINT, MAZE_WALL, MAZE_FLOOR, SMOKE, CRASHED_CAR, CLAIMED_CHECKPOINT } |
Type used to define which image should be returned. More... | |
Public Member Functions | |
BitmapStore (unsigned int blockWidth) | |
Constructor for creating a BitmapStore with a set image size. | |
~BitmapStore () | |
Destructor for clearing cache. | |
ALLEGRO_BITMAP * | getBitmap (Image image) |
Function to get image for drawing to the screen. | |
Private Member Functions | |
BitmapStore (const BitmapStore &ref) | |
Unimplemented copy constructor, prevents copying of BitmapStore objects. | |
BitmapStore & | operator= (const BitmapStore &rhs) |
Unimplemented assignment operator. | |
void | drawPlayerCar (ALLEGRO_BITMAP *canvas) |
Draws the image representing the player. | |
void | drawEnemyCar (ALLEGRO_BITMAP *canvas) |
Draws the image representing an enemy. | |
void | drawRock (ALLEGRO_BITMAP *canvas) |
Draws the image representing a rock. | |
void | drawCheckpoint (ALLEGRO_BITMAP *canvas) |
Draws the image representing a checkpoint. | |
void | drawMazeWall (ALLEGRO_BITMAP *canvas) |
Draws the image representing a solid part of the maze. | |
void | drawMazeFloor (ALLEGRO_BITMAP *canvas) |
Draws the image representing a non-solid part of the maze. | |
void | drawSmoke (ALLEGRO_BITMAP *canvas) |
Draws the image representing a smokescreen. | |
void | drawCrashedCar (ALLEGRO_BITMAP *canvas) |
Draws the popup that appears when a car crashes. | |
void | drawClaimedCheckpoint (ALLEGRO_BITMAP *canvas) |
Draws the popup that appears when a checkpoint is collected. | |
Private Attributes | |
AllegroDrawingInit | _drawingInstalls |
Ensures that Allegro is initialized while an object of this class exists. | |
ALLEGRO_FONT * | _bitmapFont |
Font used for writing text on bitmaps. | |
map< Image, ALLEGRO_BITMAP * > | _bitmaps |
map containing pairs of Images (the enumerated type) and the actual images. | |
unsigned int | _blockWidth |
The width of a square image in the store. |
Class for accessing images in ALLEGRO_BITMAP format and low level drawing.
The store ensures that only one copy of identical images are created. This is done through a map, that caches the images that have already been requested. If an uncached image is requested, it is added to the cache before being returned. The store provides an enumerated type, Image, for other classes to reference which image should represent the object on the screen.
All images are square, to allow easy rotation and placement on the screen.
Definition at line 30 of file BitmapStore.h.
enum BitmapStore::Image |
Type used to define which image should be returned.
Definition at line 47 of file BitmapStore.h.
BitmapStore::BitmapStore | ( | unsigned int | blockWidth | ) |
Constructor for creating a BitmapStore with a set image size.
[in] | blockWidth | The width (and height) of an image returned by the store in pixels. |
Definition at line 3 of file BitmapStore.cpp.
BitmapStore::~BitmapStore | ( | ) |
Destructor for clearing cache.
Definition at line 14 of file BitmapStore.cpp.
BitmapStore::BitmapStore | ( | const BitmapStore & | ref | ) | [private] |
Unimplemented copy constructor, prevents copying of BitmapStore objects.
Copying a BitmapStore is unneccesary as there should only be a single BitmapStore object.
void BitmapStore::drawCheckpoint | ( | ALLEGRO_BITMAP * | canvas | ) | [private] |
Draws the image representing a checkpoint.
[out] | canvas | ALLEGRO_BITMAP onto which the image is drawn. |
Definition at line 155 of file BitmapStore.cpp.
void BitmapStore::drawClaimedCheckpoint | ( | ALLEGRO_BITMAP * | canvas | ) | [private] |
Draws the popup that appears when a checkpoint is collected.
[out] | canvas | ALLEGRO_BITMAP onto which the image is drawn. |
Definition at line 229 of file BitmapStore.cpp.
void BitmapStore::drawCrashedCar | ( | ALLEGRO_BITMAP * | canvas | ) | [private] |
Draws the popup that appears when a car crashes.
[out] | canvas | ALLEGRO_BITMAP onto which the image is drawn. |
Definition at line 208 of file BitmapStore.cpp.
void BitmapStore::drawEnemyCar | ( | ALLEGRO_BITMAP * | canvas | ) | [private] |
Draws the image representing an enemy.
[out] | canvas | ALLEGRO_BITMAP onto which the image is drawn. |
Definition at line 105 of file BitmapStore.cpp.
void BitmapStore::drawMazeFloor | ( | ALLEGRO_BITMAP * | canvas | ) | [private] |
Draws the image representing a non-solid part of the maze.
[out] | canvas | ALLEGRO_BITMAP onto which the image is drawn. |
Definition at line 179 of file BitmapStore.cpp.
void BitmapStore::drawMazeWall | ( | ALLEGRO_BITMAP * | canvas | ) | [private] |
Draws the image representing a solid part of the maze.
[out] | canvas | ALLEGRO_BITMAP onto which the image is drawn. |
Definition at line 169 of file BitmapStore.cpp.
void BitmapStore::drawPlayerCar | ( | ALLEGRO_BITMAP * | canvas | ) | [private] |
Draws the image representing the player.
[out] | canvas | ALLEGRO_BITMAP onto which the image is drawn. |
Definition at line 71 of file BitmapStore.cpp.
void BitmapStore::drawRock | ( | ALLEGRO_BITMAP * | canvas | ) | [private] |
Draws the image representing a rock.
[out] | canvas | ALLEGRO_BITMAP onto which the image is drawn. |
Definition at line 139 of file BitmapStore.cpp.
void BitmapStore::drawSmoke | ( | ALLEGRO_BITMAP * | canvas | ) | [private] |
Draws the image representing a smokescreen.
[out] | canvas | ALLEGRO_BITMAP onto which the image is drawn. |
Definition at line 189 of file BitmapStore.cpp.
ALLEGRO_BITMAP * BitmapStore::getBitmap | ( | Image | image | ) |
Function to get image for drawing to the screen.
[in] | image | Image to be returned. |
Definition at line 25 of file BitmapStore.cpp.
BitmapStore& BitmapStore::operator= | ( | const BitmapStore & | rhs | ) | [private] |
Unimplemented assignment operator.
ALLEGRO_FONT* BitmapStore::_bitmapFont [private] |
Font used for writing text on bitmaps.
Definition at line 128 of file BitmapStore.h.
map<Image, ALLEGRO_BITMAP*> BitmapStore::_bitmaps [private] |
map containing pairs of Images (the enumerated type) and the actual images.
Creates a cache for images once they have been drawn.
Definition at line 135 of file BitmapStore.h.
unsigned int BitmapStore::_blockWidth [private] |
The width of a square image in the store.
Definition at line 137 of file BitmapStore.h.
Ensures that Allegro is initialized while an object of this class exists.
Definition at line 126 of file BitmapStore.h.