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@22:053c11a202e1, 2020-05-06 (annotated)
- Committer:
- evanso
- Date:
- Wed May 06 11:24:22 2020 +0000
- Revision:
- 22:053c11a202e1
- Parent:
- 21:f7d7834e3af1
- Child:
- 25:70b55f5bfc87
Now that the main code structure is finished for alien and weapons I can unit test those classes. Added a unit test for the alien class and it passed!
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 | 17:25d79cca203a | 10 | #include "Weapons.h" |
evanso | 19:1bc0a2d22054 | 11 | #include "Alien.h" |
evanso | 18:11068b98e261 | 12 | #include <vector> |
evanso | 11:ab578a151f67 | 13 | |
evanso | 7:0af4ced868f5 | 14 | |
evanso | 11:ab578a151f67 | 15 | /** GameEngine class |
evanso | 8:dd1037c5435b | 16 | @brief Runs the different parts of the game |
evanso | 7:0af4ced868f5 | 17 | @author Benjamin Evans, University of Leeds |
evanso | 7:0af4ced868f5 | 18 | @date April 2020 |
evanso | 7:0af4ced868f5 | 19 | */ |
evanso | 8:dd1037c5435b | 20 | |
evanso | 7:0af4ced868f5 | 21 | class GameEngine { |
evanso | 7:0af4ced868f5 | 22 | public: |
evanso | 7:0af4ced868f5 | 23 | /** Constructor */ |
evanso | 7:0af4ced868f5 | 24 | GameEngine(); |
evanso | 7:0af4ced868f5 | 25 | |
evanso | 7:0af4ced868f5 | 26 | /** Destructor */ |
evanso | 7:0af4ced868f5 | 27 | ~GameEngine(); |
evanso | 7:0af4ced868f5 | 28 | |
evanso | 14:7419c680656f | 29 | /** Initalises GameEngine */ |
evanso | 13:12276eed13ac | 30 | void init(); |
evanso | 7:0af4ced868f5 | 31 | |
evanso | 14:7419c680656f | 32 | /** Main gameplay loop that runs playable part of game */ |
evanso | 13:12276eed13ac | 33 | void gameplay_loop(); |
evanso | 15:90b6821bcf64 | 34 | |
evanso | 21:f7d7834e3af1 | 35 | // Accessors and mutators ---------------------------------------------- |
evanso | 11:ab578a151f67 | 36 | |
evanso | 11:ab578a151f67 | 37 | private: |
evanso | 21:f7d7834e3af1 | 38 | // Function prototypes ------------------------------------------------- |
evanso | 18:11068b98e261 | 39 | |
evanso | 18:11068b98e261 | 40 | /** Gets joystick direction from gamepad and stores it in d_*/ |
evanso | 18:11068b98e261 | 41 | void read_joystick_direction(); |
evanso | 11:ab578a151f67 | 42 | |
evanso | 22:053c11a202e1 | 43 | /** Creats bullet object if button A is pressed and stores in vector*/ |
evanso | 19:1bc0a2d22054 | 44 | void create_bullet(); |
evanso | 19:1bc0a2d22054 | 45 | |
evanso | 22:053c11a202e1 | 46 | /** Draws each bullet object and deleted object after set movement distance*/ |
evanso | 19:1bc0a2d22054 | 47 | void draw_bullets(); |
evanso | 13:12276eed13ac | 48 | |
evanso | 22:053c11a202e1 | 49 | /** Creats alien object and stores in vector*/ |
evanso | 20:febd920ec29e | 50 | void create_alien(); |
evanso | 20:febd920ec29e | 51 | |
evanso | 22:053c11a202e1 | 52 | /** Draws each alien object and deletes both objects if collision detected*/ |
evanso | 20:febd920ec29e | 53 | void draw_aliens(); |
evanso | 20:febd920ec29e | 54 | |
evanso | 21:f7d7834e3af1 | 55 | // Variables ----------------------------------------------------------- |
evanso | 18:11068b98e261 | 56 | |
evanso | 15:90b6821bcf64 | 57 | // Direction of joystick |
evanso | 15:90b6821bcf64 | 58 | Direction d_; |
evanso | 18:11068b98e261 | 59 | |
evanso | 19:1bc0a2d22054 | 60 | // Vector to store each new bullet object |
evanso | 19:1bc0a2d22054 | 61 | std::vector<Weapons> bullet_vector; |
evanso | 19:1bc0a2d22054 | 62 | |
evanso | 20:febd920ec29e | 63 | // Vector to store each new alien object |
evanso | 20:febd920ec29e | 64 | std::vector<Alien> alien_vector; |
evanso | 20:febd920ec29e | 65 | |
evanso | 21:f7d7834e3af1 | 66 | // Objects ------------------------------------------------------------- |
evanso | 13:12276eed13ac | 67 | |
evanso | 13:12276eed13ac | 68 | // Gamepad object |
evanso | 13:12276eed13ac | 69 | Gamepad pad; |
evanso | 13:12276eed13ac | 70 | |
evanso | 13:12276eed13ac | 71 | // LCD object |
evanso | 13:12276eed13ac | 72 | N5110 lcd; |
evanso | 13:12276eed13ac | 73 | |
evanso | 13:12276eed13ac | 74 | // Spaceship object |
evanso | 13:12276eed13ac | 75 | Spaceship spaceship; |
evanso | 13:12276eed13ac | 76 | |
evanso | 13:12276eed13ac | 77 | // Map object |
evanso | 19:1bc0a2d22054 | 78 | Map map; |
evanso | 19:1bc0a2d22054 | 79 | |
evanso | 7:0af4ced868f5 | 80 | }; |
evanso | 7:0af4ced868f5 | 81 | |
evanso | 7:0af4ced868f5 | 82 | #endif |