Zikang Qian / Mbed 2 deprecated el17z2q

Dependencies:   mbed

Fork of el17z2q by ELEC2645 (2017/18)

Committer:
yzjdxl
Date:
Mon May 07 22:11:43 2018 +0000
Branch:
GameEngine
Revision:
2:6dc7bc55c1cb
Parent:
1:00a4ea97c4cd
publish

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yzjdxl 1:00a4ea97c4cd 1 #ifndef GAMEENGINE_H
yzjdxl 1:00a4ea97c4cd 2 #define GAMEENGINE_H
yzjdxl 1:00a4ea97c4cd 3
yzjdxl 1:00a4ea97c4cd 4 #include "mbed.h"
yzjdxl 1:00a4ea97c4cd 5 #include "N5110.h"
yzjdxl 1:00a4ea97c4cd 6 #include "Gamepad.h"
yzjdxl 1:00a4ea97c4cd 7 #include "Coin.h"
yzjdxl 1:00a4ea97c4cd 8 #include "Bag.h"
yzjdxl 1:00a4ea97c4cd 9
yzjdxl 1:00a4ea97c4cd 10 /** GameEngine Class
yzjdxl 1:00a4ea97c4cd 11 * @brief Judge the situation of adding score or gameover
yzjdxl 1:00a4ea97c4cd 12 * @author Zikang Qian
yzjdxl 1:00a4ea97c4cd 13 * @date April, 2018
yzjdxl 1:00a4ea97c4cd 14 */
yzjdxl 1:00a4ea97c4cd 15
yzjdxl 1:00a4ea97c4cd 16 class GameEngine
yzjdxl 1:00a4ea97c4cd 17 {
yzjdxl 1:00a4ea97c4cd 18
yzjdxl 1:00a4ea97c4cd 19 public:
yzjdxl 1:00a4ea97c4cd 20
yzjdxl 1:00a4ea97c4cd 21 /** Constructor */
yzjdxl 1:00a4ea97c4cd 22 GameEngine();
yzjdxl 1:00a4ea97c4cd 23
yzjdxl 1:00a4ea97c4cd 24 /** Destructor */
yzjdxl 1:00a4ea97c4cd 25 ~GameEngine();
yzjdxl 1:00a4ea97c4cd 26
yzjdxl 1:00a4ea97c4cd 27 /** Initiate the bag size, coin size and speed
yzjdxl 1:00a4ea97c4cd 28 * @param the value of the bag width (int),bag height (int),coin size (int) and speed (int)
yzjdxl 1:00a4ea97c4cd 29 */
yzjdxl 1:00a4ea97c4cd 30 void init(int bag_width,int bag_height,int coin_size,int speed);
yzjdxl 1:00a4ea97c4cd 31
yzjdxl 1:00a4ea97c4cd 32 /** Get the input information from the gamepad
yzjdxl 1:00a4ea97c4cd 33 * @param the input of gamepad (pad)
yzjdxl 1:00a4ea97c4cd 34 */
yzjdxl 1:00a4ea97c4cd 35 void read_input(Gamepad &pad);
yzjdxl 1:00a4ea97c4cd 36
yzjdxl 1:00a4ea97c4cd 37 /** Output the information from the gamepad
yzjdxl 1:00a4ea97c4cd 38 * @return the input of gamepad (pad)
yzjdxl 1:00a4ea97c4cd 39 */
yzjdxl 1:00a4ea97c4cd 40 int update(Gamepad &pad);
yzjdxl 1:00a4ea97c4cd 41
yzjdxl 1:00a4ea97c4cd 42 /** Show both bag and coin figure on screen
yzjdxl 1:00a4ea97c4cd 43 * @param the figrue (lcd)
yzjdxl 1:00a4ea97c4cd 44 */
yzjdxl 1:00a4ea97c4cd 45 void draw(N5110 &lcd);
yzjdxl 1:00a4ea97c4cd 46
yzjdxl 1:00a4ea97c4cd 47 private:
yzjdxl 1:00a4ea97c4cd 48
yzjdxl 1:00a4ea97c4cd 49 /** Add score case
yzjdxl 1:00a4ea97c4cd 50 * @param input of gamepad (pad)
yzjdxl 1:00a4ea97c4cd 51 */
yzjdxl 1:00a4ea97c4cd 52 void check_bag_collisions(Gamepad &pad);
yzjdxl 1:00a4ea97c4cd 53
yzjdxl 1:00a4ea97c4cd 54 /** Game over case
yzjdxl 1:00a4ea97c4cd 55 * @param input of gamepad (pad)
yzjdxl 1:00a4ea97c4cd 56 */
yzjdxl 1:00a4ea97c4cd 57 void game_over(Gamepad &pad);
yzjdxl 1:00a4ea97c4cd 58
yzjdxl 1:00a4ea97c4cd 59 /** Game over case
yzjdxl 1:00a4ea97c4cd 60 * @param input of gamepad (pad)
yzjdxl 1:00a4ea97c4cd 61 */
yzjdxl 1:00a4ea97c4cd 62 void print_scores(N5110 &lcd);
yzjdxl 1:00a4ea97c4cd 63
yzjdxl 1:00a4ea97c4cd 64 Bag _bag;
yzjdxl 1:00a4ea97c4cd 65 Coin _coin;
yzjdxl 1:00a4ea97c4cd 66 Direction _direction;
yzjdxl 1:00a4ea97c4cd 67
yzjdxl 1:00a4ea97c4cd 68 int _bag_width;
yzjdxl 1:00a4ea97c4cd 69 int _bag_height;
yzjdxl 1:00a4ea97c4cd 70 int _coin_size;
yzjdxl 1:00a4ea97c4cd 71 int _speed;
yzjdxl 1:00a4ea97c4cd 72 int _py;
yzjdxl 1:00a4ea97c4cd 73 float _mag;
yzjdxl 1:00a4ea97c4cd 74
yzjdxl 1:00a4ea97c4cd 75 int gameover;
yzjdxl 1:00a4ea97c4cd 76
yzjdxl 1:00a4ea97c4cd 77 };
yzjdxl 1:00a4ea97c4cd 78
yzjdxl 1:00a4ea97c4cd 79 #endif