![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
test 1 doc
Engine/Engine.h@15:9ea5269b4cd4, 2020-05-27 (annotated)
- Committer:
- joebarhouch
- Date:
- Wed May 27 07:52:55 2020 +0000
- Revision:
- 15:9ea5269b4cd4
- Parent:
- 14:58887d7e1072
el18jb; VOLATILE!
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
joebarhouch | 3:e4e1cbf750b6 | 1 | #ifndef ENGINE_H |
joebarhouch | 3:e4e1cbf750b6 | 2 | #define ENGINE_H |
joebarhouch | 3:e4e1cbf750b6 | 3 | |
joebarhouch | 3:e4e1cbf750b6 | 4 | #include "mbed.h" |
joebarhouch | 3:e4e1cbf750b6 | 5 | #include "N5110.h" |
joebarhouch | 3:e4e1cbf750b6 | 6 | #include "Gamepad.h" |
joebarhouch | 3:e4e1cbf750b6 | 7 | #include "Player.h" |
joebarhouch | 5:928c2eee4109 | 8 | #include "Platform.h" |
joebarhouch | 8:d19b30a6cd69 | 9 | #include "Enemy.h" |
joebarhouch | 11:b3024ab59fa5 | 10 | #include "Coin.h" |
joebarhouch | 8:d19b30a6cd69 | 11 | #include <vector> |
joebarhouch | 14:58887d7e1072 | 12 | /** Draws the Map */ |
joebarhouch | 14:58887d7e1072 | 13 | void drawMap(N5110 &lcd); |
joebarhouch | 3:e4e1cbf750b6 | 14 | |
joebarhouch | 14:58887d7e1072 | 15 | /** Player Class |
joebarhouch | 14:58887d7e1072 | 16 | * @brief Class to control the whole game |
joebarhouch | 14:58887d7e1072 | 17 | * @author Joe Barhouch |
joebarhouch | 14:58887d7e1072 | 18 | * @author 201291584 |
joebarhouch | 14:58887d7e1072 | 19 | */ |
joebarhouch | 6:00d20886e4f8 | 20 | |
joebarhouch | 3:e4e1cbf750b6 | 21 | class Engine |
joebarhouch | 3:e4e1cbf750b6 | 22 | { |
joebarhouch | 3:e4e1cbf750b6 | 23 | |
joebarhouch | 3:e4e1cbf750b6 | 24 | public: |
joebarhouch | 14:58887d7e1072 | 25 | /** Constructor */ |
joebarhouch | 3:e4e1cbf750b6 | 26 | Engine(); |
joebarhouch | 14:58887d7e1072 | 27 | /** Deonstructor */ |
joebarhouch | 3:e4e1cbf750b6 | 28 | ~Engine(); |
joebarhouch | 14:58887d7e1072 | 29 | /** Initialisation of all parameters */ |
joebarhouch | 3:e4e1cbf750b6 | 30 | void init(); |
joebarhouch | 14:58887d7e1072 | 31 | /** Reads gamepad |
joebarhouch | 14:58887d7e1072 | 32 | *@param pad |
joebarhouch | 14:58887d7e1072 | 33 | */ |
joebarhouch | 3:e4e1cbf750b6 | 34 | void read_input(Gamepad &pad); |
joebarhouch | 14:58887d7e1072 | 35 | /** update physics |
joebarhouch | 14:58887d7e1072 | 36 | *@param pad |
joebarhouch | 14:58887d7e1072 | 37 | */ |
joebarhouch | 3:e4e1cbf750b6 | 38 | void update(Gamepad &pad); |
joebarhouch | 14:58887d7e1072 | 39 | /** Draw on the lcd |
joebarhouch | 14:58887d7e1072 | 40 | *@param lcd |
joebarhouch | 14:58887d7e1072 | 41 | */ |
joebarhouch | 3:e4e1cbf750b6 | 42 | void draw(N5110 &lcd); |
joebarhouch | 14:58887d7e1072 | 43 | /** Computes collision with platforms of the map*/ |
joebarhouch | 7:530ca713d2b2 | 44 | void floorCollide(); |
joebarhouch | 14:58887d7e1072 | 45 | /** spawn new enemy with time passed*/ |
joebarhouch | 8:d19b30a6cd69 | 46 | void spawnEnemy(); |
joebarhouch | 14:58887d7e1072 | 47 | /** Computes collision with enemies |
joebarhouch | 14:58887d7e1072 | 48 | *@return returns true if player hits enemy |
joebarhouch | 14:58887d7e1072 | 49 | */ |
joebarhouch | 14:58887d7e1072 | 50 | bool enemyCollide(); |
joebarhouch | 14:58887d7e1072 | 51 | /** Computes player falling down |
joebarhouch | 14:58887d7e1072 | 52 | *@return returns true if player falls off the screen |
joebarhouch | 14:58887d7e1072 | 53 | */ |
joebarhouch | 13:cb5ed2f0cbd5 | 54 | bool fellDown(); |
joebarhouch | 14:58887d7e1072 | 55 | /** Computes dying conditions |
joebarhouch | 14:58887d7e1072 | 56 | *@return returns true if player falls off the screen or hits an enemy |
joebarhouch | 14:58887d7e1072 | 57 | */ |
joebarhouch | 12:eb8d30593e95 | 58 | bool koed(); |
joebarhouch | 14:58887d7e1072 | 59 | /** Dying animations*/ |
joebarhouch | 11:b3024ab59fa5 | 60 | void gameOver(N5110 &lcd); |
joebarhouch | 14:58887d7e1072 | 61 | /** Computes if coins are taken*/ |
joebarhouch | 14:58887d7e1072 | 62 | void coinTaken(Gamepad &pad); |
joebarhouch | 14:58887d7e1072 | 63 | /** Computes final score |
joebarhouch | 14:58887d7e1072 | 64 | *@return returns final score |
joebarhouch | 14:58887d7e1072 | 65 | */ |
joebarhouch | 14:58887d7e1072 | 66 | int getScore(); |
joebarhouch | 14:58887d7e1072 | 67 | |
joebarhouch | 14:58887d7e1072 | 68 | |
joebarhouch | 14:58887d7e1072 | 69 | vector <int> middlesX; |
joebarhouch | 14:58887d7e1072 | 70 | vector <int> middlesY; |
joebarhouch | 14:58887d7e1072 | 71 | //counter |
joebarhouch | 14:58887d7e1072 | 72 | int counter; |
joebarhouch | 7:530ca713d2b2 | 73 | private: |
joebarhouch | 14:58887d7e1072 | 74 | |
joebarhouch | 6:00d20886e4f8 | 75 | //player object |
joebarhouch | 3:e4e1cbf750b6 | 76 | Player _p; |
joebarhouch | 3:e4e1cbf750b6 | 77 | // player coordinates |
joebarhouch | 3:e4e1cbf750b6 | 78 | int _px; |
joebarhouch | 3:e4e1cbf750b6 | 79 | int _py; |
joebarhouch | 14:58887d7e1072 | 80 | |
joebarhouch | 8:d19b30a6cd69 | 81 | Vector2D player; |
joebarhouch | 14:58887d7e1072 | 82 | |
joebarhouch | 12:eb8d30593e95 | 83 | // coin object |
joebarhouch | 12:eb8d30593e95 | 84 | Coin coin; |
joebarhouch | 13:cb5ed2f0cbd5 | 85 | Vector2D coinPos; |
joebarhouch | 14:58887d7e1072 | 86 | int f; |
joebarhouch | 14:58887d7e1072 | 87 | int score; |
joebarhouch | 14:58887d7e1072 | 88 | |
joebarhouch | 12:eb8d30593e95 | 89 | |
joebarhouch | 8:d19b30a6cd69 | 90 | //gamepad |
joebarhouch | 3:e4e1cbf750b6 | 91 | Direction _d; |
joebarhouch | 3:e4e1cbf750b6 | 92 | float _mag; |
joebarhouch | 14:58887d7e1072 | 93 | |
joebarhouch | 8:d19b30a6cd69 | 94 | //physics |
joebarhouch | 7:530ca713d2b2 | 95 | bool _jump; |
joebarhouch | 7:530ca713d2b2 | 96 | int _Ypos; |
joebarhouch | 7:530ca713d2b2 | 97 | bool _fall; |
joebarhouch | 8:d19b30a6cd69 | 98 | bool _c; |
joebarhouch | 14:58887d7e1072 | 99 | |
joebarhouch | 8:d19b30a6cd69 | 100 | //enemy |
joebarhouch | 10:9317a62bd4d0 | 101 | vector <Enemy> enemies; |
joebarhouch | 8:d19b30a6cd69 | 102 | |
joebarhouch | 14:58887d7e1072 | 103 | |
joebarhouch | 13:cb5ed2f0cbd5 | 104 | //deaths |
joebarhouch | 12:eb8d30593e95 | 105 | bool ko1; |
joebarhouch | 12:eb8d30593e95 | 106 | bool ko2; |
joebarhouch | 14:58887d7e1072 | 107 | |
joebarhouch | 14:58887d7e1072 | 108 | //time |
joebarhouch | 14:58887d7e1072 | 109 | Timer t; |
joebarhouch | 12:eb8d30593e95 | 110 | |
joebarhouch | 14:58887d7e1072 | 111 | |
joebarhouch | 8:d19b30a6cd69 | 112 | |
joebarhouch | 14:58887d7e1072 | 113 | |
joebarhouch | 3:e4e1cbf750b6 | 114 | }; |
joebarhouch | 3:e4e1cbf750b6 | 115 | |
joebarhouch | 3:e4e1cbf750b6 | 116 | #endif |