summaryrefslogtreecommitdiff
path: root/source/presentation/InfoPanel.h
diff options
context:
space:
mode:
Diffstat (limited to 'source/presentation/InfoPanel.h')
-rw-r--r--source/presentation/InfoPanel.h140
1 files changed, 140 insertions, 0 deletions
diff --git a/source/presentation/InfoPanel.h b/source/presentation/InfoPanel.h
new file mode 100644
index 0000000..9af6a70
--- /dev/null
+++ b/source/presentation/InfoPanel.h
@@ -0,0 +1,140 @@
+#ifndef INFOPANEL_H
+#define INFOPANEL_H
+
+#include <allegro5/allegro.h>
+#include <allegro5/allegro_primitives.h>
+
+#include <sstream>
+using namespace std;
+
+#include "../presentation/ScreenPanel.h"
+#include "../presentation/ColourStore.h"
+#include "../logic/Maze.h"
+#include "../logic/GameObject.h"
+#include "../logic/PlayerCar.h"
+#include "../logic/EnemyCar.h"
+#include "../logic/Checkpoint.h"
+#include "../logic/AllegroWrappers.h"
+
+/**
+* @brief 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
+* @author David Schneider
+*/
+class InfoPanel : public ScreenPanel
+{
+ public:
+ /**
+ * @brief 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.
+ *
+ * @param [in] back The current back buffer of the display being sub-bitmapped.
+ * @param [in] front The current front buffer (image currently being displayed) of the display being sub-bitmapped.
+ * @param [in] x The x coordinate of the left side of the sub-bitmap in pixels.
+ * @param [in] y The x coordinate of the top of the sub-bitmap in pixels.
+ * @param [in] width The length in the x direction of the new sub-bitmap in pixels.
+ * @param [in] height The length in the y direction of the new sub-bitmap in pixels.
+ */
+ InfoPanel(ALLEGRO_BITMAP* back, ALLEGRO_BITMAP* front, int x, int y, int width, int height);
+
+ /**
+ * @brief Destructor that ensured that the font created is destroyed.
+ *
+ * The memory for the sub-bitmaps are handled by the parent class, ScreenPanel.
+ */
+ ~InfoPanel();
+
+ /**
+ * @brief 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.
+ *
+ * @param [in] maze The Maze that all of the objects are in.
+ * @param [in] players The list of PlayerCars to be drawn.
+ * @param [in] enemies The list of EnemyCars to be drawn.
+ * @param [in] checkpoints The list of Checkpoints to be drawn.
+ * @param [in] rocks Rocks are not actually drawn.
+ * @param [in] smokescreens Smokescreens are not actually drawn.
+ * @param [in] popups DestroyedObjectPopups are not actually drawn.
+ */
+ 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);
+ private:
+ /**
+ * @brief Copy constructor not implemented, ScreenPanels should not be copied.
+ */
+ InfoPanel(const InfoPanel& ref);
+ /**
+ * @brief Assignment operator not implemented, ScreenPanels should not be copied.
+ */
+ InfoPanel& operator=(const InfoPanel& rhs);
+ /**
+ * @brief 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.
+ *
+ * @param [in] x The game coordinate to be converted into pixels.
+ */
+ float getPanelX(const double& x) const;
+ /**
+ * @brief 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.
+ *
+ * @param [in] y The game coordinate to be converted into pixels.
+ */
+ float getPanelY(const double& y) const;
+
+ /**
+ * @brief 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.
+ *
+ * @param [in] maze The Maze to be drawn.
+ */
+ void draw(const Maze& maze);
+
+ /**
+ * @brief 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.
+ *
+ * @param [in] object The GameObject to be drawn.
+ */
+ void draw(const GameObject& object);
+
+ 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.
+};
+
+#endif // INFOPANEL_H