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
Game/Game.h@25:1d3bf74dddeb, 2019-05-09 (annotated)
- Committer:
- S_Tingle
- Date:
- Thu May 09 13:43:23 2019 +0000
- Revision:
- 25:1d3bf74dddeb
- Parent:
- 24:7770c7f27cdc
doxygen added
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| S_Tingle | 5:e6cb6fda5b37 | 1 | #ifndef GAME_H |
| S_Tingle | 5:e6cb6fda5b37 | 2 | #define GAME_H |
| S_Tingle | 5:e6cb6fda5b37 | 3 | |
| S_Tingle | 5:e6cb6fda5b37 | 4 | #include "mbed.h" |
| S_Tingle | 5:e6cb6fda5b37 | 5 | #include "N5110.h" |
| S_Tingle | 5:e6cb6fda5b37 | 6 | #include "Gamepad.h" |
| S_Tingle | 16:37d98c281eb3 | 7 | #include "Menu.h" |
| S_Tingle | 25:1d3bf74dddeb | 8 | #include "Baby.h" |
| S_Tingle | 5:e6cb6fda5b37 | 9 | #include "Maze.h" |
| S_Tingle | 11:953141c3f7dd | 10 | #include "Enemy1.h" |
| S_Tingle | 12:200a1266ceee | 11 | #include "Enemy2.h" |
| S_Tingle | 14:d0650d0de063 | 12 | #include "Coin.h" |
| S_Tingle | 5:e6cb6fda5b37 | 13 | |
| S_Tingle | 24:7770c7f27cdc | 14 | /** Game class |
| S_Tingle | 24:7770c7f27cdc | 15 | |
| S_Tingle | 24:7770c7f27cdc | 16 | @brief Class of all game functions called in main.cpp |
| S_Tingle | 24:7770c7f27cdc | 17 | |
| S_Tingle | 24:7770c7f27cdc | 18 | @version 1.0 |
| S_Tingle | 24:7770c7f27cdc | 19 | |
| S_Tingle | 24:7770c7f27cdc | 20 | @author Spencer Tingle |
| S_Tingle | 24:7770c7f27cdc | 21 | |
| S_Tingle | 24:7770c7f27cdc | 22 | @date 09/05/19 |
| S_Tingle | 24:7770c7f27cdc | 23 | |
| S_Tingle | 24:7770c7f27cdc | 24 | */ |
| S_Tingle | 24:7770c7f27cdc | 25 | |
| S_Tingle | 5:e6cb6fda5b37 | 26 | class Game{ |
| S_Tingle | 22:8e38efeae0c9 | 27 | |
| S_Tingle | 22:8e38efeae0c9 | 28 | public: |
| S_Tingle | 5:e6cb6fda5b37 | 29 | |
| S_Tingle | 22:8e38efeae0c9 | 30 | Game(); |
| S_Tingle | 22:8e38efeae0c9 | 31 | ~Game(); |
| S_Tingle | 24:7770c7f27cdc | 32 | /** |
| S_Tingle | 25:1d3bf74dddeb | 33 | * @brief Init |
| S_Tingle | 25:1d3bf74dddeb | 34 | * @details Initiates coordinates of sprites and values |
| S_Tingle | 24:7770c7f27cdc | 35 | */ |
| S_Tingle | 22:8e38efeae0c9 | 36 | void init(); |
| S_Tingle | 24:7770c7f27cdc | 37 | /** |
| S_Tingle | 24:7770c7f27cdc | 38 | * @brief Gets current health |
| S_Tingle | 24:7770c7f27cdc | 39 | * @details Health set intially to 10 |
| S_Tingle | 24:7770c7f27cdc | 40 | */ |
| S_Tingle | 24:7770c7f27cdc | 41 | int get_health(); |
| S_Tingle | 24:7770c7f27cdc | 42 | /** |
| S_Tingle | 24:7770c7f27cdc | 43 | * @brief Gets current direction of joystick |
| S_Tingle | 24:7770c7f27cdc | 44 | */ |
| S_Tingle | 22:8e38efeae0c9 | 45 | void direc(Gamepad &pad); |
| S_Tingle | 24:7770c7f27cdc | 46 | /** |
| S_Tingle | 24:7770c7f27cdc | 47 | * @brief Displays current health |
| S_Tingle | 24:7770c7f27cdc | 48 | * @param N5110 &lcd @details Health displayed in bottom left corner of lcd |
| S_Tingle | 24:7770c7f27cdc | 49 | */ |
| S_Tingle | 22:8e38efeae0c9 | 50 | void display_health(N5110 &lcd); |
| S_Tingle | 24:7770c7f27cdc | 51 | /** |
| S_Tingle | 24:7770c7f27cdc | 52 | * @brief Draws all sprites |
| S_Tingle | 24:7770c7f27cdc | 53 | * @param N5110 &lcd @details Draws sprites at coordinates specified in init() |
| S_Tingle | 24:7770c7f27cdc | 54 | */ |
| S_Tingle | 22:8e38efeae0c9 | 55 | void drawSprite(N5110 &lcd); |
| S_Tingle | 24:7770c7f27cdc | 56 | /** |
| S_Tingle | 24:7770c7f27cdc | 57 | * @brief Move sprites |
| S_Tingle | 24:7770c7f27cdc | 58 | * @param N5110 &lcd @details Allows for movement of player and enemies |
| S_Tingle | 24:7770c7f27cdc | 59 | */ |
| S_Tingle | 22:8e38efeae0c9 | 60 | void movement(N5110 &lcd, Gamepad &pad); |
| S_Tingle | 24:7770c7f27cdc | 61 | /** |
| S_Tingle | 24:7770c7f27cdc | 62 | * @brief Detects collection |
| S_Tingle | 24:7770c7f27cdc | 63 | * @param N5110 &lcd, Gamepad &pad |
| S_Tingle | 24:7770c7f27cdc | 64 | * @details If coin is collected then it will respawn in new game |
| S_Tingle | 24:7770c7f27cdc | 65 | */ |
| S_Tingle | 22:8e38efeae0c9 | 66 | void collect(N5110 &lcd, Gamepad &pad); |
| S_Tingle | 24:7770c7f27cdc | 67 | /** |
| S_Tingle | 24:7770c7f27cdc | 68 | * @brief Win screen |
| S_Tingle | 24:7770c7f27cdc | 69 | * @param N5110 &lcd @details If win condition met win screen displays |
| S_Tingle | 24:7770c7f27cdc | 70 | */ |
| S_Tingle | 22:8e38efeae0c9 | 71 | void win(N5110 &lcd); |
| S_Tingle | 24:7770c7f27cdc | 72 | /** |
| S_Tingle | 24:7770c7f27cdc | 73 | * @brief Detects damage |
| S_Tingle | 24:7770c7f27cdc | 74 | * @param N5110 &lcd, Gamepad &pad |
| S_Tingle | 24:7770c7f27cdc | 75 | * @details If win condition met win screen displays |
| S_Tingle | 24:7770c7f27cdc | 76 | */ |
| S_Tingle | 22:8e38efeae0c9 | 77 | void damage(N5110 &lcd, Gamepad &pad); |
| S_Tingle | 24:7770c7f27cdc | 78 | /** |
| S_Tingle | 24:7770c7f27cdc | 79 | * @brief Death screen |
| S_Tingle | 24:7770c7f27cdc | 80 | * @param N5110 &lcd @details If death condition met game over screen displays |
| S_Tingle | 24:7770c7f27cdc | 81 | */ |
| S_Tingle | 22:8e38efeae0c9 | 82 | void death(N5110 &lcd); |
| S_Tingle | 24:7770c7f27cdc | 83 | /** |
| S_Tingle | 24:7770c7f27cdc | 84 | * @brief User Interface |
| S_Tingle | 24:7770c7f27cdc | 85 | * @param N5110 &lcd, Gamepad &pad |
| S_Tingle | 24:7770c7f27cdc | 86 | * @details Displays menus on start-up and game over |
| S_Tingle | 24:7770c7f27cdc | 87 | */ |
| S_Tingle | 22:8e38efeae0c9 | 88 | void UI(N5110 &lcd, Gamepad &pad); |
| S_Tingle | 22:8e38efeae0c9 | 89 | |
| S_Tingle | 22:8e38efeae0c9 | 90 | private: |
| S_Tingle | 22:8e38efeae0c9 | 91 | |
| S_Tingle | 25:1d3bf74dddeb | 92 | Baby baby; |
| S_Tingle | 22:8e38efeae0c9 | 93 | Maze maze; |
| S_Tingle | 22:8e38efeae0c9 | 94 | Menu menu; |
| S_Tingle | 22:8e38efeae0c9 | 95 | Direction dir; |
| S_Tingle | 5:e6cb6fda5b37 | 96 | |
| S_Tingle | 22:8e38efeae0c9 | 97 | Enemy1 enemyA; |
| S_Tingle | 22:8e38efeae0c9 | 98 | Enemy1 enemy1; |
| S_Tingle | 22:8e38efeae0c9 | 99 | Enemy2 enemyB; |
| S_Tingle | 22:8e38efeae0c9 | 100 | Enemy2 enemy2; |
| S_Tingle | 22:8e38efeae0c9 | 101 | Enemy2 enemyC; |
| S_Tingle | 9:b272864b8355 | 102 | |
| S_Tingle | 22:8e38efeae0c9 | 103 | Coin coin0; |
| S_Tingle | 22:8e38efeae0c9 | 104 | Coin coin1; |
| S_Tingle | 22:8e38efeae0c9 | 105 | Coin coin2; |
| S_Tingle | 22:8e38efeae0c9 | 106 | Coin coin3; |
| S_Tingle | 22:8e38efeae0c9 | 107 | Coin coin4; |
| S_Tingle | 22:8e38efeae0c9 | 108 | Coin coin5; |
| S_Tingle | 22:8e38efeae0c9 | 109 | Coin coin6; |
| S_Tingle | 22:8e38efeae0c9 | 110 | Coin coin7; |
| S_Tingle | 22:8e38efeae0c9 | 111 | Coin coin8; |
| S_Tingle | 22:8e38efeae0c9 | 112 | Coin coin9; |
| S_Tingle | 22:8e38efeae0c9 | 113 | Coin coin10; |
| S_Tingle | 22:8e38efeae0c9 | 114 | Coin coin11; |
| S_Tingle | 22:8e38efeae0c9 | 115 | Coin coin12; |
| S_Tingle | 22:8e38efeae0c9 | 116 | Coin coin13; |
| S_Tingle | 22:8e38efeae0c9 | 117 | |
| S_Tingle | 22:8e38efeae0c9 | 118 | int x; |
| S_Tingle | 22:8e38efeae0c9 | 119 | int y; |
| S_Tingle | 24:7770c7f27cdc | 120 | int _health; |
| S_Tingle | 22:8e38efeae0c9 | 121 | int coin; |
| S_Tingle | 5:e6cb6fda5b37 | 122 | }; |
| S_Tingle | 5:e6cb6fda5b37 | 123 | |
| S_Tingle | 5:e6cb6fda5b37 | 124 | #endif |