Ben Evans University Second Year Project. Game Called Defender.
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.
Settings/Settings.h@87:832ca78426b5, 2020-05-27 (annotated)
- 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?
User | Revision | Line number | New contents of line |
---|---|---|---|
evanso | 43:d43759dbddb9 | 1 | #ifndef SETTINGS_H |
evanso | 43:d43759dbddb9 | 2 | #define SETTINGS_H |
evanso | 43:d43759dbddb9 | 3 | |
evanso | 82:3211b31e9421 | 4 | // Included Headers ------------------------------------------------------------ |
evanso | 43:d43759dbddb9 | 5 | #include "mbed.h" |
evanso | 43:d43759dbddb9 | 6 | #include "N5110.h" |
evanso | 43:d43759dbddb9 | 7 | #include "Gamepad.h" |
evanso | 69:753ba27325ce | 8 | #include "Sprites.h" |
evanso | 69:753ba27325ce | 9 | |
evanso | 85:87bc28b151d8 | 10 | /** Enum for different menu parts*/ |
evanso | 74:6827b43c689d | 11 | enum SettingsParts {contrast, controls, sound_fx, music }; |
evanso | 69:753ba27325ce | 12 | |
evanso | 85:87bc28b151d8 | 13 | /** Enum for different control settings parts, joystick and accelerometer*/ |
evanso | 69:753ba27325ce | 14 | enum ControlsParts {joy, acc}; |
evanso | 69:753ba27325ce | 15 | |
evanso | 85:87bc28b151d8 | 16 | /** Enum for different sound setting parts*/ |
evanso | 69:753ba27325ce | 17 | enum SoundParts {on, off}; |
evanso | 69:753ba27325ce | 18 | |
evanso | 85:87bc28b151d8 | 19 | /** Enum for different music setting parts*/ |
evanso | 74:6827b43c689d | 20 | enum MusicParts {music_on, music_off}; |
evanso | 74:6827b43c689d | 21 | |
evanso | 85:87bc28b151d8 | 22 | /** scroll_order Struct |
evanso | 69:753ba27325ce | 23 | * @brief Struct hold differnt settings orders |
evanso | 69:753ba27325ce | 24 | */ |
evanso | 69:753ba27325ce | 25 | struct scroll_order_setting { |
evanso | 82:3211b31e9421 | 26 | SettingsParts part_previous; /**< Previous settings part */ |
evanso | 74:6827b43c689d | 27 | SettingsParts part_displayed; /**< Displayed settings part */ |
evanso | 69:753ba27325ce | 28 | SettingsParts part_next; /**< Next settings part */ |
evanso | 69:753ba27325ce | 29 | }; |
evanso | 69:753ba27325ce | 30 | |
evanso | 74:6827b43c689d | 31 | /** On/off sound fx Struct |
evanso | 85:87bc28b151d8 | 32 | * @brief Struct hold different sound fx orders |
evanso | 69:753ba27325ce | 33 | */ |
evanso | 69:753ba27325ce | 34 | struct on_off_order { |
evanso | 69:753ba27325ce | 35 | SoundParts part_next; /**< Next onoff part */ |
evanso | 69:753ba27325ce | 36 | SoundParts part_displayed; /**< Displayed onoff part */ |
evanso | 69:753ba27325ce | 37 | }; |
evanso | 69:753ba27325ce | 38 | |
evanso | 74:6827b43c689d | 39 | /** On/off music Struct |
evanso | 74:6827b43c689d | 40 | * @brief Struct hold differnt music orders |
evanso | 74:6827b43c689d | 41 | */ |
evanso | 74:6827b43c689d | 42 | struct music_on_off_order { |
evanso | 74:6827b43c689d | 43 | MusicParts part_next; /**< Next onoff part */ |
evanso | 74:6827b43c689d | 44 | MusicParts part_displayed; /**< Displayed onoff part */ |
evanso | 74:6827b43c689d | 45 | }; |
evanso | 74:6827b43c689d | 46 | |
evanso | 85:87bc28b151d8 | 47 | /** Controll_order Struct |
evanso | 69:753ba27325ce | 48 | * @brief Struct hold differnt controls orders |
evanso | 69:753ba27325ce | 49 | */ |
evanso | 69:753ba27325ce | 50 | struct control_order { |
evanso | 69:753ba27325ce | 51 | ControlsParts part_next; /**< Next controls part */ |
evanso | 69:753ba27325ce | 52 | ControlsParts part_displayed; /**< Displayed controls part */ |
evanso | 69:753ba27325ce | 53 | }; |
evanso | 43:d43759dbddb9 | 54 | |
evanso | 43:d43759dbddb9 | 55 | /** Settings class |
evanso | 43:d43759dbddb9 | 56 | * @brief Change change contrast, control method |
evanso | 43:d43759dbddb9 | 57 | * @author Benjamin Evans, University of Leeds |
evanso | 43:d43759dbddb9 | 58 | * @date May 2020 |
evanso | 43:d43759dbddb9 | 59 | */ |
evanso | 43:d43759dbddb9 | 60 | class Settings{ |
evanso | 43:d43759dbddb9 | 61 | public: |
evanso | 43:d43759dbddb9 | 62 | /** Constructor */ |
evanso | 43:d43759dbddb9 | 63 | Settings(); |
evanso | 43:d43759dbddb9 | 64 | |
evanso | 43:d43759dbddb9 | 65 | /** Destructor */ |
evanso | 43:d43759dbddb9 | 66 | ~Settings(); |
evanso | 43:d43759dbddb9 | 67 | |
evanso | 85:87bc28b151d8 | 68 | /** Initialises Settings*/ |
evanso | 43:d43759dbddb9 | 69 | void init(); |
evanso | 43:d43759dbddb9 | 70 | |
evanso | 69:753ba27325ce | 71 | /** Draws the settings screen |
evanso | 69:753ba27325ce | 72 | * @param lcd @details N5110 object |
evanso | 82:3211b31e9421 | 73 | * @param pot_read @details Potentiometer read value |
evanso | 69:753ba27325ce | 74 | */ |
evanso | 69:753ba27325ce | 75 | void display_settings_screen(N5110 &lcd, float pot_read); |
evanso | 69:753ba27325ce | 76 | |
evanso | 69:753ba27325ce | 77 | /** Changes the current displayed setting part |
evanso | 69:753ba27325ce | 78 | * @param pressed @details Buttom A pressed |
evanso | 69:753ba27325ce | 79 | */ |
evanso | 69:753ba27325ce | 80 | void change_setting(bool pressed); |
evanso | 69:753ba27325ce | 81 | |
evanso | 85:87bc28b151d8 | 82 | /** Scrolls through the different settings parts |
evanso | 69:753ba27325ce | 83 | * @param d_ @details Direction of joystick |
evanso | 69:753ba27325ce | 84 | */ |
evanso | 69:753ba27325ce | 85 | void settings_scroll(Direction d_); |
evanso | 44:2d957de3bce3 | 86 | |
evanso | 43:d43759dbddb9 | 87 | // Accessors and mutators -------------------------------------------------- |
evanso | 44:2d957de3bce3 | 88 | |
evanso | 85:87bc28b151d8 | 89 | /** Return the control method that set-in setting menu |
evanso | 69:753ba27325ce | 90 | * @return control_method_ |
evanso | 44:2d957de3bce3 | 91 | */ |
evanso | 69:753ba27325ce | 92 | ControlsParts get_control_method(); |
evanso | 69:753ba27325ce | 93 | |
evanso | 85:87bc28b151d8 | 94 | /** Return the sound method that set-in setting menu |
evanso | 69:753ba27325ce | 95 | * @return sound_method_ |
evanso | 69:753ba27325ce | 96 | */ |
evanso | 73:d1aea9b8da92 | 97 | SoundParts get_sound_method(); |
evanso | 44:2d957de3bce3 | 98 | |
evanso | 85:87bc28b151d8 | 99 | /** Return the music method that set-in setting menu |
evanso | 74:6827b43c689d | 100 | * @return music_method_ |
evanso | 74:6827b43c689d | 101 | */ |
evanso | 74:6827b43c689d | 102 | MusicParts get_music_method(); |
evanso | 74:6827b43c689d | 103 | |
evanso | 70:8c4572d17441 | 104 | /** Return the setting part that is displayed |
evanso | 70:8c4572d17441 | 105 | * @return get_displayed_settings_part_ |
evanso | 70:8c4572d17441 | 106 | */ |
evanso | 70:8c4572d17441 | 107 | SettingsParts get_displayed_settings_part(); |
evanso | 70:8c4572d17441 | 108 | |
evanso | 43:d43759dbddb9 | 109 | private: |
evanso | 43:d43759dbddb9 | 110 | |
evanso | 43:d43759dbddb9 | 111 | // Varibles ---------------------------------------------------------------- |
evanso | 44:2d957de3bce3 | 112 | |
evanso | 44:2d957de3bce3 | 113 | /** LCD contrast */ |
evanso | 44:2d957de3bce3 | 114 | int lcd_contrast; |
evanso | 44:2d957de3bce3 | 115 | |
evanso | 69:753ba27325ce | 116 | /** Control method of the spaceship */ |
evanso | 69:753ba27325ce | 117 | ControlsParts control_method_; |
evanso | 69:753ba27325ce | 118 | |
evanso | 69:753ba27325ce | 119 | /** Controls whether sound fx are on or not */ |
evanso | 69:753ba27325ce | 120 | SoundParts sound_method_; |
evanso | 69:753ba27325ce | 121 | |
evanso | 74:6827b43c689d | 122 | /** Controls whether music are on or not */ |
evanso | 74:6827b43c689d | 123 | MusicParts music_method_; |
evanso | 74:6827b43c689d | 124 | |
evanso | 69:753ba27325ce | 125 | /** The part of setting that is displayed */ |
evanso | 69:753ba27325ce | 126 | SettingsParts displayed_settings_part_; |
evanso | 69:753ba27325ce | 127 | |
evanso | 43:d43759dbddb9 | 128 | }; |
evanso | 85:87bc28b151d8 | 129 | #endif |