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.
GameEngine/GameEngine.h@15:90b6821bcf64, 2020-04-28 (annotated)
- Committer:
- evanso
- Date:
- Tue Apr 28 19:13:12 2020 +0000
- Revision:
- 15:90b6821bcf64
- Parent:
- 14:7419c680656f
- Child:
- 16:1ee3d3804557
Added DEBUG compile macros to check calculate_map_map was producing correct output
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
evanso | 11:ab578a151f67 | 1 | #ifndef GAMEENGINE_H |
evanso | 11:ab578a151f67 | 2 | #define GAMEENGINE_H |
evanso | 7:0af4ced868f5 | 3 | |
evanso | 15:90b6821bcf64 | 4 | // Included libraries ----------------------------------------------------------- |
evanso | 7:0af4ced868f5 | 5 | #include "mbed.h" |
evanso | 7:0af4ced868f5 | 6 | #include "N5110.h" |
evanso | 7:0af4ced868f5 | 7 | #include "Gamepad.h" |
evanso | 8:dd1037c5435b | 8 | #include "Spaceship.h" |
evanso | 8:dd1037c5435b | 9 | #include "Map.h" |
evanso | 11:ab578a151f67 | 10 | |
evanso | 7:0af4ced868f5 | 11 | |
evanso | 11:ab578a151f67 | 12 | /** GameEngine class |
evanso | 8:dd1037c5435b | 13 | @brief Runs the different parts of the game |
evanso | 7:0af4ced868f5 | 14 | @author Benjamin Evans, University of Leeds |
evanso | 7:0af4ced868f5 | 15 | @date April 2020 |
evanso | 7:0af4ced868f5 | 16 | */ |
evanso | 8:dd1037c5435b | 17 | |
evanso | 7:0af4ced868f5 | 18 | class GameEngine { |
evanso | 7:0af4ced868f5 | 19 | public: |
evanso | 7:0af4ced868f5 | 20 | /** Constructor */ |
evanso | 7:0af4ced868f5 | 21 | GameEngine(); |
evanso | 7:0af4ced868f5 | 22 | |
evanso | 7:0af4ced868f5 | 23 | /** Destructor */ |
evanso | 7:0af4ced868f5 | 24 | ~GameEngine(); |
evanso | 7:0af4ced868f5 | 25 | |
evanso | 14:7419c680656f | 26 | /** Initalises GameEngine */ |
evanso | 13:12276eed13ac | 27 | void init(); |
evanso | 7:0af4ced868f5 | 28 | |
evanso | 14:7419c680656f | 29 | /** Main gameplay loop that runs playable part of game */ |
evanso | 13:12276eed13ac | 30 | void gameplay_loop(); |
evanso | 15:90b6821bcf64 | 31 | |
evanso | 15:90b6821bcf64 | 32 | /** Gets joystick direction from gamepad and stores it in d_*/ |
evanso | 15:90b6821bcf64 | 33 | void read_joystick_direction(); |
evanso | 15:90b6821bcf64 | 34 | |
evanso | 15:90b6821bcf64 | 35 | |
evanso | 15:90b6821bcf64 | 36 | // Accessors and mutators ---------------------------------------------- |
evanso | 11:ab578a151f67 | 37 | |
evanso | 11:ab578a151f67 | 38 | private: |
evanso | 13:12276eed13ac | 39 | // Function prototypes ------------------------------------------------- |
evanso | 11:ab578a151f67 | 40 | |
evanso | 15:90b6821bcf64 | 41 | /** Calulates the map movement depeding on spaceship positions and joystick input */ |
evanso | 15:90b6821bcf64 | 42 | void calculate_map_movement(); |
evanso | 11:ab578a151f67 | 43 | |
evanso | 13:12276eed13ac | 44 | // Variables ----------------------------------------------------------- |
evanso | 11:ab578a151f67 | 45 | |
evanso | 11:ab578a151f67 | 46 | // Changes the drawing x postion of map, 1 moves right, -1 moves left and 0 doesnt change map position |
evanso | 11:ab578a151f67 | 47 | int move_map_; |
evanso | 13:12276eed13ac | 48 | |
evanso | 15:90b6821bcf64 | 49 | // Direction of joystick |
evanso | 15:90b6821bcf64 | 50 | Direction d_; |
evanso | 15:90b6821bcf64 | 51 | |
evanso | 13:12276eed13ac | 52 | // Objects ------------------------------------------------------------- |
evanso | 13:12276eed13ac | 53 | |
evanso | 13:12276eed13ac | 54 | // Gamepad object |
evanso | 13:12276eed13ac | 55 | Gamepad pad; |
evanso | 13:12276eed13ac | 56 | |
evanso | 13:12276eed13ac | 57 | // LCD object |
evanso | 13:12276eed13ac | 58 | N5110 lcd; |
evanso | 13:12276eed13ac | 59 | |
evanso | 13:12276eed13ac | 60 | // Spaceship object |
evanso | 13:12276eed13ac | 61 | Spaceship spaceship; |
evanso | 13:12276eed13ac | 62 | |
evanso | 13:12276eed13ac | 63 | // Map object |
evanso | 13:12276eed13ac | 64 | Map map; |
evanso | 7:0af4ced868f5 | 65 | }; |
evanso | 7:0af4ced868f5 | 66 | |
evanso | 7:0af4ced868f5 | 67 | #endif |