Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
SavedGames.h
00001 #ifndef SAVEDGAMES_H 00002 #define SAVEDGAMES_H 00003 00004 // Included Headers ------------------------------------------------------------ 00005 #include "mbed.h" 00006 #include "N5110.h" 00007 #include "SDFileSystem.h" 00008 #include "Sprites.h" 00009 #include "SDErrors.h" 00010 00011 struct SavedGamesData{ 00012 int score; /**< Score variable */ 00013 int lives; /**< Lives left variable */ 00014 int smart_bombs; /**< Smart_bombs left variable */ 00015 int alien_number; /**< Number of alien on screen variable*/ 00016 }; 00017 00018 /** SavedGames class 00019 * @brief Stores saved games on sd card, stores score, lives, smart bombs and 00020 * number of current alliens 00021 * @author Benjamin Evans, University of Leeds 00022 * @date May 2020 00023 */ 00024 class SavedGames: public SDErrors{ 00025 public: 00026 /** Constructor */ 00027 SavedGames(); 00028 00029 /** Destructor */ 00030 ~SavedGames(); 00031 00032 /** Initialises SavedGames 00033 */ 00034 void init(); 00035 00036 /** Adds saved data to sd card 00037 * @param sd @details sd card object 00038 * @param data @details SavedGamesData struct 00039 * @param lcd @details N5110 object 00040 */ 00041 void add_saved_data(SDFileSystem &sd,SavedGamesData data, N5110 &lcd); 00042 00043 /** Reads saved data from sd card and return it as a struct 00044 * @param sd @details sd card object 00045 * @param lcd @details N5110 object 00046 * @return data @details SavedGamesData struct 00047 */ 00048 SavedGamesData read_saved_data(SDFileSystem &sd, N5110 &lcd); 00049 00050 /** Scrolls through the different saved games parts 00051 * @param d_ @details Direction of joystick 00052 */ 00053 void saved_games_scroll(Direction d_); 00054 00055 /** Draws the saved game screen 00056 * @param lcd @details N5110 object 00057 */ 00058 void display_saved_games(N5110 &lcd); 00059 00060 /** Draws the select save game select screen 00061 * @param lcd @details N5110 object 00062 */ 00063 void save_game_screen(N5110 &lcd); 00064 00065 /** Runs the save test unit test 00066 * @param lcd @details N5110 object 00067 * @param sd @details sd card object 00068 */ 00069 void run_save_test(SDFileSystem &sd, N5110 &lcd); 00070 00071 // Accessors and mutators -------------------------------------------------- 00072 00073 /** Gets the displayed saved game number 00074 * @return display_data_number_; 00075 */ 00076 int get_display_data_number(); 00077 00078 private: 00079 // Function prototypes ----------------------------------------------------- 00080 00081 /** Check if sd card is inserted and print message if not 00082 * @param lcd @details N5110 object 00083 * @param sd @details sd card object 00084 * @note Dont think sd.card_present()function actually works 00085 */ 00086 void check_sd_present(SDFileSystem &sd,N5110 &lcd); 00087 00088 /** Shows error if saved data files opens incorrectly 00089 * @param lcd @details N5110 object 00090 */ 00091 void error_open_file(N5110 &lcd); 00092 00093 /** Draws no saved files screen 00094 * @param lcd @details N5110 object 00095 */ 00096 void no_saved_files(N5110 &lcd); 00097 00098 /** Save test unit test, checks the saving and reading functions work 00099 * @param lcd @details N5110 object 00100 * @param sd @details sd card object 00101 * @param d_ @details Direction of joystick 00102 */ 00103 bool save_test(Direction d_,SDFileSystem &sd, N5110 &lcd); 00104 00105 // Varibles ---------------------------------------------------------------- 00106 00107 /** Variable for which vector data to select */ 00108 int display_data_number_; 00109 00110 00111 }; 00112 #endif
Generated on Fri Aug 5 2022 06:55:07 by
1.7.2