“Race Collision” is a one player game in which a truck has to avoid “particles” that appear on the road. By the use of the joystick, the player can guide themselves through the menu system to start the game. The truck is the main element of the game and it can be moved from side to side with the joystick. The road curves randomly from time to time and the player has to be careful to keep the truck within the road boundaries. Particles appear on the screen at random positions and 4 collisions lead to the end of the game.
Dependencies: ELEC2645_JoystickLCD_LPC1768_2021
Diff: lib/Utils.h
- Revision:
- 4:def20a1665d1
- Parent:
- 3:cbe2dcca5058
- Child:
- 7:559edc36f261
diff -r cbe2dcca5058 -r def20a1665d1 lib/Utils.h --- a/lib/Utils.h Fri Mar 19 20:04:39 2021 +0000 +++ b/lib/Utils.h Sun Mar 21 17:03:59 2021 +0000 @@ -3,19 +3,25 @@ #include "mbed.h" #include "N5110.h" +#include "Vector.h" -struct Position2D { - int x; - int y; -}; - -typedef struct Vector2Df { float x; float y; } Vector2Df; - -Class Utils +class Utils { public: - /** Take points from curve + Utils(); + + /* Linear Interpolation + * This function implements the "smooth" connectivity between two points + * @param term0 - first term of the equation + * @param term1 - second term of the equation + * @param perc - percentage at which we increase: always between 0 and 1.0 + */ + float curveEquation(float const term0, + float const term1, + float perc); + + /** Take points from curve * * This function takes all the points from a curve and stores them in a vector * @param x0 - x-coordinate of first point @@ -31,13 +37,12 @@ float const y1, float const x2, float const y2); - - - float curveEquation(float const n1, - float const n2, - float perc ); - + + + private: + int _help; + }; #endif \ No newline at end of file