Rally X
ELEN3009 Project by Justin Wernick and David Schneider
|
Parent class for panels that are drawn on the screen. More...
#include <ScreenPanel.h>
Public Member Functions | |
ScreenPanel (ALLEGRO_BITMAP *back, ALLEGRO_BITMAP *front, int x, int y, int width, int height) | |
Creates a ScreenPanel from the given back and front buffers. | |
virtual | ~ScreenPanel () |
Destructor to ensure that sub-bitmap memory is deallocated. | |
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)=0 |
Pure virtual method for drawing a collection of objects onto the panel. | |
virtual void | flip () |
Swaps the front and back buffers. | |
Protected Attributes | |
ALLEGRO_BITMAP * | _back |
The back buffer. Only the back buffer can be drawn to. | |
int | _width |
The width of the sub-bitmaps being drawn to in pixels. | |
int | _height |
The height of the sub-bitmaps being drawn to in pixels. | |
Static Protected Attributes | |
static const ALLEGRO_COLOR | BLANK = al_map_rgb(0,0,0) |
Colour used to clear the screen at the beginning of drawing operations. | |
Private Member Functions | |
ScreenPanel (const ScreenPanel &ref) | |
Copy constructor not implemented, ScreenPanels should not be copied. | |
ScreenPanel & | operator= (const ScreenPanel &rhs) |
Assignment operator not implemented, ScreenPanels should not be copied. | |
Private Attributes | |
AllegroInit | _allegro |
Handles dependencies on Allegro being initialised. | |
ALLEGRO_BITMAP * | _front |
The front buffer, that is currently being shown on the screen. |
Parent class for panels that are drawn on the screen.
Panels are given a sub-bitmap of the Screen bitmap, which they draw their panel specific outputs on. The ScreenPanel class is subclassed to give specific drawing functions, like drawing the Maze and GameObjects on the screen.
When the object is created, the back bitmap and front bitmap should correspond to the back and front buffers of the display respectively. This should be kept in sync by calling flip every time the display is flipped.
Definition at line 29 of file ScreenPanel.h.
ScreenPanel::ScreenPanel | ( | ALLEGRO_BITMAP * | back, |
ALLEGRO_BITMAP * | front, | ||
int | x, | ||
int | y, | ||
int | width, | ||
int | height | ||
) |
Creates a ScreenPanel from the given back and front buffers.
The sub-bitmaps that ScreenPanel 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 5 of file ScreenPanel.cpp.
ScreenPanel::~ScreenPanel | ( | ) | [virtual] |
Destructor to ensure that sub-bitmap memory is deallocated.
Definition at line 13 of file ScreenPanel.cpp.
ScreenPanel::ScreenPanel | ( | const ScreenPanel & | ref | ) | [private] |
Copy constructor not implemented, ScreenPanels should not be copied.
virtual void ScreenPanel::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 | ||
) | [pure virtual] |
Pure virtual method for drawing a collection of objects onto the panel.
Implementations do not need to draw all of the objects if it is not neccesary for the type of panel, but the interface accepts all of them to be general.
[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. |
void ScreenPanel::flip | ( | ) | [virtual] |
Swaps the front and back buffers.
This function should be called every time the display is flipped.
Definition at line 19 of file ScreenPanel.cpp.
ScreenPanel& ScreenPanel::operator= | ( | const ScreenPanel & | rhs | ) | [private] |
Assignment operator not implemented, ScreenPanels should not be copied.
AllegroInit ScreenPanel::_allegro [private] |
Handles dependencies on Allegro being initialised.
Reimplemented in GamePanel.
Definition at line 93 of file ScreenPanel.h.
ALLEGRO_BITMAP* ScreenPanel::_back [protected] |
The back buffer. Only the back buffer can be drawn to.
Definition at line 79 of file ScreenPanel.h.
ALLEGRO_BITMAP* ScreenPanel::_front [private] |
The front buffer, that is currently being shown on the screen.
Definition at line 95 of file ScreenPanel.h.
int ScreenPanel::_height [protected] |
The height of the sub-bitmaps being drawn to in pixels.
Definition at line 82 of file ScreenPanel.h.
int ScreenPanel::_width [protected] |
The width of the sub-bitmaps being drawn to in pixels.
Definition at line 81 of file ScreenPanel.h.
const ALLEGRO_COLOR ScreenPanel::BLANK = al_map_rgb(0,0,0) [static, protected] |
Colour used to clear the screen at the beginning of drawing operations.
Definition at line 77 of file ScreenPanel.h.