“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

lib/Utils.h

Committer:
alex_20
Date:
2021-04-22
Revision:
7:559edc36f261
Parent:
4:def20a1665d1

File content as of revision 7:559edc36f261:

#ifndef UTILS_H
#define UTILS_H

#include "mbed.h"
#include "N5110.h"
#include "Vector.h"

class Utils
{
  public:
  
   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
    *   @param  y0     - y-coordinate of first point
    *   @param  x1     - x-coordinate of second point
    *   @param  y1     - y-coordinate of second point
    *   @param  x2     - x-coordinate of third point
    *   @param  y2     - y-coordinate of third point
    */
   std::vector<Vector2Df> getCurve(float const x0,
                                   float const y0,
                                   float const x1,
                                   float const y1,
                                   float const x2,
                                   float const y2);
   
};

#endif