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

ScreenPanel to be drawn on the screen to give the player information. More...

#include <InfoPanel.h>

Inheritance diagram for InfoPanel:
ScreenPanel

List of all members.

Public Member Functions

 InfoPanel (ALLEGRO_BITMAP *back, ALLEGRO_BITMAP *front, int x, int y, int width, int height)
 Creates an InfoPanel from the given back and front buffers.
 ~InfoPanel ()
 Destructor that ensured that the font created is destroyed.
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 InfoPanel using the given objects.

Private Member Functions

 InfoPanel (const InfoPanel &ref)
 Copy constructor not implemented, ScreenPanels should not be copied.
InfoPaneloperator= (const InfoPanel &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 panel.
void draw (const GameObject &object)
 Draws a single GameObject on the panel.

Private Attributes

AllegroDrawingInit _drawing
 Handles dependencies on Allegro's primitive drawing functions.
ColourStore _colourStore
 Caches colours for drawing.
float _petrolHeadingY
 The y coordinate of the heading for the petrol guage.
float _petrolGuageY
 The y coordinate of top of the petrol guage.
float _petrolGuageHeight
 The height of the rectangle that is the petrol guage.
float _checkpointHeadingY
 The y coordinate of the heading for the number of remaining checkpoints.
float _checkpointValueY
 The y coordinate of the text stating the number of remaining checkpoints.
float _miniMazeY
 The y coordinate of the top of the Maze.
float _miniMazeHeight
 The height of the Maze.
float _miniMazeblockWidth
 The width of each Maze block being drawn.
ALLEGRO_FONT * _panelFont
 The font being used to write the headings and number of checkpoints remaining.

Detailed Description

ScreenPanel to be drawn on the screen to give the player information.

This includes the minimap, a scaled down version of the entire maze that does not scroll, with icons to represent the PlayerCar, EnemyCars, and Checkpoints. Text is drawn to show the player the number of Checkpoints that needed to be collected for victory, and a rectangle is drawn representing the amount of petrol that the PlayerCar has left.

Author:
Justin Wernick
David Schneider

Definition at line 30 of file InfoPanel.h.


Constructor & Destructor Documentation

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

Creates an InfoPanel from the given back and front buffers.

The sub-bitmaps that InfoPanel 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 InfoPanel.cpp.

InfoPanel::~InfoPanel ( )

Destructor that ensured that the font created is destroyed.

The memory for the sub-bitmaps are handled by the parent class, ScreenPanel.

Definition at line 22 of file InfoPanel.cpp.

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

Copy constructor not implemented, ScreenPanels should not be copied.


Member Function Documentation

void InfoPanel::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 InfoPanel using the given objects.

Not all of the provided objects are needed for the drawing process, but they are included to give the most general drawing case. This is to support polymorphism, where the InfoPanel can be told to draw its sub-bitmap in the same manner as any other ScreenPanel.

The scale of the minimap is determined at the beginning of each frame, so that it will always fit even if the maze is larger than on the last frame.

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]rocksRocks are not actually drawn.
[in]smokescreensSmokescreens are not actually drawn.
[in]popupsDestroyedObjectPopups are not actually drawn.

Implements ScreenPanel.

Definition at line 27 of file InfoPanel.cpp.

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

Draws a Maze on the panel.

The Maze is constructed of coloured squares. The colour of the squares is retrieved from the ColourStore.

Unlike in the GamePanel, the entire Maze is drawn.

Parameters:
[in]mazeThe Maze to be drawn.

Definition at line 71 of file InfoPanel.cpp.

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

Draws a single GameObject on the panel.

The GameObject is represented by a coloured circle in the Maze. The colour is based on the GameObject's image and is retrieved from the ColourStore.

Parameters:
[in]objectThe GameObject to be drawn.

Definition at line 96 of file InfoPanel.cpp.

float InfoPanel::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 104 of file InfoPanel.cpp.

float InfoPanel::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 108 of file InfoPanel.cpp.

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

Assignment operator not implemented, ScreenPanels should not be copied.


Member Data Documentation

The y coordinate of the heading for the number of remaining checkpoints.

Definition at line 131 of file InfoPanel.h.

The y coordinate of the text stating the number of remaining checkpoints.

Definition at line 132 of file InfoPanel.h.

Caches colours for drawing.

Definition at line 126 of file InfoPanel.h.

Handles dependencies on Allegro's primitive drawing functions.

Definition at line 125 of file InfoPanel.h.

The width of each Maze block being drawn.

Definition at line 135 of file InfoPanel.h.

float InfoPanel::_miniMazeHeight [private]

The height of the Maze.

Definition at line 134 of file InfoPanel.h.

float InfoPanel::_miniMazeY [private]

The y coordinate of the top of the Maze.

Definition at line 133 of file InfoPanel.h.

ALLEGRO_FONT* InfoPanel::_panelFont [private]

The font being used to write the headings and number of checkpoints remaining.

Definition at line 137 of file InfoPanel.h.

The height of the rectangle that is the petrol guage.

Definition at line 130 of file InfoPanel.h.

float InfoPanel::_petrolGuageY [private]

The y coordinate of top of the petrol guage.

Definition at line 129 of file InfoPanel.h.

float InfoPanel::_petrolHeadingY [private]

The y coordinate of the heading for the petrol guage.

Definition at line 128 of file InfoPanel.h.


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