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:
Wed May 27 02:06:05 2020 +0000
Revision:
87:832ca78426b5
Parent:
85:87bc28b151d8
Final Submission. I have read and agreed with Statement of Academic Integrity.

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 82:3211b31e9421 4 // Included Headers ------------------------------------------------------------
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 85:87bc28b151d8 10 /** Enum for defend menu parts*/
evanso 75:643a509cf9ed 11 enum MenuParts {play, settings, saved_games, high_score, 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 82:3211b31e9421 17 MenuParts part_previous; /**< Previous menu part */
evanso 74:6827b43c689d 18 MenuParts part_displayed; /**< Displayed menu part */
evanso 40:71f947254fda 19 MenuParts part_next; /**< Next Menu part */
evanso 40:71f947254fda 20 };
evanso 40:71f947254fda 21
evanso 40:71f947254fda 22 /** Explosion class
evanso 85:87bc28b151d8 23 * @brief Selects and draws different menu parts
evanso 40:71f947254fda 24 * @author Benjamin Evans, University of Leeds
evanso 40:71f947254fda 25 * @date May 2020
evanso 40:71f947254fda 26 */
evanso 40:71f947254fda 27 class Menu{
evanso 40:71f947254fda 28 public:
evanso 40:71f947254fda 29 /** Constructor */
evanso 40:71f947254fda 30 Menu();
evanso 40:71f947254fda 31
evanso 40:71f947254fda 32 /** Destructor */
evanso 40:71f947254fda 33 ~Menu();
evanso 40:71f947254fda 34
evanso 85:87bc28b151d8 35 /** Initialises Menu*/
evanso 40:71f947254fda 36 void init();
evanso 40:71f947254fda 37
evanso 82:3211b31e9421 38 /** Sets the current menu part to the displayed when a is pressed
evanso 85:87bc28b151d8 39 * @param pressed @details Bottom A pressed
evanso 40:71f947254fda 40 */
evanso 65:daa792a09e1f 41 void select_part(bool pressed);
evanso 40:71f947254fda 42
evanso 40:71f947254fda 43 /** Draws the name of the part that is in the middle
evanso 40:71f947254fda 44 * @param lcd @details N5110 object
evanso 40:71f947254fda 45 */
evanso 40:71f947254fda 46 void draw_part(N5110 &lcd);
evanso 40:71f947254fda 47
evanso 85:87bc28b151d8 48 /** Scrolls through the different menu parts
evanso 40:71f947254fda 49 * @param d_ @details Direction of joystick
evanso 40:71f947254fda 50 */
evanso 65:daa792a09e1f 51 void menu_scroll(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 68:bb1650c657ef 60 private:
evanso 68:bb1650c657ef 61 // Function prototypes -----------------------------------------------------
evanso 68:bb1650c657ef 62
evanso 85:87bc28b151d8 63 /** Prints the tile screen by printing different letter sprites
evanso 82:3211b31e9421 64 * @param lcd @details N5110 object
evanso 82:3211b31e9421 65 */
evanso 82:3211b31e9421 66 void title_screen(N5110 &lcd);
evanso 40:71f947254fda 67
evanso 82:3211b31e9421 68 /** Time-triggered interrupt to flash title screen */
evanso 82:3211b31e9421 69 void title_screen_isr();
evanso 72:e7492591307e 70
evanso 85:87bc28b151d8 71 // Variables ----------------------------------------------------------------
evanso 40:71f947254fda 72
evanso 40:71f947254fda 73 /** The part of the menu that is displayed */
evanso 40:71f947254fda 74 MenuParts displayed_menu_part_;
evanso 40:71f947254fda 75
evanso 43:d43759dbddb9 76 /** The part of the menu that is currently selected and in */
evanso 40:71f947254fda 77 MenuParts current_menu_part_;
evanso 72:e7492591307e 78
evanso 72:e7492591307e 79 /** Volatile flag for ISR */
evanso 72:e7492591307e 80 volatile bool title_screen_flag_;
evanso 72:e7492591307e 81
evanso 72:e7492591307e 82 /** Define Ticker object for flash title screen */
evanso 72:e7492591307e 83 Ticker ticker_title;
evanso 40:71f947254fda 84 };
evanso 85:87bc28b151d8 85 #endif