“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

Committer:
alex_20
Date:
Thu May 06 12:04:45 2021 +0000
Revision:
9:6f060f495536
Parent:
7:559edc36f261
Race Collision for ELEC2645

Who changed what in which revision?

UserRevisionLine numberNew contents of line
alex_20 1:2ae7a8b01771 1 #ifndef UTILS_H
alex_20 1:2ae7a8b01771 2 #define UTILS_H
alex_20 1:2ae7a8b01771 3
alex_20 3:cbe2dcca5058 4 #include "mbed.h"
alex_20 3:cbe2dcca5058 5 #include "N5110.h"
alex_20 4:def20a1665d1 6 #include "Vector.h"
alex_20 3:cbe2dcca5058 7
alex_20 4:def20a1665d1 8 class Utils
alex_20 3:cbe2dcca5058 9 {
alex_20 3:cbe2dcca5058 10 public:
alex_20 3:cbe2dcca5058 11
alex_20 4:def20a1665d1 12 Utils();
alex_20 4:def20a1665d1 13
alex_20 4:def20a1665d1 14 /* Linear Interpolation
alex_20 4:def20a1665d1 15 * This function implements the "smooth" connectivity between two points
alex_20 4:def20a1665d1 16 * @param term0 - first term of the equation
alex_20 4:def20a1665d1 17 * @param term1 - second term of the equation
alex_20 4:def20a1665d1 18 * @param perc - percentage at which we increase: always between 0 and 1.0
alex_20 4:def20a1665d1 19 */
alex_20 4:def20a1665d1 20 float curveEquation(float const term0,
alex_20 4:def20a1665d1 21 float const term1,
alex_20 4:def20a1665d1 22 float perc);
alex_20 4:def20a1665d1 23
alex_20 4:def20a1665d1 24 /** Take points from curve
alex_20 3:cbe2dcca5058 25 *
alex_20 3:cbe2dcca5058 26 * This function takes all the points from a curve and stores them in a vector
alex_20 3:cbe2dcca5058 27 * @param x0 - x-coordinate of first point
alex_20 3:cbe2dcca5058 28 * @param y0 - y-coordinate of first point
alex_20 3:cbe2dcca5058 29 * @param x1 - x-coordinate of second point
alex_20 3:cbe2dcca5058 30 * @param y1 - y-coordinate of second point
alex_20 3:cbe2dcca5058 31 * @param x2 - x-coordinate of third point
alex_20 3:cbe2dcca5058 32 * @param y2 - y-coordinate of third point
alex_20 3:cbe2dcca5058 33 */
alex_20 3:cbe2dcca5058 34 std::vector<Vector2Df> getCurve(float const x0,
alex_20 3:cbe2dcca5058 35 float const y0,
alex_20 3:cbe2dcca5058 36 float const x1,
alex_20 3:cbe2dcca5058 37 float const y1,
alex_20 3:cbe2dcca5058 38 float const x2,
alex_20 3:cbe2dcca5058 39 float const y2);
alex_20 4:def20a1665d1 40
alex_20 1:2ae7a8b01771 41 };
alex_20 1:2ae7a8b01771 42
alex_20 1:2ae7a8b01771 43 #endif