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@11:ab578a151f67, 2020-04-23 (annotated)
- Committer:
- evanso
- Date:
- Thu Apr 23 18:17:28 2020 +0000
- Revision:
- 11:ab578a151f67
- Parent:
- 8:dd1037c5435b
- Child:
- 13:12276eed13ac
Added test files and ran a spaceship unit test, which it passed! Also cleaned up code and comments.
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 | 11:ab578a151f67 | 4 | /////////////// Include 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 | 8:dd1037c5435b | 26 | /** Initalises GameEngine |
evanso | 11:ab578a151f67 | 27 | * @param lcd object, map object ,spaceship object, pad objectn, adc object |
evanso | 8:dd1037c5435b | 28 | */ |
evanso | 8:dd1037c5435b | 29 | void init(N5110 &lcd, Spaceship &spaceship, Map &map, Gamepad &pad,AnalogIn &adc); |
evanso | 7:0af4ced868f5 | 30 | |
evanso | 8:dd1037c5435b | 31 | /** Main gameplay loop that runs playable part of game |
evanso | 8:dd1037c5435b | 32 | * @param lcd object, map object ,spaceship object, potentiometer object, pad object, potentiometer object |
evanso | 8:dd1037c5435b | 33 | */ |
evanso | 8:dd1037c5435b | 34 | void gameplay_loop(N5110 &lcd, Spaceship &spaceship, Map &map, Gamepad &pad, AnalogIn &pot_1); |
evanso | 11:ab578a151f67 | 35 | |
evanso | 11:ab578a151f67 | 36 | private: |
evanso | 11:ab578a151f67 | 37 | /////////////// Functions /////////////// |
evanso | 11:ab578a151f67 | 38 | |
evanso | 11:ab578a151f67 | 39 | /** Moves map with spaceship movment |
evanso | 8:dd1037c5435b | 40 | * @param spaceship object, gampad object, |
evanso | 8:dd1037c5435b | 41 | */ |
evanso | 8:dd1037c5435b | 42 | void map_movement(Spaceship &spaceship, Gamepad &pad); |
evanso | 11:ab578a151f67 | 43 | |
evanso | 11:ab578a151f67 | 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 | 7:0af4ced868f5 | 48 | }; |
evanso | 7:0af4ced868f5 | 49 | |
evanso | 7:0af4ced868f5 | 50 | #endif |