Rally X
ELEN3009 Project by Justin Wernick and David Schneider
|
Class for creating a window on the screen. More...
#include <Screen.h>
Public Member Functions | |
Screen (unsigned int screenWidth, unsigned int screenHeight, bool fullscreen) | |
Creates a Screen with the given width and height in pixels, and the given fullscreen setting. | |
~Screen () | |
Destructor to ensure that the display and any ScreenPanels are destroyed properly. | |
string | getLevel () |
Presents the player with a file dialog, requesting a level file to be selected. | |
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. | |
bool | exitClicked () |
Function to find if the player has chosen to exit the game. | |
void | drawWin () |
Draws a splash screen when the level has been won. | |
void | drawLoss () |
Draws a splash screen when the level has been lost. | |
Private Member Functions | |
Screen (const Screen &ref) | |
Unimplemented copy constructor, prevents copying of Screen objects. | |
Screen & | operator= (const Screen &rhs) |
Unimplemented assignment operator. | |
void | flip () |
Flips the display's buffers, as well as those for all of the ScreenPanels. | |
bool | resolutionSupported () |
Checks the current resolution (_screenWidth and _screenHeight) against the screen's supported resolutions. | |
Private Attributes | |
AllegroInit | _allegro |
Ensures that Allegro has been installed, for event queues and creating the display. | |
AllegroKeyboardInit | _keyboard |
Ensures that the keyboard has been installed, for checking for the ESC key. | |
AllegroDrawingInit | _drawing |
Ensures that drawing operations have been installed, for drawing splash screens. | |
bool | _exitClicked |
Set to true when the user chooses to quit the game. | |
unsigned int | _screenWidth |
Horizontal number of pixels per row on the screen. | |
unsigned int | _screenHeight |
Vertical number of pixels per column on the screen. | |
unsigned int | _gameAreaWidth |
Width of the GamePanel created. | |
unsigned int | _infoPanelWidth |
Width of the InfoPanel created. The InfoPanel is placed directly to the right of the GamePanel. | |
ALLEGRO_DISPLAY * | _display |
The window created on the player's monitor to see the game. | |
ALLEGRO_EVENT_QUEUE * | _windowEvents |
Events caught by the screen, checked for an exit command. | |
ALLEGRO_FONT * | _font |
Font used in drawing splash screens. | |
vector< ScreenPanel * > | _panels |
Polymorphic container used to encapsulate the different types of drawing to the screen. |
Class for creating a window on the screen.
Anything involving drawing on the screen is the responsibility of this class. Most of these responsibilities are outsourced through creating ScreenPanels with more specialised tasks, such as drawing specifically the area where the gameplay takes place (GamePanel) or the providing the player with information (InfoPanel).
Screen::Screen | ( | unsigned int | screenWidth, |
unsigned int | screenHeight, | ||
bool | fullscreen | ||
) |
Creates a Screen with the given width and height in pixels, and the given fullscreen setting.
[in] | screenWidth | The width of the display that will be created in pixels. |
[in] | screenHeight | The height of the display that will be created in pixels. |
[in] | fullscreen | True if the game should be in fullscreen mode. False otherwise. |
Definition at line 3 of file Screen.cpp.
Screen::~Screen | ( | ) |
Destructor to ensure that the display and any ScreenPanels are destroyed properly.
Definition at line 52 of file Screen.cpp.
Screen::Screen | ( | const Screen & | ref | ) | [private] |
void Screen::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.
The objects are passed to each of the ScreenPanels in turn, and then the buffers are flipped.
[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. |
Definition at line 83 of file Screen.cpp.
void Screen::drawLoss | ( | ) |
Draws a splash screen when the level has been lost.
Definition at line 114 of file Screen.cpp.
void Screen::drawWin | ( | ) |
Draws a splash screen when the level has been won.
Definition at line 101 of file Screen.cpp.
bool Screen::exitClicked | ( | ) |
Function to find if the player has chosen to exit the game.
The game can be exited by clicking the x in the corner of the window, pressing the ESC key during the game, or by clicking 'cancel' on the file selection dialog.
Definition at line 127 of file Screen.cpp.
void Screen::flip | ( | ) | [private] |
Flips the display's buffers, as well as those for all of the ScreenPanels.
Definition at line 92 of file Screen.cpp.
string Screen::getLevel | ( | ) |
Presents the player with a file dialog, requesting a level file to be selected.
If the cancel button is clicked, and empty string is returned and exitClicked() will return true on its next call.
Definition at line 65 of file Screen.cpp.
Unimplemented assignment operator.
bool Screen::resolutionSupported | ( | ) | [private] |
Checks the current resolution (_screenWidth and _screenHeight) against the screen's supported resolutions.
Used to test if a fullscreen mode selection will launch without issue.
Definition at line 145 of file Screen.cpp.
AllegroInit Screen::_allegro [private] |
ALLEGRO_DISPLAY* Screen::_display [private] |
AllegroDrawingInit Screen::_drawing [private] |
bool Screen::_exitClicked [private] |
ALLEGRO_FONT* Screen::_font [private] |
unsigned int Screen::_gameAreaWidth [private] |
unsigned int Screen::_infoPanelWidth [private] |
AllegroKeyboardInit Screen::_keyboard [private] |
vector<ScreenPanel*> Screen::_panels [private] |
unsigned int Screen::_screenHeight [private] |
unsigned int Screen::_screenWidth [private] |
ALLEGRO_EVENT_QUEUE* Screen::_windowEvents [private] |