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/SavedGames.h
- Committer:
- evanso
- Date:
- 2020-05-20
- Revision:
- 59:0b2e43312d6b
- Parent:
- 54:d46459104dea
- Child:
- 60:55fdc6bb29b9
File content as of revision 59:0b2e43312d6b:
#ifndef SAVEDGAMES_H #define SAVEDGAMES_H // Included libraries ---------------------------------------------------------- #include "mbed.h" #include "N5110.h" #include "Gamepad.h" #include "SDFileSystem.h" #include <vector> struct SavedGamesData{ int score; /**< Score variable */ int lives; /**< lives left variable */ int smart_bombs; /**< smart_bombs left variable */ int alien_number; /**< number of alien on screen variable*/ }; /** SavedGames class * @brief Stores saved games on sd card, stores score, lives, smart bombs and * number of current alliens * @author Benjamin Evans, University of Leeds * @date May 2020 */ class SavedGames{ public: /** Constructor */ SavedGames(); /** Destructor */ ~SavedGames(); /** Initalises SavedGames * @param lcd @details N5110 object * @param sd @details sd card object */ void init(SDFileSystem &sd,N5110 &lcd); /** Check if sd card is inserted and print message if not * @param lcd @details N5110 object * @param sd @details sd card object */ void check_sd_present(SDFileSystem &sd,N5110 &lcd); /** shows error if saved data files opens incorrectly * @param lcd @details N5110 object */ void error_open_file(N5110 &lcd); /** Adds saved data to sd card * @param sd @details sd card object * @param data @details SavedGamesData struct * @param lcd @details N5110 object */ void add_saved_data(SDFileSystem &sd,SavedGamesData data, N5110 &lcd); /** Reads saved data to sd card * @param sd @details sd card object * @param lcd @details N5110 object */ void read_saved_data(SDFileSystem &sd, N5110 &lcd); /** Scrolls through the diffent saved games parts * @param d_ @details Direction of joystick */ void saved_games_scroll(Direction d_); /** Draws the saved game screen * @param lcd @details N5110 object */ void display_saved_games(N5110 &lcd); /** Vector to store saved game data*/ std::vector<SavedGamesData> saved_data_vector; // Accessors and mutators -------------------------------------------------- /** Gets error flag * @return error_; */ bool get_error(); /** Gets the displayed saved game number * @return display_data_number_; */ int get_display_data_number(); private: // Varibles ---------------------------------------------------------------- /** Flag for error, true = error */ bool error_; /** Variable for which vector data to select */ int display_data_number_; }; #endif