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@13:12276eed13ac, 2020-04-26 (annotated)
- Committer:
- evanso
- Date:
- Sun Apr 26 17:08:10 2020 +0000
- Revision:
- 13:12276eed13ac
- Parent:
- 11:ab578a151f67
- Child:
- 14:7419c680656f
Changed spaceship unit test code so it now done properly and doesn't require my input. Changed where objects are defined to reduce the number of arguments that need passing when a function is called. Edited gamepad code to properly add ADC pin.
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 | 13:12276eed13ac | 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 | 13:12276eed13ac | 29 | void init(); |
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 | 13:12276eed13ac | 34 | void gameplay_loop(); |
evanso | 11:ab578a151f67 | 35 | |
evanso | 11:ab578a151f67 | 36 | private: |
evanso | 13:12276eed13ac | 37 | // Function prototypes ------------------------------------------------- |
evanso | 11:ab578a151f67 | 38 | |
evanso | 11:ab578a151f67 | 39 | /** Moves map with spaceship movment |
evanso | 13:12276eed13ac | 40 | * @param spaceship object, gampad object, Direction f |
evanso | 8:dd1037c5435b | 41 | */ |
evanso | 13:12276eed13ac | 42 | void 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 | 13:12276eed13ac | 49 | void get_joystick_direction(); |
evanso | 13:12276eed13ac | 50 | |
evanso | 13:12276eed13ac | 51 | // Objects ------------------------------------------------------------- |
evanso | 13:12276eed13ac | 52 | |
evanso | 13:12276eed13ac | 53 | // Gamepad object |
evanso | 13:12276eed13ac | 54 | Gamepad pad; |
evanso | 13:12276eed13ac | 55 | |
evanso | 13:12276eed13ac | 56 | // LCD object |
evanso | 13:12276eed13ac | 57 | N5110 lcd; |
evanso | 13:12276eed13ac | 58 | |
evanso | 13:12276eed13ac | 59 | // Direction object of joystick |
evanso | 13:12276eed13ac | 60 | Direction d_; |
evanso | 13:12276eed13ac | 61 | |
evanso | 13:12276eed13ac | 62 | // Spaceship object |
evanso | 13:12276eed13ac | 63 | Spaceship spaceship; |
evanso | 13:12276eed13ac | 64 | |
evanso | 13:12276eed13ac | 65 | // Map object |
evanso | 13:12276eed13ac | 66 | Map map; |
evanso | 7:0af4ced868f5 | 67 | }; |
evanso | 7:0af4ced868f5 | 68 | |
evanso | 7:0af4ced868f5 | 69 | #endif |