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

ScreenPanel to be drawn on the screen to draw the area where the game takes place. More...

#include <GamePanel.h>

Inheritance diagram for GamePanel:
ScreenPanel

List of all members.

Public Member Functions

 GamePanel (ALLEGRO_BITMAP *back, ALLEGRO_BITMAP *front, int x, int y, int width, int height)
 Creates a GamePanel from the given back and front buffers.
virtual void draw (const Maze &maze, const list< PlayerCar > &players, const list< EnemyCar > &enemies, const list< Checkpoint > &checkpoints, const list< Rock > &rocks, const list< Smokescreen > &smokescreens, const list< DestroyedObjectPopup > &popups)
 Draws the given objects on the screen.

Private Member Functions

 GamePanel (const GamePanel &ref)
 Copy constructor not implemented, ScreenPanels should not be copied.
GamePaneloperator= (const GamePanel &rhs)
 Assignment operator not implemented, ScreenPanels should not be copied.
float getPanelX (const double &x) const
 Converts an x game coordinate value to its equivalent in pixels.
float getPanelY (const double &y) const
 Converts a y game coordinate value to its equivalent in pixels.
void draw (const Maze &maze)
 Draws a Maze on the screen.
void draw (const GameObject &object)
 Draws a single GameObject on the screen.

Private Attributes

unsigned int _mazeblockWidth
 The width of one (square) Maze block on the screen, in pixels.
float _offsetX
 The amount that drawing should be offset to the right, recalculated every frame.
float _offsetY
 The amount that drawing should be offset downwards, recalculated every frame.
BitmapStore _bitmapStore
 Used to cache ALLEGRO_BITMAPs, so that they only need to be drawn once.
AllegroInit _allegro
 Handles dependencies on Allegro.

Static Private Attributes

static const int BLOCKS_PER_ROW = 15
 The number of Maze blocks in one row shown on the panel at a time. Used to determine the scale.

Detailed Description

ScreenPanel to be drawn on the screen to draw the area where the game takes place.

This includes the scrolling maze and all of the GameObjects.

Author:
Justin Wernick
David Schneider

Definition at line 23 of file GamePanel.h.


Constructor & Destructor Documentation

GamePanel::GamePanel ( ALLEGRO_BITMAP *  back,
ALLEGRO_BITMAP *  front,
int  x,
int  y,
int  width,
int  height 
)

Creates a GamePanel from the given back and front buffers.

The sub-bitmaps that GamePanel uses are created from a rectangular region on back and front that has its top left corner at the coordinate x,y, is width long in the x direction, and height long in the y direction.

Parameters:
[in]backThe current back buffer of the display being sub-bitmapped.
[in]frontThe current front buffer (image currently being displayed) of the display being sub-bitmapped.
[in]xThe x coordinate of the left side of the sub-bitmap in pixels.
[in]yThe x coordinate of the top of the sub-bitmap in pixels.
[in]widthThe length in the x direction of the new sub-bitmap in pixels.
[in]heightThe length in the y direction of the new sub-bitmap in pixels.

Definition at line 3 of file GamePanel.cpp.

GamePanel::GamePanel ( const GamePanel ref) [private]

Copy constructor not implemented, ScreenPanels should not be copied.


Member Function Documentation

void GamePanel::draw ( const Maze maze,
const list< PlayerCar > &  players,
const list< EnemyCar > &  enemies,
const list< Checkpoint > &  checkpoints,
const list< Rock > &  rocks,
const list< Smokescreen > &  smokescreens,
const list< DestroyedObjectPopup > &  popups 
) [virtual]

Draws the given objects on the screen.

The drawing is offset so that the first entry in players is in the middle of the panel. However, the offset will never be such that the drawing area will be outside of the maze.

Parameters:
[in]mazeThe Maze that all of the objects are in.
[in]playersThe list of PlayerCars to be drawn.
[in]enemiesThe list of EnemyCars to be drawn.
[in]checkpointsThe list of Checkpoints to be drawn.
[in]rocksThe list of Rocks to be drawn.
[in]smokescreensThe list of Smokescreens to be drawn.
[in]popupsThe list of DestroyedObjectPopups to be drawn.

Implements ScreenPanel.

Definition at line 12 of file GamePanel.cpp.

void GamePanel::draw ( const Maze maze) [private]

Draws a Maze on the screen.

Bitmaps used to represent solid and non-solid parts of the Maze are stored in the BitmapStore.

Parameters:
[in]mazeThe Maze to be drawn.

Definition at line 63 of file GamePanel.cpp.

void GamePanel::draw ( const GameObject object) [private]

Draws a single GameObject on the screen.

The bitmap to be drawn is retrieved from the BitmapStore using the GameObject's image.

Parameters:
[in]objectThe GameObject to be drawn.

Definition at line 92 of file GamePanel.cpp.

float GamePanel::getPanelX ( const double &  x) const [private]

Converts an x game coordinate value to its equivalent in pixels.

Converting to the pixel coordinates happens for every object every frame. To increase performance, the parameters are passed in by constant reference instead of by value.

Parameters:
[in]xThe game coordinate to be converted into pixels.

Definition at line 126 of file GamePanel.cpp.

float GamePanel::getPanelY ( const double &  y) const [private]

Converts a y game coordinate value to its equivalent in pixels.

Converting to the pixel coordinates happens for every object every frame. To increase performance, the parameters are passed in by constant reference instead of by value.

Parameters:
[in]yThe game coordinate to be converted into pixels.

Definition at line 130 of file GamePanel.cpp.

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

Assignment operator not implemented, ScreenPanels should not be copied.


Member Data Documentation

Handles dependencies on Allegro.

Reimplemented from ScreenPanel.

Definition at line 114 of file GamePanel.h.

Used to cache ALLEGRO_BITMAPs, so that they only need to be drawn once.

Definition at line 112 of file GamePanel.h.

unsigned int GamePanel::_mazeblockWidth [private]

The width of one (square) Maze block on the screen, in pixels.

Definition at line 107 of file GamePanel.h.

float GamePanel::_offsetX [private]

The amount that drawing should be offset to the right, recalculated every frame.

Definition at line 109 of file GamePanel.h.

float GamePanel::_offsetY [private]

The amount that drawing should be offset downwards, recalculated every frame.

Definition at line 110 of file GamePanel.h.

const int GamePanel::BLOCKS_PER_ROW = 15 [static, private]

The number of Maze blocks in one row shown on the panel at a time. Used to determine the scale.

Definition at line 105 of file GamePanel.h.


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