Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: GameEngine/engine.h
- Revision:
- 11:0e6a221ad8a9
- Parent:
- 10:b939edd9b87c
- Child:
- 12:bc9a43f56261
--- a/GameEngine/engine.h Fri May 10 12:00:30 2019 +0000
+++ b/GameEngine/engine.h Fri May 10 13:58:51 2019 +0000
@@ -10,27 +10,85 @@
#include "map.h"
#include <vector>
-
+/** MapSegment structure
+@author Dobri Tsvetkov, University of Leeds
+@brief C++ struct to define part of the map
+@date May 2019
+*/
struct MapSegment {
-
- float curvature;
- float meters;
-};
+ float curvature;
+ float meters;
+ };
+/** Engine Class
+@author Dobri Tsvetkov, University of Leeds
+@brief C++ class to help facilitate the realtion between the car and the road
+@date May 2019
+*/
class Engine{
public:
+ /**
+ @brief Constructor
+ @param None
+ @details
+ */
Engine();
+ /**
+ @brief Destructor
+ @param None
+ @details
+ */
~Engine();
+ /**
+ @brief Sets screen parameters and initial speed
+ @param int screenHeight, int screenWidth, int speed
+ @details
+ */
void init(int screenHeight, int screenWidth, int speed);
+ /**
+ @brief Reads input
+ @param Gamepad &pad, float elapsedTime
+ @details It sets the fields of the car and map object as well
+ */
void read_input(Gamepad &pad, float elapsedTime);
+ /**
+ @brief Updates the picture
+ @param Gamepad &pad, N5110 &lcd, float elapsedTime
+ @details It uses some maths and car and map objects to draw the picture
+ */
void update(Gamepad &pad, N5110 &lcd, float elapsedTime);
+ /**
+ @brief Draws the whole picture
+ @param N5110 &lcd
+ @details
+ */
void draw(N5110 &lcd);
+ /**
+ @brief Adds segment to the map
+ @param N5110 &lcd
+ @details
+ */
void addSegment(float curvature, float meters);
+ /**
+ @brief Adds the distance of the segments to _track_distance
+ @param None
+ @details
+ */
void calc_track_distance();
-
+ /**
+ @brief Decides whether or not to light up a pixel based on road parameters
+ @param N5110 &lcd, int x, int y, int row,
+ * float SideColour,
+ * float GrassColour,
+ * int leftGrass,
+ * int rightGrass,
+ * int leftSide,
+ * int rightSide
+ @details
+ */
void assignPixel(N5110 &lcd, int x, int y, int row,
float SideColour,
float GrassColour,
@@ -38,9 +96,23 @@
int rightGrass,
int leftSide,
int rightSide);
-
+ /**
+ @brief Uses sin fuction to make the ilusion of distance and moving
+ @param N5110 &lcd, Car &car, float frequency, float perspective
+ @details
+ */
float defineStripes(N5110 &lcd, Car &car, float frequency, float perspective);
+ /**
+ @brief Lap accessot
+ @param None
+ @details return int _lap
+ */
int get_lap();
+ /**
+ @brief _lap_time accessot
+ @param None
+ @details return float _lap_time
+ */
float get_lap_time();
private: