![](/media/cache/profiles/LinkedIn_0NghoZJ.jpeg.50x50_q85.jpg)
Snake vs Block Game to be run upon K64F.
MenuClasses/Stats/Stats.h@91:ca8cff78f2fe, 2019-05-08 (annotated)
- Committer:
- AhmedPlaymaker
- Date:
- Wed May 08 21:29:06 2019 +0000
- Revision:
- 91:ca8cff78f2fe
- Parent:
- 90:741120c09784
fixed an error with my documentation syntax
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AhmedPlaymaker | 33:249cf423fb18 | 1 | #ifndef Stats_H |
AhmedPlaymaker | 33:249cf423fb18 | 2 | #define Stats_H |
AhmedPlaymaker | 33:249cf423fb18 | 3 | |
AhmedPlaymaker | 33:249cf423fb18 | 4 | #include "mbed.h" |
AhmedPlaymaker | 33:249cf423fb18 | 5 | #include "N5110.h" |
AhmedPlaymaker | 33:249cf423fb18 | 6 | #include "Gamepad.h" |
AhmedPlaymaker | 33:249cf423fb18 | 7 | #include "SDFileSystem.h" |
AhmedPlaymaker | 33:249cf423fb18 | 8 | |
AhmedPlaymaker | 90:741120c09784 | 9 | /** Stats Class |
AhmedPlaymaker | 90:741120c09784 | 10 | @brief Class for saving the highest level achived and displaying when asked. |
AhmedPlaymaker | 90:741120c09784 | 11 | @author Ahmed N.Adamjee |
AhmedPlaymaker | 90:741120c09784 | 12 | @date 8th May 2019 |
AhmedPlaymaker | 90:741120c09784 | 13 | */ |
AhmedPlaymaker | 33:249cf423fb18 | 14 | class Stats |
AhmedPlaymaker | 33:249cf423fb18 | 15 | { |
AhmedPlaymaker | 84:9950d561fdf8 | 16 | public: |
AhmedPlaymaker | 84:9950d561fdf8 | 17 | |
AhmedPlaymaker | 90:741120c09784 | 18 | /** Constructor */ |
AhmedPlaymaker | 33:249cf423fb18 | 19 | Stats(); |
AhmedPlaymaker | 90:741120c09784 | 20 | /** Destructor */ |
AhmedPlaymaker | 33:249cf423fb18 | 21 | ~Stats(); |
AhmedPlaymaker | 84:9950d561fdf8 | 22 | |
AhmedPlaymaker | 91:ca8cff78f2fe | 23 | /** |
AhmedPlaymaker | 91:ca8cff78f2fe | 24 | * @brief Gets pointers of lcd and pad from int main() to be used privately in the entire class. |
AhmedPlaymaker | 91:ca8cff78f2fe | 25 | * @param N5110 *lcd @details pointer to the N5110 object in main, address of this pointer is saved to make availability to the entire class, without passing address to each function. |
AhmedPlaymaker | 91:ca8cff78f2fe | 26 | * @param Gamepad *pad @details pointer to the gamepad object in main, address of this pointer is saved to make availability to the entire class, without passing address to each function. |
AhmedPlaymaker | 83:329da564799a | 27 | */ |
AhmedPlaymaker | 83:329da564799a | 28 | void init(N5110 *lcd, Gamepad *pad); |
AhmedPlaymaker | 84:9950d561fdf8 | 29 | |
AhmedPlaymaker | 91:ca8cff78f2fe | 30 | /** |
AhmedPlaymaker | 91:ca8cff78f2fe | 31 | * @brief Used to display saved stats onto the screen. |
AhmedPlaymaker | 91:ca8cff78f2fe | 32 | */ |
AhmedPlaymaker | 83:329da564799a | 33 | void StatsDisplay(); |
AhmedPlaymaker | 84:9950d561fdf8 | 34 | |
AhmedPlaymaker | 90:741120c09784 | 35 | /** |
AhmedPlaymaker | 90:741120c09784 | 36 | * @brief Used to write stats to the SD card. |
AhmedPlaymaker | 91:ca8cff78f2fe | 37 | * @param level @details level is as the name implies, the current game level while playing. |
AhmedPlaymaker | 91:ca8cff78f2fe | 38 | * @param SDFileSystem &sd @details The SDFileSystem library. |
AhmedPlaymaker | 90:741120c09784 | 39 | */ |
AhmedPlaymaker | 33:249cf423fb18 | 40 | void write(int level, SDFileSystem &sd); |
AhmedPlaymaker | 84:9950d561fdf8 | 41 | |
AhmedPlaymaker | 91:ca8cff78f2fe | 42 | /** |
AhmedPlaymaker | 91:ca8cff78f2fe | 43 | * @brief Used to read data from the file |
AhmedPlaymaker | 91:ca8cff78f2fe | 44 | * @param SDFileSystem &sd @details The SDFileSystem library. |
AhmedPlaymaker | 33:249cf423fb18 | 45 | */ |
AhmedPlaymaker | 33:249cf423fb18 | 46 | void read(SDFileSystem &sd); |
AhmedPlaymaker | 84:9950d561fdf8 | 47 | |
AhmedPlaymaker | 90:741120c09784 | 48 | /** Allows us to delete the file if required. |
AhmedPlaymaker | 90:741120c09784 | 49 | * @brief not used in the working version but used when i need to delete data from the sd card. |
AhmedPlaymaker | 91:ca8cff78f2fe | 50 | * @param filename[] @details saves the name of the file we want to delete. |
AhmedPlaymaker | 33:249cf423fb18 | 51 | */ |
AhmedPlaymaker | 33:249cf423fb18 | 52 | void delete_file(char filename[]); |
AhmedPlaymaker | 90:741120c09784 | 53 | |
AhmedPlaymaker | 84:9950d561fdf8 | 54 | |
AhmedPlaymaker | 84:9950d561fdf8 | 55 | |
AhmedPlaymaker | 84:9950d561fdf8 | 56 | private: |
AhmedPlaymaker | 90:741120c09784 | 57 | int _stored_top_level; //stores the old top level from what is read from file. |
AhmedPlaymaker | 90:741120c09784 | 58 | int _current_level; //stores the current level. |
AhmedPlaymaker | 90:741120c09784 | 59 | int _top_level; //stores the new top level after comparison. |
AhmedPlaymaker | 90:741120c09784 | 60 | char _bufferlevel[14]; //this helps me print the highest level on screen. |
AhmedPlaymaker | 84:9950d561fdf8 | 61 | |
AhmedPlaymaker | 83:329da564799a | 62 | //Pointer to the game pad object pad. |
AhmedPlaymaker | 83:329da564799a | 63 | Gamepad *_pad; |
AhmedPlaymaker | 83:329da564799a | 64 | //Pointer to the N5110 object lcd. |
AhmedPlaymaker | 83:329da564799a | 65 | N5110 *_lcd; |
AhmedPlaymaker | 84:9950d561fdf8 | 66 | |
AhmedPlaymaker | 33:249cf423fb18 | 67 | |
AhmedPlaymaker | 33:249cf423fb18 | 68 | }; |
AhmedPlaymaker | 33:249cf423fb18 | 69 | #endif |