ELEC2645 (2018/19) / Mbed 2 deprecated el17zl

Dependencies:   mbed

Fork of el17zl by Zhenwen Liao

Committer:
franklzw
Date:
Wed May 08 15:10:51 2019 +0000
Revision:
16:27c284d8b01b
Parent:
13:5930f0e5889d
Child:
17:9e6eb80478d3
08/05 commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
franklzw 2:9f0d9516a6cd 1 #ifndef PUSHINGENGINE_H
franklzw 2:9f0d9516a6cd 2 #define PUSHINGENGINE_H
franklzw 2:9f0d9516a6cd 3
franklzw 2:9f0d9516a6cd 4 #include "mbed.h"
franklzw 2:9f0d9516a6cd 5 #include "N5110.h"
franklzw 2:9f0d9516a6cd 6 #include "Gamepad.h"
franklzw 2:9f0d9516a6cd 7 #include "Ppl.h"
franklzw 2:9f0d9516a6cd 8 #include "Box.h"
franklzw 8:83891ea9a5d9 9 #include "Cross.h"
franklzw 10:726c1489894e 10 #include "Menu.h"
franklzw 8:83891ea9a5d9 11
franklzw 13:5930f0e5889d 12 /** PushingEngine Class
franklzw 13:5930f0e5889d 13 @author Zhenwen liao, University of Leeds
franklzw 13:5930f0e5889d 14 @brief Controls the Pushing and Determining Move in the Sokoban game
franklzw 13:5930f0e5889d 15 @date 04 2019
franklzw 13:5930f0e5889d 16 */
franklzw 2:9f0d9516a6cd 17 class PushingEngine
franklzw 2:9f0d9516a6cd 18 {
franklzw 2:9f0d9516a6cd 19
franklzw 2:9f0d9516a6cd 20 public:
franklzw 13:5930f0e5889d 21 /** Constructor */
franklzw 2:9f0d9516a6cd 22 PushingEngine();
franklzw 13:5930f0e5889d 23
franklzw 13:5930f0e5889d 24 /** Destructor */
franklzw 2:9f0d9516a6cd 25 ~PushingEngine();
franklzw 2:9f0d9516a6cd 26
franklzw 13:5930f0e5889d 27 /** Initialise the first position of two boxes, ppl, two crosses and initial reading of Menu parameter
franklzw 13:5930f0e5889d 28 * @param box1_x @details the first x position of box1 (int)
franklzw 13:5930f0e5889d 29 * @param box1_y @details the first y position of box1 (int)
franklzw 13:5930f0e5889d 30 * @param box2_x @details the first x position of box2 (int)
franklzw 13:5930f0e5889d 31 * @param box2_y @details the first y position of box2 (int)
franklzw 13:5930f0e5889d 32 * @param ppl_x @details the first x position of ppl (int)
franklzw 13:5930f0e5889d 33 * @param ppl_y @details the first y position of ppl (int)
franklzw 13:5930f0e5889d 34 * @param cross1_x @details the first x position of cross1 (int)
franklzw 13:5930f0e5889d 35 * @param cross1_y @details the first y position of cross1 (int)
franklzw 13:5930f0e5889d 36 * @param cross2_x @details the first x position of cross2 (int)
franklzw 13:5930f0e5889d 37 * @param cross2_y @details the first y position of cross2 (int)
franklzw 13:5930f0e5889d 38 * @param menu_x @details the initial reading of level for menu (int)
franklzw 13:5930f0e5889d 39 * @param menu_y @details the initial reading of level confirmation for menu (int)
franklzw 13:5930f0e5889d 40 */
franklzw 8:83891ea9a5d9 41 void init(int box1_x,int box1_y,int box2_x,int box2_y,int ppl_x,int ppl_y,
franklzw 10:726c1489894e 42 int cross1_x,int cross1_y,int cross2_x,int cross2_y,int menu_x,int menu_y);
franklzw 13:5930f0e5889d 43
franklzw 13:5930f0e5889d 44 /** Read the inputs from Gamepad
franklzw 13:5930f0e5889d 45 * @details Read the potentialmeter, botton A,B,X,Y
franklzw 13:5930f0e5889d 46 */
franklzw 2:9f0d9516a6cd 47 void read_input(Gamepad &pad);
franklzw 13:5930f0e5889d 48
franklzw 13:5930f0e5889d 49 /** Update the Pushing and determining proccess
franklzw 13:5930f0e5889d 50 * @details First,check box and ppl touching or not
franklzw 13:5930f0e5889d 51 * Second,check if next move of ppl will kick the box out off screen
franklzw 13:5930f0e5889d 52 * Third, update the parameter accorading to the determination of above function
franklzw 13:5930f0e5889d 53 * Fourth, reset the indicator for function
franklzw 13:5930f0e5889d 54 * Fifth, check if ppl will cover the box after next move
franklzw 13:5930f0e5889d 55 * Sixth, check if box and cross match each other and set the scores
franklzw 13:5930f0e5889d 56 */
franklzw 6:6b083e22cb53 57 void update(Gamepad &pad,int barrier_x,int barrier_y);
franklzw 13:5930f0e5889d 58
franklzw 13:5930f0e5889d 59 /** Draw all the oject on the screen*/
franklzw 6:6b083e22cb53 60 void draw(N5110 &lcd,int barrier_x,int barrier_y);
franklzw 13:5930f0e5889d 61
franklzw 13:5930f0e5889d 62 /** Set the score */
franklzw 9:1fa7f087051e 63 int set_score();
franklzw 13:5930f0e5889d 64
franklzw 13:5930f0e5889d 65 /** Get the Menu
franklzw 13:5930f0e5889d 66 * @return the parameter of current Menu state
franklzw 13:5930f0e5889d 67 */
franklzw 11:f5d0ea7e4b74 68 Vector2D get_menu(N5110 &lcd,Gamepad &pad);
franklzw 6:6b083e22cb53 69
franklzw 16:27c284d8b01b 70 void set_menu();
franklzw 2:9f0d9516a6cd 71
franklzw 2:9f0d9516a6cd 72 private:
franklzw 13:5930f0e5889d 73
franklzw 13:5930f0e5889d 74
franklzw 4:750d3f9b54de 75 void check_ppl_box1_touching(Gamepad &pad);
franklzw 4:750d3f9b54de 76 void check_ppl_box2_touching(Gamepad &pad);
franklzw 6:6b083e22cb53 77 void hold_ppl_box1_wall(Gamepad &pad);
franklzw 6:6b083e22cb53 78 void hold_ppl_box2_wall(Gamepad &pad);
franklzw 7:6f8aeadc4370 79 bool ppl_cover_box(Gamepad &pad);
franklzw 8:83891ea9a5d9 80 void box_cover_cross1_score(Gamepad &pad);
franklzw 8:83891ea9a5d9 81 void box_cover_cross2_score(Gamepad &pad);
franklzw 11:f5d0ea7e4b74 82
franklzw 11:f5d0ea7e4b74 83
franklzw 2:9f0d9516a6cd 84
franklzw 2:9f0d9516a6cd 85 Box _b1;
franklzw 2:9f0d9516a6cd 86 Box _b2;
franklzw 2:9f0d9516a6cd 87
franklzw 2:9f0d9516a6cd 88 // positions of the Boxes
franklzw 2:9f0d9516a6cd 89 int _b1x;
franklzw 2:9f0d9516a6cd 90 int _b2x;
franklzw 2:9f0d9516a6cd 91 int _b1y;
franklzw 2:9f0d9516a6cd 92 int _b2y;
franklzw 2:9f0d9516a6cd 93
franklzw 2:9f0d9516a6cd 94 Ppl _ppl;
franklzw 2:9f0d9516a6cd 95
franklzw 2:9f0d9516a6cd 96 // poitions of the ppl
franklzw 2:9f0d9516a6cd 97 int _pplx;
franklzw 2:9f0d9516a6cd 98 int _pply;
franklzw 5:b50ce6160013 99
franklzw 8:83891ea9a5d9 100 Cross _c1;
franklzw 8:83891ea9a5d9 101 Cross _c2;
franklzw 8:83891ea9a5d9 102
franklzw 8:83891ea9a5d9 103 // position of the crosses
franklzw 8:83891ea9a5d9 104 int _c1x;
franklzw 8:83891ea9a5d9 105 int _c2x;
franklzw 8:83891ea9a5d9 106 int _c1y;
franklzw 8:83891ea9a5d9 107 int _c2y;
franklzw 8:83891ea9a5d9 108
franklzw 10:726c1489894e 109 Menu _menu;
franklzw 10:726c1489894e 110
franklzw 11:f5d0ea7e4b74 111 //reading of bottom
franklzw 5:b50ce6160013 112 int _bb;
franklzw 5:b50ce6160013 113 int _bx;
franklzw 5:b50ce6160013 114 int _by;
franklzw 5:b50ce6160013 115 int _ba;
franklzw 5:b50ce6160013 116 int _bjoy;
franklzw 10:726c1489894e 117 int _bj;
franklzw 2:9f0d9516a6cd 118
franklzw 5:b50ce6160013 119 //parameter for touching
franklzw 5:b50ce6160013 120 int _s; //ppl with b1
franklzw 5:b50ce6160013 121 int _r; //ppl with b2
franklzw 11:f5d0ea7e4b74 122 int _temp; //
franklzw 11:f5d0ea7e4b74 123
franklzw 8:83891ea9a5d9 124 int _score;
franklzw 2:9f0d9516a6cd 125
franklzw 2:9f0d9516a6cd 126 };
franklzw 2:9f0d9516a6cd 127
franklzw 2:9f0d9516a6cd 128 #endif