Ben Evans University Second Year Project. Game Called Defender.

Dependencies:   mbed

https://os.mbed.com/media/uploads/evanso/84bc1a30759fd6a1e3f1fd1fae3e97c2.png

Hello, soldier, you have been specially selected as the defender of planet earth.

Your mission, if you choose to accept it. Fly around the planet and pulverise invading alien ships for as long as you can. Stop the aliens abducting the innocent people on the ground. Be warned if an alien ship manages to abduct a person and take them to top of the screen, they will no longer move randomly and will begin to hunt you down. This sounds like a challenge you were trained for.

But don’t worry soldier you’re not going into battle empty-handed. Your ship is equipped with a state of the art laser beam that has unlimited ammo and four smart bombs that will destroy anything on the screen. The ship also has three lives so use them wisely.

As time goes on more alien ships will arrive on planet earth increasing the difficulty of your mission. And remember the landscape bellow loops around so if you continually fly in the same direction you go to your original position. Good luck soldier.

Committer:
evanso
Date:
Sun May 17 23:40:34 2020 +0000
Revision:
41:5959256f4aab
Parent:
40:71f947254fda
Child:
43:d43759dbddb9
Added function to main to select between different menu parts;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
evanso 40:71f947254fda 1 #ifndef MENU_H
evanso 40:71f947254fda 2 #define MENU_H
evanso 40:71f947254fda 3
evanso 40:71f947254fda 4 // Included libraries ----------------------------------------------------------
evanso 40:71f947254fda 5 #include "mbed.h"
evanso 40:71f947254fda 6 #include "N5110.h"
evanso 40:71f947254fda 7 #include "Gamepad.h"
evanso 40:71f947254fda 8
evanso 40:71f947254fda 9 /** Enum for diffent menu parts*/
evanso 41:5959256f4aab 10 enum MenuParts {play, settings, saved_games, main_menu};
evanso 40:71f947254fda 11
evanso 40:71f947254fda 12 /** scroll_orderStruct
evanso 40:71f947254fda 13 * @brief Struct hold differnt menu orders
evanso 40:71f947254fda 14 */
evanso 40:71f947254fda 15 struct scroll_order {
evanso 40:71f947254fda 16 MenuParts part_next; /**< Next Menu part */
evanso 40:71f947254fda 17 MenuParts part_displayed; /**< Displayed menu part */
evanso 40:71f947254fda 18 };
evanso 40:71f947254fda 19
evanso 40:71f947254fda 20 /** Explosion class
evanso 40:71f947254fda 21 * @brief Selects and draws differnt menu parts
evanso 40:71f947254fda 22 * @author Benjamin Evans, University of Leeds
evanso 40:71f947254fda 23 * @date May 2020
evanso 40:71f947254fda 24 */
evanso 40:71f947254fda 25 class Menu{
evanso 40:71f947254fda 26 public:
evanso 40:71f947254fda 27 /** Constructor */
evanso 40:71f947254fda 28 Menu();
evanso 40:71f947254fda 29
evanso 40:71f947254fda 30 /** Destructor */
evanso 40:71f947254fda 31 ~Menu();
evanso 40:71f947254fda 32
evanso 40:71f947254fda 33 /** Initalises Menu*/
evanso 40:71f947254fda 34 void init();
evanso 40:71f947254fda 35
evanso 40:71f947254fda 36 /** sets the current menu part to the displayed when a is pressed
evanso 40:71f947254fda 37 * @param lcd @details N5110 object
evanso 40:71f947254fda 38 * @param pad @details Gamepad object
evanso 40:71f947254fda 39 */
evanso 40:71f947254fda 40 void select_part(N5110 &lcd, Gamepad &pad);
evanso 40:71f947254fda 41
evanso 40:71f947254fda 42 /** Draws the name of the part that is in the middle
evanso 40:71f947254fda 43 * @param lcd @details N5110 object
evanso 40:71f947254fda 44 */
evanso 40:71f947254fda 45 void draw_part(N5110 &lcd);
evanso 40:71f947254fda 46
evanso 40:71f947254fda 47 /** Scrolls through the diffent menu parts
evanso 40:71f947254fda 48 * @param pad @details Gamepad object
evanso 40:71f947254fda 49 * @param d_ @details Direction of joystick
evanso 40:71f947254fda 50 */
evanso 40:71f947254fda 51 void menu_scroll(Gamepad &pad, Direction d_);
evanso 41:5959256f4aab 52
evanso 41:5959256f4aab 53 // Accessors and mutators --------------------------------------------------
evanso 41:5959256f4aab 54
evanso 41:5959256f4aab 55 /** Gets the current menu part that is selected
evanso 41:5959256f4aab 56 * @return current_menu_part_
evanso 41:5959256f4aab 57 */
evanso 41:5959256f4aab 58 MenuParts get_current_menu_part();
evanso 40:71f947254fda 59
evanso 40:71f947254fda 60 private:
evanso 40:71f947254fda 61
evanso 40:71f947254fda 62 // Varibles ----------------------------------------------------------------
evanso 40:71f947254fda 63
evanso 40:71f947254fda 64 /** The part of the menu that is displayed */
evanso 40:71f947254fda 65 MenuParts displayed_menu_part_;
evanso 40:71f947254fda 66
evanso 40:71f947254fda 67 /** The part of the menu that is currently selected and in*/
evanso 40:71f947254fda 68 MenuParts current_menu_part_;
evanso 40:71f947254fda 69 };
evanso 40:71f947254fda 70 #endif