Liu Liting 201199465

Dependencies:   mbed N5110

Committer:
Ting12138
Date:
Thu May 14 14:10:49 2020 +0000
Revision:
12:3b7811c3502c
llll

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Ting12138 12:3b7811c3502c 1 #ifndef ENGINE_H
Ting12138 12:3b7811c3502c 2 #define ENGINE_H
Ting12138 12:3b7811c3502c 3
Ting12138 12:3b7811c3502c 4 #include "foods.h"
Ting12138 12:3b7811c3502c 5 #include "rocket.h"
Ting12138 12:3b7811c3502c 6 #include "the_wall.h"
Ting12138 12:3b7811c3502c 7 #include "mbed.h"
Ting12138 12:3b7811c3502c 8 #include "N5110.h"
Ting12138 12:3b7811c3502c 9 #include "Gamepad.h"
Ting12138 12:3b7811c3502c 10
Ting12138 12:3b7811c3502c 11
Ting12138 12:3b7811c3502c 12
Ting12138 12:3b7811c3502c 13 class Engine
Ting12138 12:3b7811c3502c 14 {
Ting12138 12:3b7811c3502c 15
Ting12138 12:3b7811c3502c 16 public:
Ting12138 12:3b7811c3502c 17 Engine();
Ting12138 12:3b7811c3502c 18 ~Engine();
Ting12138 12:3b7811c3502c 19
Ting12138 12:3b7811c3502c 20 void read_input(Gamepad &pad);
Ting12138 12:3b7811c3502c 21 /**
Ting12138 12:3b7811c3502c 22 * @brief Draws every objects on the screen using initiate data/update data
Ting12138 12:3b7811c3502c 23 * @param N5110
Ting12138 12:3b7811c3502c 24 * @details LCD which diaplay the game
Ting12138 12:3b7811c3502c 25 */
Ting12138 12:3b7811c3502c 26 void init(int wall_width,int wall_gap,int foods_bulk,int speed);
Ting12138 12:3b7811c3502c 27 /**
Ting12138 12:3b7811c3502c 28 * @brief Reads the data input from the joystick
Ting12138 12:3b7811c3502c 29 * @param Gamepad and details Gamepad that holds the parameters of the joystick
Ting12138 12:3b7811c3502c 30 */
Ting12138 12:3b7811c3502c 31 void draw(N5110 &lcd);
Ting12138 12:3b7811c3502c 32 /**
Ting12138 12:3b7811c3502c 33 * @brief Renews positions for all the objects
Ting12138 12:3b7811c3502c 34 * @param Gamepad @details Gamepad that holds the parameters of the joystick
Ting12138 12:3b7811c3502c 35 */
Ting12138 12:3b7811c3502c 36 int get_final_score(); // get score for the incoming events
Ting12138 12:3b7811c3502c 37 void update(Gamepad &pad);
Ting12138 12:3b7811c3502c 38 /**
Ting12138 12:3b7811c3502c 39 * @brief Gets the score
Ting12138 12:3b7811c3502c 40 * @returns The number of score
Ting12138 12:3b7811c3502c 41 */
Ting12138 12:3b7811c3502c 42
Ting12138 12:3b7811c3502c 43 private:
Ting12138 12:3b7811c3502c 44 void collision(Gamepad &pad);
Ting12138 12:3b7811c3502c 45 void check_score(Gamepad &pad);
Ting12138 12:3b7811c3502c 46
Ting12138 12:3b7811c3502c 47 the_wall _w0;
Ting12138 12:3b7811c3502c 48 the_wall _w1;
Ting12138 12:3b7811c3502c 49 the_wall _w2;
Ting12138 12:3b7811c3502c 50 the_wall _w3;
Ting12138 12:3b7811c3502c 51 the_wall _w4;
Ting12138 12:3b7811c3502c 52
Ting12138 12:3b7811c3502c 53 int _wall_width;
Ting12138 12:3b7811c3502c 54 int _wall_gap;
Ting12138 12:3b7811c3502c 55 int _foods_bulk;
Ting12138 12:3b7811c3502c 56 int _velocity;
Ting12138 12:3b7811c3502c 57
Ting12138 12:3b7811c3502c 58 // x positions of the walls
Ting12138 12:3b7811c3502c 59 int _w0x;
Ting12138 12:3b7811c3502c 60 int _w1x;
Ting12138 12:3b7811c3502c 61 int _w2x;
Ting12138 12:3b7811c3502c 62 int _w3x;
Ting12138 12:3b7811c3502c 63 int _w4x;
Ting12138 12:3b7811c3502c 64 int _rocketx;
Ting12138 12:3b7811c3502c 65 int _foodsx;
Ting12138 12:3b7811c3502c 66
Ting12138 12:3b7811c3502c 67 rocket _rocket;
Ting12138 12:3b7811c3502c 68 foods _foods;
Ting12138 12:3b7811c3502c 69
Ting12138 12:3b7811c3502c 70 Direction _d;
Ting12138 12:3b7811c3502c 71 float _mag;
Ting12138 12:3b7811c3502c 72 Vector2D _mapped_coord;
Ting12138 12:3b7811c3502c 73
Ting12138 12:3b7811c3502c 74
Ting12138 12:3b7811c3502c 75 };
Ting12138 12:3b7811c3502c 76
Ting12138 12:3b7811c3502c 77 #endif