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:
- 5:2d9f3c36bcb9
- Child:
- 6:5f76dd718dc3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Mechanics/Mechanics.h Tue Feb 11 17:28:56 2020 +0000 @@ -0,0 +1,64 @@ +#ifndef MECHANICS_H +#define MECHANICS_H + +#include "mbed.h" +#include "Gamepad.h" +#include "N5110.h" +#include "Graphics.h" +#include "Controls.h" + + +#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; +}; + +#endif + +class Mechanics +{ + public: + 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); + 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); + + private: + 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); + +}; + +#endif \ No newline at end of file