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.
Diff: Mechanics/Mechanics.h
- Revision:
- 19:0245df53e919
- Parent:
- 11:7b12992156de
- Child:
- 20:f8d7b04471b8
--- a/Mechanics/Mechanics.h Sat Mar 28 13:08:30 2020 +0000 +++ b/Mechanics/Mechanics.h Sat Mar 28 14:25:37 2020 +0000 @@ -12,6 +12,12 @@ #include "Ghost.h" #include <string> +/** Mechanics Class +* @brief Operates the game. +* @author Henry W Triff +* @date Mar, 2020 +*/ + #ifndef STRUCTS #define STRUCTS @@ -74,13 +80,78 @@ class Mechanics { public: + /** Checks the current position of the player to see if they are in the next gate, returns either the current gate or increases the gate + * @param gates[] The array containing all the gates (Square_2D) + * @param number_of_gates Number of gates in the array (int) + * @param position This is the current position of the player (Point_2D) + * @param current_gate The current gate that has been driven over (int) + * @return Current gate number (int) + */ int Get_Gate(const Square_2D gates[], int number_of_gates, Point_2D position, int current_gate); + + /** Checks the current position of the player to see if they are about to complete a lap + * @param laps The current number of laps (int) + * @param gates[] The array containing all the gates (Square_2D) + * @param number_of_gates Number of gates in the array (int) + * @param position This is the current position of the player (Point_2D) + * @param current_gate The current gate that has been driven over (int) + * @return The new current number of laps (int) + */ int Get_Laps(int laps, const Square_2D gates[], int number_of_gates, Point_2D position, int current_gate); + /** Converts between the number of elapsed frames to time in min,sec,mili + * @param game_fps The fps of the game (int) + * @param number_of_frames The number of frames elapsed so far during the current race (int) + * @return The time in minutes, seconds, miliseconds format (Time) + */ Time Convert_To_Time(int game_fps, int number_of_frames); + + /** Returns the current angle of rotation of the map using the previos rotation + * @param angle The currrent angle of roatation of the map (int) + * @param handling The maximum number of degrees of rotation for that given cars handling (int) + * @param gyro_enabled Has gyroscope steering been enabled in settings (bool) + * @param Gyro The gyroscope class object (object) + * @param Device The gamepad class object (Device) + * @return The new current angle of map rotation (int) + */ int Get_Angle(int angle, int handling, bool gyro_enabled, FXOS8700CQ &Gyro, Gamepad &Device); - Point_2D Get_Translation(Point_2D in, float angle, float speed, const Square_2D *out_of_bounds_square, const Triangle_2D *out_of_bounds_triangle, const Map_Data map_info, Gamepad &Device); + /** Returns the current map translation usung the previos translation + * @param in The currrent map translation(Point_2D) + * @param angle The current angle of roataion of the map [Drection of travel] (float) + * @param speed The current of the player (float) + * @param *out_of_bounds_square The pointer for the array of square out of bounds areas(Square_2D) + * @param *out_of_bounds_triangle The pointer for the array of triange out of bounds areas(Triangle_2D) + * @param map_info The number of elements in each array above (Map_Data) + * @param Device The gamepad class object (Device) + * @return The new current translation (Point_2D) + */ + Point_2D Get_Translation( + Point_2D in, + float angle, + float speed, + const Square_2D *out_of_bounds_square, + const Triangle_2D *out_of_bounds_triangle, + const Map_Data map_info, + Gamepad &Device + ); + + /** Returns the current speed using the previos speed + * @param speed The currrent speed(float) + * @param max_speed The maximum speed of the chosen car (float) + * @param acceleration The acceleration of the chosen car (float) + * @param deceleration The deceleration of the chosen car (float) + * @param off_track_speed The maximum speed when off track of the chosen car (float) + * @param position The current position of the car (Point_2D) + * @param *offtrack_square The pointer for the array of square of off track areas(Square_2D) + * @param *offtrack_triangle The pointer for the array of triange of off track areas(Triangle_2D) + * @param *out_of_bounds_square The pointer for the array of square out of bounds areas(Square_2D) + * @param *out_of_bounds_triangle The pointer for the array of triange out of bounds areas(Triangle_2D) + * @param *plates The pointer for the boost plates array (Triangle_2D) + * @param map_info The number of elements in each array above (Map_Data) + * @param Device The gamepad class object (Device) + * @return The new current speed (float) + */ float Get_Speed( float speed, float max_speed, @@ -97,10 +168,34 @@ Gamepad &Device ); + /** Returns the max speed for the chosen vehicle + * @param car_model The chosen car model (int) + * @return The maximum speed (float) + */ float Get_Max_Speed(int car_model); + + /** Returns the acceleration for the chosen vehicle + * @param car_model The chosen car model (int) + * @return The acceleration (float) + */ float Get_Acceleration(int car_model); + + /** Returns the decleration for the chosen vehicle + * @param car_model The chosen car model (int) + * @return The deceleration (float) + */ float Get_Deceleration(int car_model); + + /** Returns the max speed when off road for the chosen vehicle + * @param car_model The chosen car model (int) + * @return The maximum speed when off road (float) + */ float Get_Off_Road_Speed(int car_model); + + /** Returns the handling of the chosen vehicle + * @param car_model The chosen car model (int) + * @return The handling (float) + */ int Get_Handling(int car_model); private: