Alexandra Posta / Mbed OS ELEC2645_Race_Collision

Dependencies:   ELEC2645_JoystickLCD_LPC1768_2021

Committer:
alex_20
Date:
Thu May 06 12:04:45 2021 +0000
Revision:
9:6f060f495536
Parent:
8:1fc5e14b0db6
Race Collision for ELEC2645

Who changed what in which revision?

UserRevisionLine numberNew contents of line
alex_20 8:1fc5e14b0db6 1 #ifndef GAMEENGINE_H
alex_20 8:1fc5e14b0db6 2 #define GAMEENGINE_H
alex_20 8:1fc5e14b0db6 3
alex_20 8:1fc5e14b0db6 4 #include "mbed.h"
alex_20 8:1fc5e14b0db6 5 #include "N5110.h"
alex_20 8:1fc5e14b0db6 6 #include "Ball.h"
alex_20 8:1fc5e14b0db6 7 #include "Utils.h"
alex_20 8:1fc5e14b0db6 8 #include "Road.h"
alex_20 8:1fc5e14b0db6 9 #include "Car.h"
alex_20 9:6f060f495536 10 #include "Vector.h"
alex_20 8:1fc5e14b0db6 11
alex_20 9:6f060f495536 12 class GameEngine
alex_20 9:6f060f495536 13 {
alex_20 9:6f060f495536 14 public:
alex_20 9:6f060f495536 15
alex_20 9:6f060f495536 16 GameEngine();
alex_20 9:6f060f495536 17
alex_20 9:6f060f495536 18 /** Initialize game
alex_20 9:6f060f495536 19 * @param road_direction - set up the road as STRAIGHT (0)
alex_20 9:6f060f495536 20 * @param road_inclination - set up the inclination of the road as 0
alex_20 9:6f060f495536 21 * @param radius - set the ball radius as 4
alex_20 9:6f060f495536 22 * @param ball_path - initial the ball start position
alex_20 9:6f060f495536 23 * @param car_direction - set up the car view as STRAIGHT (0)
alex_20 9:6f060f495536 24 * @param car_magnitude - set up the car tilt as 0
alex_20 9:6f060f495536 25 * @param car_start_pos - set up the car position as 38 (right in the centre)
alex_20 9:6f060f495536 26 * @param road_offset - should increase continuously
alex_20 9:6f060f495536 27 * @param car_turn - the angle at which the car turns
alex_20 9:6f060f495536 28 * @param ball_it - the iterator that draws the ball
alex_20 9:6f060f495536 29 **/
alex_20 9:6f060f495536 30 void init(int road_direction,
alex_20 9:6f060f495536 31 int road_inclination,
alex_20 9:6f060f495536 32 int radius,
alex_20 9:6f060f495536 33 std::vector<Vector2Df> ball_path,
alex_20 9:6f060f495536 34 int car_direction,
alex_20 9:6f060f495536 35 int car_magnitude,
alex_20 9:6f060f495536 36 int car_start_pos,
alex_20 9:6f060f495536 37 float road_offset,
alex_20 9:6f060f495536 38 float car_turn,
alex_20 9:6f060f495536 39 float ball_it);
alex_20 9:6f060f495536 40
alex_20 9:6f060f495536 41 int check_collision();
alex_20 9:6f060f495536 42 void update(float car_coord);
alex_20 9:6f060f495536 43 void sign(N5110 &lcd, Road &road);
alex_20 9:6f060f495536 44 void reset_ball();
alex_20 9:6f060f495536 45 void draw(N5110 &lcd, Utils &utils);
alex_20 9:6f060f495536 46 void generate_road(float tilt);
alex_20 9:6f060f495536 47 void generate_ball(int start);
alex_20 9:6f060f495536 48
alex_20 9:6f060f495536 49
alex_20 9:6f060f495536 50 private:
alex_20 9:6f060f495536 51
alex_20 9:6f060f495536 52 Ball _ball;
alex_20 9:6f060f495536 53 Road _road;
alex_20 9:6f060f495536 54 Car _car;
alex_20 9:6f060f495536 55 Utils _utils;
alex_20 9:6f060f495536 56
alex_20 9:6f060f495536 57 float _road_offset; // Road
alex_20 9:6f060f495536 58 float _road_direction; // Road, i
alex_20 9:6f060f495536 59 int _road_inclination; // Road
alex_20 9:6f060f495536 60 float _ball_it; // Ball, it
alex_20 9:6f060f495536 61 int _radius; // Ball
alex_20 9:6f060f495536 62 std::vector<Vector2Df> _ball_path; // Ball
alex_20 9:6f060f495536 63 int _iterator; // Ball
alex_20 9:6f060f495536 64 int _car_direction; // Car
alex_20 9:6f060f495536 65 int _car_magnitude; // Car
alex_20 9:6f060f495536 66 float _car_start_pos; // Car
alex_20 9:6f060f495536 67 float _car_turn; // Car, y
alex_20 9:6f060f495536 68
alex_20 8:1fc5e14b0db6 69 };
alex_20 8:1fc5e14b0db6 70 #endif