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.
Mechanics Class Reference
#include <Mechanics.h>
Public Member Functions | |
| Mechanics () | |
| Constructor. | |
| ~Mechanics () | |
| Destructor. | |
| 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 in the next gate, returns either the current gate or increases the gate. | |
| int | Get_Laps (int laps, 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. | |
| Time | Convert_To_Time (int game_fps, int number_of_frames) |
| Converts between the number of elapsed frames to time in min,sec,mili. | |
| int | Get_Angle (int angle, int handling, bool gyro_enabled, FXOS8700CQ &Gyro, Gamepad &Device) |
| Returns the current angle of rotation of the map using the previos rotation. | |
| 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. | |
| float | Get_Speed (float speed, float max_speed, float acceleration, float deceleration, float off_track_speed, Point_2D position, const Square_2D *offtrack_square, const Triangle_2D *offtrack_triangle, const Square_2D *out_of_bounds_square, const Triangle_2D *out_of_bounds_triangle, const Triangle_2D *plates, const Map_Data map_info, Gamepad &Device) |
| Returns the current speed using the previos speed. | |
| float | Get_Max_Speed (int car_model) |
| Returns the max speed for the chosen vehicle. | |
| float | Get_Acceleration (int car_model) |
| Returns the acceleration for the chosen vehicle. | |
| float | Get_Deceleration (int car_model) |
| Returns the decleration for the chosen vehicle. | |
| float | Get_Off_Road_Speed (int car_model) |
| Returns the max speed when off road for the chosen vehicle. | |
| int | Get_Handling (int car_model) |
| Returns the handling of the chosen vehicle. | |
Detailed Description
Mechanics Class.
Operates the game.
- Date:
- Mar, 2020
Definition at line 94 of file Mechanics.h.
Constructor & Destructor Documentation
| Mechanics | ( | ) |
Constructor.
Definition at line 7 of file Mechanics.cpp.
| ~Mechanics | ( | ) |
Destructor.
Definition at line 11 of file Mechanics.cpp.
Member Function Documentation
| Time Convert_To_Time | ( | int | game_fps, |
| int | number_of_frames | ||
| ) |
Converts between the number of elapsed frames to time in min,sec,mili.
- Parameters:
-
game_fps The fps of the game (int) number_of_frames The number of frames elapsed so far during the current race (int)
- Returns:
- The time in minutes, seconds, miliseconds format (Time)
Definition at line 230 of file Mechanics.cpp.
| float Get_Acceleration | ( | int | car_model ) |
Returns the acceleration for the chosen vehicle.
- Parameters:
-
car_model The chosen car model (int)
- Returns:
- The acceleration (float)
Definition at line 348 of file Mechanics.cpp.
| int Get_Angle | ( | int | angle, |
| int | handling, | ||
| bool | gyro_enabled, | ||
| FXOS8700CQ & | Gyro, | ||
| Gamepad & | Device | ||
| ) |
Returns the current angle of rotation of the map using the previos rotation.
- Parameters:
-
angle The currrent angle of roatation of the map (int) handling The maximum number of degrees of rotation for that given cars handling (int) gyro_enabled Has gyroscope steering been enabled in settings (bool) Gyro The gyroscope class object (object) Device The gamepad class object (Device)
- Returns:
- The new current angle of map rotation (int)
Definition at line 244 of file Mechanics.cpp.
| float Get_Deceleration | ( | int | car_model ) |
Returns the decleration for the chosen vehicle.
- Parameters:
-
car_model The chosen car model (int)
- Returns:
- The deceleration (float)
Definition at line 368 of file Mechanics.cpp.
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.
- Parameters:
-
gates[] The array containing all the gates (Square_2D) number_of_gates Number of gates in the array (int) position This is the current position of the player (Point_2D) current_gate The current gate that has been driven over (int)
- Returns:
- Current gate number (int)
Definition at line 188 of file Mechanics.cpp.
| int Get_Handling | ( | int | car_model ) |
Returns the handling of the chosen vehicle.
- Parameters:
-
car_model The chosen car model (int)
- Returns:
- The handling (float)
Definition at line 406 of file Mechanics.cpp.
| int Get_Laps | ( | int | laps, |
| 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.
- Parameters:
-
laps The current number of laps (int) gates[] The array containing all the gates (Square_2D) number_of_gates Number of gates in the array (int) position This is the current position of the player (Point_2D) current_gate The current gate that has been driven over (int)
- Returns:
- The new current number of laps (int)
Definition at line 209 of file Mechanics.cpp.
| float Get_Max_Speed | ( | int | car_model ) |
Returns the max speed for the chosen vehicle.
- Parameters:
-
car_model The chosen car model (int)
- Returns:
- The maximum speed (float)
Definition at line 329 of file Mechanics.cpp.
| float Get_Off_Road_Speed | ( | int | car_model ) |
Returns the max speed when off road for the chosen vehicle.
- Parameters:
-
car_model The chosen car model (int)
- Returns:
- The maximum speed when off road (float)
Definition at line 387 of file Mechanics.cpp.
| float Get_Speed | ( | float | speed, |
| float | max_speed, | ||
| float | acceleration, | ||
| float | deceleration, | ||
| float | off_track_speed, | ||
| Point_2D | position, | ||
| const Square_2D * | offtrack_square, | ||
| const Triangle_2D * | offtrack_triangle, | ||
| const Square_2D * | out_of_bounds_square, | ||
| const Triangle_2D * | out_of_bounds_triangle, | ||
| const Triangle_2D * | plates, | ||
| const Map_Data | map_info, | ||
| Gamepad & | Device | ||
| ) |
Returns the current speed using the previos speed.
- Parameters:
-
speed The currrent speed(float) max_speed The maximum speed of the chosen car (float) acceleration The acceleration of the chosen car (float) deceleration The deceleration of the chosen car (float) off_track_speed The maximum speed when off track of the chosen car (float) position The current position of the car (Point_2D) *offtrack_square The pointer for the array of square of off track areas(Square_2D) *offtrack_triangle The pointer for the array of triange of off track areas(Triangle_2D) *out_of_bounds_square The pointer for the array of square out of bounds areas(Square_2D) *out_of_bounds_triangle The pointer for the array of triange out of bounds areas(Triangle_2D) *plates The pointer for the boost plates array (Triangle_2D) map_info The number of elements in each array above (Map_Data) Device The gamepad class object (Device)
- Returns:
- The new current speed (float)
Definition at line 19 of file Mechanics.cpp.
| 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.
- Parameters:
-
in The currrent map translation(Point_2D) angle The current angle of roataion of the map [Drection of travel] (float) speed The current of the player (float) *out_of_bounds_square The pointer for the array of square out of bounds areas(Square_2D) *out_of_bounds_triangle The pointer for the array of triange out of bounds areas(Triangle_2D) map_info The number of elements in each array above (Map_Data) Device The gamepad class object (Device)
- Returns:
- The new current translation (Point_2D)
Definition at line 287 of file Mechanics.cpp.
Generated on Wed Jul 20 2022 17:42:24 by
1.7.2