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
Ppl/Ppl.h@13:5930f0e5889d, 2019-04-30 (annotated)
- Committer:
- franklzw
- Date:
- Tue Apr 30 09:58:30 2019 +0000
- Revision:
- 13:5930f0e5889d
- Parent:
- 11:f5d0ea7e4b74
most of the class, detial with doxygen comments
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| franklzw | 4:750d3f9b54de | 1 | #include "mbed.h" |
| franklzw | 4:750d3f9b54de | 2 | #include "N5110.h" |
| franklzw | 4:750d3f9b54de | 3 | #include "Gamepad.h" |
| franklzw | 4:750d3f9b54de | 4 | |
| franklzw | 11:f5d0ea7e4b74 | 5 | /** Ppl Class |
| franklzw | 11:f5d0ea7e4b74 | 6 | @author Zhenwen liao, University of Leeds |
| franklzw | 11:f5d0ea7e4b74 | 7 | @brief Controls the Ppl in the Sokoban game |
| franklzw | 11:f5d0ea7e4b74 | 8 | @date 04 2019 |
| franklzw | 11:f5d0ea7e4b74 | 9 | */ |
| franklzw | 4:750d3f9b54de | 10 | class Ppl |
| franklzw | 4:750d3f9b54de | 11 | { |
| franklzw | 4:750d3f9b54de | 12 | |
| franklzw | 4:750d3f9b54de | 13 | public: |
| franklzw | 13:5930f0e5889d | 14 | /** Constructor */ |
| franklzw | 4:750d3f9b54de | 15 | Ppl(); |
| franklzw | 13:5930f0e5889d | 16 | |
| franklzw | 13:5930f0e5889d | 17 | /** Destructor */ |
| franklzw | 4:750d3f9b54de | 18 | ~Ppl(); |
| franklzw | 13:5930f0e5889d | 19 | |
| franklzw | 13:5930f0e5889d | 20 | /** Initialise the first position of ppl |
| franklzw | 13:5930f0e5889d | 21 | * @param x0 @details the first x position of ppl (int) |
| franklzw | 13:5930f0e5889d | 22 | * @param y0 @details the first y position of ppl (int) |
| franklzw | 13:5930f0e5889d | 23 | */ |
| franklzw | 4:750d3f9b54de | 24 | void init(int x0, int y0); |
| franklzw | 13:5930f0e5889d | 25 | |
| franklzw | 13:5930f0e5889d | 26 | /** Draw the Ppl accroading to the current _x,_y |
| franklzw | 13:5930f0e5889d | 27 | * @param lcd @details the object of screen |
| franklzw | 13:5930f0e5889d | 28 | */ |
| franklzw | 4:750d3f9b54de | 29 | void draw(N5110 &lcd); |
| franklzw | 13:5930f0e5889d | 30 | |
| franklzw | 13:5930f0e5889d | 31 | |
| franklzw | 13:5930f0e5889d | 32 | /** Update the reading of box parameter |
| franklzw | 13:5930f0e5889d | 33 | * @param bb @details the indicater of botton B being push or not (int) |
| franklzw | 13:5930f0e5889d | 34 | * @param ba @details the indicater of botton A being push or not (int) |
| franklzw | 13:5930f0e5889d | 35 | * @param bx @details the indicater of botton X being push or not (int) |
| franklzw | 13:5930f0e5889d | 36 | * @param by @details the indicater of botton Y being push or not (int) |
| franklzw | 13:5930f0e5889d | 37 | * @param indicator @details indicator for function hold_ppl_box_touching (int) |
| franklzw | 13:5930f0e5889d | 38 | * @param barrier_x @details the x position of barrier (int) |
| franklzw | 13:5930f0e5889d | 39 | * @param barrier_y @details the y position of barrier (int) |
| franklzw | 13:5930f0e5889d | 40 | */ |
| franklzw | 13:5930f0e5889d | 41 | void update(int bb,int ba,int bx,int by,int indicator,int barrier_x,int barrier_y); |
| franklzw | 11:f5d0ea7e4b74 | 42 | |
| franklzw | 13:5930f0e5889d | 43 | /** |
| franklzw | 13:5930f0e5889d | 44 | * @brief Check whether after moving if ppl pos match the barrier |
| franklzw | 13:5930f0e5889d | 45 | * @param barrier_x @details the x position of barrier (int) |
| franklzw | 13:5930f0e5889d | 46 | * @param barrier_y @details the y position of barrier (int) |
| franklzw | 13:5930f0e5889d | 47 | * @return true if matched barrier atfer next move |
| franklzw | 13:5930f0e5889d | 48 | */ |
| franklzw | 6:6b083e22cb53 | 49 | bool hold_beside_barrier(int barrier_x,int barrier_y); |
| franklzw | 13:5930f0e5889d | 50 | |
| franklzw | 13:5930f0e5889d | 51 | /** Move the ppl with respect to the bottom read |
| franklzw | 13:5930f0e5889d | 52 | * @param bb @details the indicater of botton B being push or not (int) |
| franklzw | 13:5930f0e5889d | 53 | * @param ba @details the indicater of botton A being push or not (int) |
| franklzw | 13:5930f0e5889d | 54 | * @param bx @details the indicater of botton X being push or not (int) |
| franklzw | 13:5930f0e5889d | 55 | * @param by @details the indicater of botton Y being push or not (int) |
| franklzw | 13:5930f0e5889d | 56 | */ |
| franklzw | 6:6b083e22cb53 | 57 | void move_ppl(int bb,int ba,int bx,int by); |
| franklzw | 13:5930f0e5889d | 58 | |
| franklzw | 13:5930f0e5889d | 59 | /** |
| franklzw | 13:5930f0e5889d | 60 | * @brief Check whether box facing wall and hold pos of ppl |
| franklzw | 13:5930f0e5889d | 61 | * @param indicator @details indicating the respected position of Ppl and Box (int) |
| franklzw | 13:5930f0e5889d | 62 | * @details 0: do nothing |
| franklzw | 13:5930f0e5889d | 63 | * 1: next move box off the left hold ppl in x = 10; |
| franklzw | 13:5930f0e5889d | 64 | * 2: next move box off the right hold ppl in x = 66; |
| franklzw | 13:5930f0e5889d | 65 | * 3: next move box off the top hold ppl in y = 12; |
| franklzw | 13:5930f0e5889d | 66 | * 4: next move box off the bottom hold ppl in y = 28; |
| franklzw | 13:5930f0e5889d | 67 | */ |
| franklzw | 13:5930f0e5889d | 68 | void hold_ppl_box_touching(int indicator); |
| franklzw | 13:5930f0e5889d | 69 | |
| franklzw | 13:5930f0e5889d | 70 | /** Hold the position if ppl go off screen */ |
| franklzw | 6:6b083e22cb53 | 71 | void hold_ppl_against_wall(); |
| franklzw | 13:5930f0e5889d | 72 | |
| franklzw | 13:5930f0e5889d | 73 | /** get the current position of ppl */ |
| franklzw | 4:750d3f9b54de | 74 | Vector2D get_pos(); |
| franklzw | 13:5930f0e5889d | 75 | |
| franklzw | 13:5930f0e5889d | 76 | /** set the position of ppl |
| franklzw | 13:5930f0e5889d | 77 | * @param p @details the Vector form of ppl (Vector2D) |
| franklzw | 13:5930f0e5889d | 78 | */ |
| franklzw | 4:750d3f9b54de | 79 | void set_pos(Vector2D p); |
| franklzw | 6:6b083e22cb53 | 80 | |
| franklzw | 6:6b083e22cb53 | 81 | |
| franklzw | 6:6b083e22cb53 | 82 | |
| franklzw | 4:750d3f9b54de | 83 | private: |
| franklzw | 13:5930f0e5889d | 84 | // position of the ppl |
| franklzw | 4:750d3f9b54de | 85 | int _x; |
| franklzw | 4:750d3f9b54de | 86 | int _y; |
| franklzw | 5:b50ce6160013 | 87 | }; |
