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:
Sat May 23 21:35:16 2020 +0000
Revision:
72:e7492591307e
Parent:
69:753ba27325ce
Child:
74:6827b43c689d
Added sound class to hold songs. Also added tones for when sprites explode.

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 68:bb1650c657ef 8 #include "Sprites.h"
evanso 40:71f947254fda 9
evanso 40:71f947254fda 10 /** Enum for diffent menu parts*/
evanso 41:5959256f4aab 11 enum MenuParts {play, settings, saved_games, main_menu};
evanso 40:71f947254fda 12
evanso 40:71f947254fda 13 /** scroll_orderStruct
evanso 40:71f947254fda 14 * @brief Struct hold differnt menu orders
evanso 40:71f947254fda 15 */
evanso 40:71f947254fda 16 struct scroll_order {
evanso 40:71f947254fda 17 MenuParts part_next; /**< Next Menu part */
evanso 40:71f947254fda 18 MenuParts part_displayed; /**< Displayed menu part */
evanso 40:71f947254fda 19 };
evanso 40:71f947254fda 20
evanso 40:71f947254fda 21 /** Explosion class
evanso 40:71f947254fda 22 * @brief Selects and draws differnt menu parts
evanso 40:71f947254fda 23 * @author Benjamin Evans, University of Leeds
evanso 40:71f947254fda 24 * @date May 2020
evanso 40:71f947254fda 25 */
evanso 40:71f947254fda 26 class Menu{
evanso 40:71f947254fda 27 public:
evanso 40:71f947254fda 28 /** Constructor */
evanso 40:71f947254fda 29 Menu();
evanso 40:71f947254fda 30
evanso 40:71f947254fda 31 /** Destructor */
evanso 40:71f947254fda 32 ~Menu();
evanso 40:71f947254fda 33
evanso 40:71f947254fda 34 /** Initalises Menu*/
evanso 40:71f947254fda 35 void init();
evanso 40:71f947254fda 36
evanso 40:71f947254fda 37 /** sets the current menu part to the displayed when a is pressed
evanso 65:daa792a09e1f 38 * @param pressed @details Buttom A pressed
evanso 40:71f947254fda 39 */
evanso 65:daa792a09e1f 40 void select_part(bool pressed);
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 d_ @details Direction of joystick
evanso 40:71f947254fda 49 */
evanso 65:daa792a09e1f 50 void menu_scroll(Direction d_);
evanso 41:5959256f4aab 51
evanso 41:5959256f4aab 52 // Accessors and mutators --------------------------------------------------
evanso 41:5959256f4aab 53
evanso 41:5959256f4aab 54 /** Gets the current menu part that is selected
evanso 41:5959256f4aab 55 * @return current_menu_part_
evanso 41:5959256f4aab 56 */
evanso 41:5959256f4aab 57 MenuParts get_current_menu_part();
evanso 40:71f947254fda 58
evanso 68:bb1650c657ef 59 private:
evanso 68:bb1650c657ef 60 // Function prototypes -----------------------------------------------------
evanso 68:bb1650c657ef 61
evanso 69:753ba27325ce 62 /** Prints the tile screen by printing differnt letter sprites */
evanso 68:bb1650c657ef 63 void title_screen(N5110 &lcd);
evanso 40:71f947254fda 64
evanso 72:e7492591307e 65 /** Time-triggered interrupt to flash title screen */
evanso 72:e7492591307e 66 void title_screen_isr();
evanso 72:e7492591307e 67
evanso 40:71f947254fda 68 // Varibles ----------------------------------------------------------------
evanso 40:71f947254fda 69
evanso 40:71f947254fda 70 /** The part of the menu that is displayed */
evanso 40:71f947254fda 71 MenuParts displayed_menu_part_;
evanso 40:71f947254fda 72
evanso 43:d43759dbddb9 73 /** The part of the menu that is currently selected and in */
evanso 40:71f947254fda 74 MenuParts current_menu_part_;
evanso 72:e7492591307e 75
evanso 72:e7492591307e 76 /** Volatile flag for ISR */
evanso 72:e7492591307e 77 volatile bool title_screen_flag_;
evanso 72:e7492591307e 78
evanso 72:e7492591307e 79 /** Define Ticker object for flash title screen */
evanso 72:e7492591307e 80 Ticker ticker_title;
evanso 40:71f947254fda 81 };
evanso 40:71f947254fda 82 #endif