Rally X
ELEN3009 Project by Justin Wernick and David Schneider
|
ScreenPanel to be drawn on the screen to draw the area where the game takes place. More...
#include <GamePanel.h>
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. | |
GamePanel & | operator= (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. |
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.
Definition at line 23 of file GamePanel.h.
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.
[in] | back | The current back buffer of the display being sub-bitmapped. |
[in] | front | The current front buffer (image currently being displayed) of the display being sub-bitmapped. |
[in] | x | The x coordinate of the left side of the sub-bitmap in pixels. |
[in] | y | The x coordinate of the top of the sub-bitmap in pixels. |
[in] | width | The length in the x direction of the new sub-bitmap in pixels. |
[in] | height | The 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.
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.
[in] | maze | The Maze that all of the objects are in. |
[in] | players | The list of PlayerCars to be drawn. |
[in] | enemies | The list of EnemyCars to be drawn. |
[in] | checkpoints | The list of Checkpoints to be drawn. |
[in] | rocks | The list of Rocks to be drawn. |
[in] | smokescreens | The list of Smokescreens to be drawn. |
[in] | popups | The 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.
[in] | maze | The 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.
[in] | object | The 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.
[in] | x | The 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.
[in] | y | The game coordinate to be converted into pixels. |
Definition at line 130 of file GamePanel.cpp.
Assignment operator not implemented, ScreenPanels should not be copied.
AllegroInit GamePanel::_allegro [private] |
Handles dependencies on Allegro.
Reimplemented from ScreenPanel.
Definition at line 114 of file GamePanel.h.
BitmapStore GamePanel::_bitmapStore [private] |
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.