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/Mechanics.h
- Committer:
- HenryWTriff
- Date:
- 2020-02-22
- Revision:
- 7:2ce6e90f6d47
- Parent:
- 6:5f76dd718dc3
- Child:
- 9:7b1093d3f03a
File content as of revision 7:2ce6e90f6d47:
#ifndef MECHANICS_H #define MECHANICS_H #include "mbed.h" #include "Gamepad.h" #include "N5110.h" #include "FXOS8700CQ.h" #include "Graphics.h" #include "Mechanics.h" #include "Menu.h" #include "LEDs.h" #include "Ghost.h" #include <string> #ifndef STRUCTS #define STRUCTS //STRUCTS struct Point_2D { float x; float y; }; struct Line_2D { Point_2D from; Point_2D to; }; struct Square_2D { Point_2D TL; Point_2D BR; }; struct Triangle_2D { Point_2D TL; Point_2D BR; int Type; }; struct Map_Data { int number_of_track_lines; int number_of_dotted_lines; int number_of_flags; int number_of_walls; int number_of_off_track_squares; int number_of_off_track_triangles; int number_of_out_of_bounds_squares; int number_of_out_of_bounds_triangles; int number_of_gates; int number_of_boost_plates; }; struct Time { int mins; int secs; int milis; }; struct Gyro_Data { float ax; float ay; float az; float mx; float my; float mz; }; struct Menu_Data { int Menu_return; bool Back; }; #endif class Mechanics { public: int Get_Gate(Square_2D gates[], int number_of_gates, Point_2D position, int current_gate); int Get_Laps(int laps, Square_2D gates[], int number_of_gates, Point_2D position, int current_gate); Time Convert_To_Time(int game_fps, int number_of_frames); 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, Square_2D *out_of_bounds_square, Triangle_2D *out_of_bounds_triangle, Map_Data map_info, Gamepad &Device); float Get_Speed( float speed, float max_speed, float acceleration, float deceleration, float off_track_speed, Point_2D position, Square_2D *offtrack_square, Triangle_2D *offtrack_triangle, Square_2D *out_of_bounds_square, Triangle_2D *out_of_bounds_triangle, Triangle_2D *plates, Map_Data map_info, Gamepad &Device ); float Get_Max_Speed(int car_model); float Get_Acceleration(int car_model); float Get_Deceleration(int car_model); float Get_Off_Road_Speed(int car_model); int Get_Handling(int car_model); private: //SPEED bool Is_Offtrack(Point_2D position, Square_2D offtrack_square[], Triangle_2D offtrack_triangle[], Map_Data map_info); bool Is_Out_Of_Bounds(Point_2D position, Square_2D offtrack_square[], Triangle_2D offtrack_triangle[], Map_Data map_info); bool Is_Offtrack_Square(Square_2D offtrack[], int size, Point_2D position); bool Is_Offtrack_Triangle(Triangle_2D offtrack[], int size, Point_2D position); bool Is_Out_Of_Bounds_Square(Square_2D out_of_bounds[], int size, Point_2D position); bool Is_Out_Of_Bounds_Triangle(Triangle_2D out_of_bounds[], int size, Point_2D position); float Get_Boost_Speed(Triangle_2D plates[], int number_of_plates, Point_2D position, float speed); }; #endif