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:
86:eecd168c3a23
Final Submission. I have read and agreed with Statement of Academic Integrity.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
evanso 49:ed569eceeaa4 1 #ifndef SAVEDGAMES_H
evanso 49:ed569eceeaa4 2 #define SAVEDGAMES_H
evanso 49:ed569eceeaa4 3
evanso 82:3211b31e9421 4 // Included Headers ------------------------------------------------------------
evanso 49:ed569eceeaa4 5 #include "mbed.h"
evanso 49:ed569eceeaa4 6 #include "N5110.h"
evanso 50:13c8710985f4 7 #include "SDFileSystem.h"
evanso 68:bb1650c657ef 8 #include "Sprites.h"
evanso 78:6a6c93c19ed1 9 #include "SDErrors.h"
evanso 51:35cb8e604b72 10
evanso 51:35cb8e604b72 11 struct SavedGamesData{
evanso 52:feb8cf28bcff 12 int score; /**< Score variable */
evanso 82:3211b31e9421 13 int lives; /**< Lives left variable */
evanso 82:3211b31e9421 14 int smart_bombs; /**< Smart_bombs left variable */
evanso 82:3211b31e9421 15 int alien_number; /**< Number of alien on screen variable*/
evanso 51:35cb8e604b72 16 };
evanso 49:ed569eceeaa4 17
evanso 49:ed569eceeaa4 18 /** SavedGames class
evanso 49:ed569eceeaa4 19 * @brief Stores saved games on sd card, stores score, lives, smart bombs and
evanso 49:ed569eceeaa4 20 * number of current alliens
evanso 49:ed569eceeaa4 21 * @author Benjamin Evans, University of Leeds
evanso 49:ed569eceeaa4 22 * @date May 2020
evanso 49:ed569eceeaa4 23 */
evanso 78:6a6c93c19ed1 24 class SavedGames: public SDErrors{
evanso 49:ed569eceeaa4 25 public:
evanso 49:ed569eceeaa4 26 /** Constructor */
evanso 49:ed569eceeaa4 27 SavedGames();
evanso 49:ed569eceeaa4 28
evanso 49:ed569eceeaa4 29 /** Destructor */
evanso 49:ed569eceeaa4 30 ~SavedGames();
evanso 49:ed569eceeaa4 31
evanso 85:87bc28b151d8 32 /** Initialises SavedGames
evanso 51:35cb8e604b72 33 */
evanso 67:a2984682d641 34 void init();
evanso 49:ed569eceeaa4 35
evanso 51:35cb8e604b72 36 /** Adds saved data to sd card
evanso 51:35cb8e604b72 37 * @param sd @details sd card object
evanso 53:01be7898c23f 38 * @param data @details SavedGamesData struct
evanso 54:d46459104dea 39 * @param lcd @details N5110 object
evanso 51:35cb8e604b72 40 */
evanso 59:0b2e43312d6b 41 void add_saved_data(SDFileSystem &sd,SavedGamesData data, N5110 &lcd);
evanso 53:01be7898c23f 42
evanso 85:87bc28b151d8 43 /** Reads saved data from sd card and return it as a struct
evanso 53:01be7898c23f 44 * @param sd @details sd card object
evanso 54:d46459104dea 45 * @param lcd @details N5110 object
evanso 61:7c4ec680a428 46 * @return data @details SavedGamesData struct
evanso 53:01be7898c23f 47 */
evanso 61:7c4ec680a428 48 SavedGamesData read_saved_data(SDFileSystem &sd, N5110 &lcd);
evanso 54:d46459104dea 49
evanso 85:87bc28b151d8 50 /** Scrolls through the different saved games parts
evanso 54:d46459104dea 51 * @param d_ @details Direction of joystick
evanso 54:d46459104dea 52 */
evanso 59:0b2e43312d6b 53 void saved_games_scroll(Direction d_);
evanso 54:d46459104dea 54
evanso 54:d46459104dea 55 /** Draws the saved game screen
evanso 54:d46459104dea 56 * @param lcd @details N5110 object
evanso 54:d46459104dea 57 */
evanso 54:d46459104dea 58 void display_saved_games(N5110 &lcd);
evanso 59:0b2e43312d6b 59
evanso 61:7c4ec680a428 60 /** Draws the select save game select screen
evanso 60:55fdc6bb29b9 61 * @param lcd @details N5110 object
evanso 60:55fdc6bb29b9 62 */
evanso 60:55fdc6bb29b9 63 void save_game_screen(N5110 &lcd);
evanso 60:55fdc6bb29b9 64
evanso 67:a2984682d641 65 /** Runs the save test unit test
evanso 67:a2984682d641 66 * @param lcd @details N5110 object
evanso 67:a2984682d641 67 * @param sd @details sd card object
evanso 67:a2984682d641 68 */
evanso 67:a2984682d641 69 void run_save_test(SDFileSystem &sd, N5110 &lcd);
evanso 67:a2984682d641 70
evanso 49:ed569eceeaa4 71 // Accessors and mutators --------------------------------------------------
evanso 49:ed569eceeaa4 72
evanso 59:0b2e43312d6b 73 /** Gets the displayed saved game number
evanso 59:0b2e43312d6b 74 * @return display_data_number_;
evanso 59:0b2e43312d6b 75 */
evanso 59:0b2e43312d6b 76 int get_display_data_number();
evanso 59:0b2e43312d6b 77
evanso 49:ed569eceeaa4 78 private:
evanso 64:e9dfc35a1738 79 // Function prototypes -----------------------------------------------------
evanso 64:e9dfc35a1738 80
evanso 64:e9dfc35a1738 81 /** Check if sd card is inserted and print message if not
evanso 64:e9dfc35a1738 82 * @param lcd @details N5110 object
evanso 64:e9dfc35a1738 83 * @param sd @details sd card object
evanso 85:87bc28b151d8 84 * @note Dont think sd.card_present()function actually works
evanso 64:e9dfc35a1738 85 */
evanso 64:e9dfc35a1738 86 void check_sd_present(SDFileSystem &sd,N5110 &lcd);
evanso 64:e9dfc35a1738 87
evanso 82:3211b31e9421 88 /** Shows error if saved data files opens incorrectly
evanso 64:e9dfc35a1738 89 * @param lcd @details N5110 object
evanso 64:e9dfc35a1738 90 */
evanso 64:e9dfc35a1738 91 void error_open_file(N5110 &lcd);
evanso 64:e9dfc35a1738 92
evanso 64:e9dfc35a1738 93 /** Draws no saved files screen
evanso 64:e9dfc35a1738 94 * @param lcd @details N5110 object
evanso 64:e9dfc35a1738 95 */
evanso 64:e9dfc35a1738 96 void no_saved_files(N5110 &lcd);
evanso 79:66bcf8fa2d2d 97
evanso 79:66bcf8fa2d2d 98 /** Save test unit test, checks the saving and reading functions work
evanso 79:66bcf8fa2d2d 99 * @param lcd @details N5110 object
evanso 79:66bcf8fa2d2d 100 * @param sd @details sd card object
evanso 79:66bcf8fa2d2d 101 * @param d_ @details Direction of joystick
evanso 79:66bcf8fa2d2d 102 */
evanso 79:66bcf8fa2d2d 103 bool save_test(Direction d_,SDFileSystem &sd, N5110 &lcd);
evanso 67:a2984682d641 104
evanso 49:ed569eceeaa4 105 // Varibles ----------------------------------------------------------------
evanso 49:ed569eceeaa4 106
evanso 54:d46459104dea 107 /** Variable for which vector data to select */
evanso 54:d46459104dea 108 int display_data_number_;
evanso 61:7c4ec680a428 109
evanso 61:7c4ec680a428 110
evanso 49:ed569eceeaa4 111 };
evanso 85:87bc28b151d8 112 #endif