Henry Triff / Mbed 2 deprecated ELEC2645_Project_el18ht

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Mechanics Class Reference

Mechanics Class Reference

Mechanics Class. More...

#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.

Author:
Henry W Triff
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_fpsThe fps of the game (int)
number_of_framesThe 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_modelThe 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:
angleThe currrent angle of roatation of the map (int)
handlingThe maximum number of degrees of rotation for that given cars handling (int)
gyro_enabledHas gyroscope steering been enabled in settings (bool)
GyroThe gyroscope class object (object)
DeviceThe 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_modelThe chosen car model (int)
Returns:
The deceleration (float)

Definition at line 368 of file Mechanics.cpp.

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.

Parameters:
gates[]The array containing all the gates (Square_2D)
number_of_gatesNumber of gates in the array (int)
positionThis is the current position of the player (Point_2D)
current_gateThe 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_modelThe 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:
lapsThe current number of laps (int)
gates[]The array containing all the gates (Square_2D)
number_of_gatesNumber of gates in the array (int)
positionThis is the current position of the player (Point_2D)
current_gateThe 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_modelThe 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_modelThe 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:
speedThe currrent speed(float)
max_speedThe maximum speed of the chosen car (float)
accelerationThe acceleration of the chosen car (float)
decelerationThe deceleration of the chosen car (float)
off_track_speedThe maximum speed when off track of the chosen car (float)
positionThe current position of the car (Point_2D)
*offtrack_squareThe pointer for the array of square of off track areas(Square_2D)
*offtrack_triangleThe pointer for the array of triange of off track areas(Triangle_2D)
*out_of_bounds_squareThe pointer for the array of square out of bounds areas(Square_2D)
*out_of_bounds_triangleThe pointer for the array of triange out of bounds areas(Triangle_2D)
*platesThe pointer for the boost plates array (Triangle_2D)
map_infoThe number of elements in each array above (Map_Data)
DeviceThe 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:
inThe currrent map translation(Point_2D)
angleThe current angle of roataion of the map [Drection of travel] (float)
speedThe current of the player (float)
*out_of_bounds_squareThe pointer for the array of square out of bounds areas(Square_2D)
*out_of_bounds_triangleThe pointer for the array of triange out of bounds areas(Triangle_2D)
map_infoThe number of elements in each array above (Map_Data)
DeviceThe gamepad class object (Device)
Returns:
The new current translation (Point_2D)

Definition at line 287 of file Mechanics.cpp.