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
GameEngine/engine.h
- Committer:
- batJoro
- Date:
- 2019-05-10
- Revision:
- 12:bc9a43f56261
- Parent:
- 11:0e6a221ad8a9
File content as of revision 12:bc9a43f56261:
#ifndef ENGINE_H #define ENGINE_H #include "mbed.h" #include "N5110.h" #include "Gamepad.h" #include "functions.h" #include "car.h" #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; }; /** 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, int leftGrass, 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: Car car; Map map; float _curvature; vector<MapSegment> track; // fields: curvature distance int _screen_height; /**<int screen height */ int _screen_width; /**<int screen width */ int _lap; /**<int counter for the laps */ float _track_curvature; /**<float variable helping for calulating road curvature */ float _track_distance; /**<float he length of the track */ float _lap_time; /**<float lap time */ }; #endif