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

Parent class for panels that are drawn on the screen. More...

#include <ScreenPanel.h>

Inheritance diagram for ScreenPanel:
GamePanel InfoPanel

List of all members.

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

Detailed Description

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.

Author:
Justin Wernick
David Schneider

Definition at line 29 of file ScreenPanel.h.


Constructor & Destructor Documentation

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.

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 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.


Member Function Documentation

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.

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.

Implemented in InfoPanel, and GamePanel.

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.


Member Data Documentation

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.


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