Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of el17zl by
PushingEngine/PushingEngine.h
- Committer:
- franklzw
- Date:
- 2019-04-30
- Revision:
- 13:5930f0e5889d
- Parent:
- 11:f5d0ea7e4b74
- Child:
- 16:27c284d8b01b
File content as of revision 13:5930f0e5889d:
#ifndef PUSHINGENGINE_H #define PUSHINGENGINE_H #include "mbed.h" #include "N5110.h" #include "Gamepad.h" #include "Ppl.h" #include "Box.h" #include "Cross.h" #include "Menu.h" /** PushingEngine Class @author Zhenwen liao, University of Leeds @brief Controls the Pushing and Determining Move in the Sokoban game @date 04 2019 */ class PushingEngine { public: /** Constructor */ PushingEngine(); /** Destructor */ ~PushingEngine(); /** Initialise the first position of two boxes, ppl, two crosses and initial reading of Menu parameter * @param box1_x @details the first x position of box1 (int) * @param box1_y @details the first y position of box1 (int) * @param box2_x @details the first x position of box2 (int) * @param box2_y @details the first y position of box2 (int) * @param ppl_x @details the first x position of ppl (int) * @param ppl_y @details the first y position of ppl (int) * @param cross1_x @details the first x position of cross1 (int) * @param cross1_y @details the first y position of cross1 (int) * @param cross2_x @details the first x position of cross2 (int) * @param cross2_y @details the first y position of cross2 (int) * @param menu_x @details the initial reading of level for menu (int) * @param menu_y @details the initial reading of level confirmation for menu (int) */ void init(int box1_x,int box1_y,int box2_x,int box2_y,int ppl_x,int ppl_y, int cross1_x,int cross1_y,int cross2_x,int cross2_y,int menu_x,int menu_y); /** Read the inputs from Gamepad * @details Read the potentialmeter, botton A,B,X,Y */ void read_input(Gamepad &pad); /** Update the Pushing and determining proccess * @details First,check box and ppl touching or not * Second,check if next move of ppl will kick the box out off screen * Third, update the parameter accorading to the determination of above function * Fourth, reset the indicator for function * Fifth, check if ppl will cover the box after next move * Sixth, check if box and cross match each other and set the scores */ void update(Gamepad &pad,int barrier_x,int barrier_y); /** Draw all the oject on the screen*/ void draw(N5110 &lcd,int barrier_x,int barrier_y); /** Set the score */ int set_score(); /** Get the Menu * @return the parameter of current Menu state */ Vector2D get_menu(N5110 &lcd,Gamepad &pad); private: void check_ppl_box1_touching(Gamepad &pad); void check_ppl_box2_touching(Gamepad &pad); void hold_ppl_box1_wall(Gamepad &pad); void hold_ppl_box2_wall(Gamepad &pad); bool ppl_cover_box(Gamepad &pad); void box_cover_cross1_score(Gamepad &pad); void box_cover_cross2_score(Gamepad &pad); Box _b1; Box _b2; // positions of the Boxes int _b1x; int _b2x; int _b1y; int _b2y; Ppl _ppl; // poitions of the ppl int _pplx; int _pply; Cross _c1; Cross _c2; // position of the crosses int _c1x; int _c2x; int _c1y; int _c2y; Menu _menu; //reading of bottom int _bb; int _bx; int _by; int _ba; int _bjoy; int _bj; //parameter for touching int _s; //ppl with b1 int _r; //ppl with b2 int _temp; // int _score; }; #endif