Rally X
ELEN3009 Project by Justin Wernick and David Schneider
Public Types | Public Member Functions | Private Member Functions | Private Attributes
BitmapStore Class Reference

Class for accessing images in ALLEGRO_BITMAP format and low level drawing. More...

#include <BitmapStore.h>

List of all members.

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.
BitmapStoreoperator= (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.

Detailed Description

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.

Author:
Justin Wernick
David Schneider

Definition at line 30 of file BitmapStore.h.


Member Enumeration Documentation

Type used to define which image should be returned.

Enumerator:
PLAYER 
ENEMY 
ROCK 
CHECKPOINT 
MAZE_WALL 
MAZE_FLOOR 
SMOKE 
CRASHED_CAR 
CLAIMED_CHECKPOINT 

Definition at line 47 of file BitmapStore.h.


Constructor & Destructor Documentation

BitmapStore::BitmapStore ( unsigned int  blockWidth)

Constructor for creating a BitmapStore with a set image size.

Parameters:
[in]blockWidthThe 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.


Member Function Documentation

void BitmapStore::drawCheckpoint ( ALLEGRO_BITMAP *  canvas) [private]

Draws the image representing a checkpoint.

Parameters:
[out]canvasALLEGRO_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.

Parameters:
[out]canvasALLEGRO_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.

Parameters:
[out]canvasALLEGRO_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.

Parameters:
[out]canvasALLEGRO_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.

Parameters:
[out]canvasALLEGRO_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.

Parameters:
[out]canvasALLEGRO_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.

Parameters:
[out]canvasALLEGRO_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.

Parameters:
[out]canvasALLEGRO_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.

Parameters:
[out]canvasALLEGRO_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.

Parameters:
[in]imageImage to be returned.
Returns:
Requested image in ALLEGRO_BITMAP format.

Definition at line 25 of file BitmapStore.cpp.

BitmapStore& BitmapStore::operator= ( const BitmapStore rhs) [private]

Unimplemented assignment operator.

See also:
BitmapStore(const BitmapStore& ref);

Member Data Documentation

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.


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