Ahmed Adamjee
/
SnakeVSBlock
Snake vs Block Game to be run upon K64F.
MenuClasses/Stats/Stats.h@90:741120c09784, 2019-05-08 (annotated)
- Committer:
- AhmedPlaymaker
- Date:
- Wed May 08 21:01:20 2019 +0000
- Revision:
- 90:741120c09784
- Parent:
- 84:9950d561fdf8
- Child:
- 91:ca8cff78f2fe
Made documentation for stats and tutorial.
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 | 90:741120c09784 | 23 | /** Gets pointers of lcd and pad from int main() to be used privately in the entire class.. |
AhmedPlaymaker | 90:741120c09784 | 24 | * @param 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 | 90:741120c09784 | 25 | * @param 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 | 26 | */ |
AhmedPlaymaker | 83:329da564799a | 27 | void init(N5110 *lcd, Gamepad *pad); |
AhmedPlaymaker | 84:9950d561fdf8 | 28 | |
AhmedPlaymaker | 90:741120c09784 | 29 | /** Used to display saved stats onto the screen.*/ |
AhmedPlaymaker | 83:329da564799a | 30 | void StatsDisplay(); |
AhmedPlaymaker | 84:9950d561fdf8 | 31 | |
AhmedPlaymaker | 90:741120c09784 | 32 | /** |
AhmedPlaymaker | 90:741120c09784 | 33 | * @brief Used to write stats to the SD card. |
AhmedPlaymaker | 90:741120c09784 | 34 | * @param level is as the name implies, the current game level while playing. |
AhmedPlaymaker | 90:741120c09784 | 35 | * @param The SDFileSystem library |
AhmedPlaymaker | 90:741120c09784 | 36 | */ |
AhmedPlaymaker | 33:249cf423fb18 | 37 | void write(int level, SDFileSystem &sd); |
AhmedPlaymaker | 84:9950d561fdf8 | 38 | |
AhmedPlaymaker | 90:741120c09784 | 39 | /** Used to read data from the file |
AhmedPlaymaker | 90:741120c09784 | 40 | * @param The SDFileSystem library |
AhmedPlaymaker | 33:249cf423fb18 | 41 | */ |
AhmedPlaymaker | 33:249cf423fb18 | 42 | void read(SDFileSystem &sd); |
AhmedPlaymaker | 84:9950d561fdf8 | 43 | |
AhmedPlaymaker | 90:741120c09784 | 44 | /** Allows us to delete the file if required. |
AhmedPlaymaker | 90:741120c09784 | 45 | * @brief not used in the working version but used when i need to delete data from the sd card. |
AhmedPlaymaker | 90:741120c09784 | 46 | * @param filename[] saves the name of the file we want to delete. |
AhmedPlaymaker | 33:249cf423fb18 | 47 | */ |
AhmedPlaymaker | 33:249cf423fb18 | 48 | void delete_file(char filename[]); |
AhmedPlaymaker | 90:741120c09784 | 49 | |
AhmedPlaymaker | 84:9950d561fdf8 | 50 | |
AhmedPlaymaker | 84:9950d561fdf8 | 51 | |
AhmedPlaymaker | 84:9950d561fdf8 | 52 | private: |
AhmedPlaymaker | 90:741120c09784 | 53 | int _stored_top_level; //stores the old top level from what is read from file. |
AhmedPlaymaker | 90:741120c09784 | 54 | int _current_level; //stores the current level. |
AhmedPlaymaker | 90:741120c09784 | 55 | int _top_level; //stores the new top level after comparison. |
AhmedPlaymaker | 90:741120c09784 | 56 | char _bufferlevel[14]; //this helps me print the highest level on screen. |
AhmedPlaymaker | 84:9950d561fdf8 | 57 | |
AhmedPlaymaker | 83:329da564799a | 58 | //Pointer to the game pad object pad. |
AhmedPlaymaker | 83:329da564799a | 59 | Gamepad *_pad; |
AhmedPlaymaker | 83:329da564799a | 60 | //Pointer to the N5110 object lcd. |
AhmedPlaymaker | 83:329da564799a | 61 | N5110 *_lcd; |
AhmedPlaymaker | 84:9950d561fdf8 | 62 | |
AhmedPlaymaker | 33:249cf423fb18 | 63 | |
AhmedPlaymaker | 33:249cf423fb18 | 64 | }; |
AhmedPlaymaker | 33:249cf423fb18 | 65 | #endif |