![](/media/cache/profiles/LinkedIn_0NghoZJ.jpeg.50x50_q85.jpg)
Snake vs Block Game to be run upon K64F.
GameEngine/LengthManager/LengthManager.h@83:329da564799a, 2019-05-06 (annotated)
- Committer:
- AhmedPlaymaker
- Date:
- Mon May 06 14:28:35 2019 +0000
- Revision:
- 83:329da564799a
- Parent:
- 79:35cb65c52d25
- Child:
- 93:7f9c31ed5cab
Now, I have put gamepad and lcd objects from the main() in a pointer, so that i can declare them in init() in every class i use them in and use them as global objects for each class, without having to send their addresses to all of the functions.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AhmedPlaymaker | 79:35cb65c52d25 | 1 | #ifndef LENGTHMANAGER_H |
AhmedPlaymaker | 79:35cb65c52d25 | 2 | #define LENGTHMANAGER_H |
AhmedPlaymaker | 79:35cb65c52d25 | 3 | |
AhmedPlaymaker | 79:35cb65c52d25 | 4 | #include "mbed.h" |
AhmedPlaymaker | 79:35cb65c52d25 | 5 | #include "N5110.h" |
AhmedPlaymaker | 79:35cb65c52d25 | 6 | #include "Gamepad.h" |
AhmedPlaymaker | 79:35cb65c52d25 | 7 | |
AhmedPlaymaker | 79:35cb65c52d25 | 8 | class LengthManager |
AhmedPlaymaker | 79:35cb65c52d25 | 9 | { |
AhmedPlaymaker | 79:35cb65c52d25 | 10 | public: |
AhmedPlaymaker | 79:35cb65c52d25 | 11 | |
AhmedPlaymaker | 79:35cb65c52d25 | 12 | LengthManager(); |
AhmedPlaymaker | 79:35cb65c52d25 | 13 | ~LengthManager(); |
AhmedPlaymaker | 79:35cb65c52d25 | 14 | |
AhmedPlaymaker | 79:35cb65c52d25 | 15 | /** Initialise LengthManager |
AhmedPlaymaker | 79:35cb65c52d25 | 16 | * |
AhmedPlaymaker | 79:35cb65c52d25 | 17 | * This function sets the initial length parameters. |
AhmedPlaymaker | 79:35cb65c52d25 | 18 | */ |
AhmedPlaymaker | 83:329da564799a | 19 | void init(N5110 *lcd); |
AhmedPlaymaker | 79:35cb65c52d25 | 20 | |
AhmedPlaymaker | 79:35cb65c52d25 | 21 | /** Minus Length |
AhmedPlaymaker | 79:35cb65c52d25 | 22 | * |
AhmedPlaymaker | 79:35cb65c52d25 | 23 | * This function decrements the length value by 1;. |
AhmedPlaymaker | 79:35cb65c52d25 | 24 | */ |
AhmedPlaymaker | 79:35cb65c52d25 | 25 | void MinusLength(); |
AhmedPlaymaker | 79:35cb65c52d25 | 26 | |
AhmedPlaymaker | 79:35cb65c52d25 | 27 | /** Plus Length |
AhmedPlaymaker | 79:35cb65c52d25 | 28 | * |
AhmedPlaymaker | 79:35cb65c52d25 | 29 | * This function increments the length by one. |
AhmedPlaymaker | 79:35cb65c52d25 | 30 | */ |
AhmedPlaymaker | 79:35cb65c52d25 | 31 | void PlusLength(); |
AhmedPlaymaker | 79:35cb65c52d25 | 32 | |
AhmedPlaymaker | 79:35cb65c52d25 | 33 | /** Draw |
AhmedPlaymaker | 79:35cb65c52d25 | 34 | * |
AhmedPlaymaker | 79:35cb65c52d25 | 35 | * This function draws the length on the screen. |
AhmedPlaymaker | 79:35cb65c52d25 | 36 | */ |
AhmedPlaymaker | 83:329da564799a | 37 | void print_length_on_screen(); |
AhmedPlaymaker | 79:35cb65c52d25 | 38 | |
AhmedPlaymaker | 79:35cb65c52d25 | 39 | /** get the length |
AhmedPlaymaker | 79:35cb65c52d25 | 40 | * |
AhmedPlaymaker | 79:35cb65c52d25 | 41 | * This sends the current length value when called. |
AhmedPlaymaker | 79:35cb65c52d25 | 42 | */ |
AhmedPlaymaker | 79:35cb65c52d25 | 43 | int _getLength(); |
AhmedPlaymaker | 79:35cb65c52d25 | 44 | |
AhmedPlaymaker | 79:35cb65c52d25 | 45 | /** Set the Length |
AhmedPlaymaker | 79:35cb65c52d25 | 46 | * |
AhmedPlaymaker | 79:35cb65c52d25 | 47 | * This function obtains the length value to be altered. |
AhmedPlaymaker | 79:35cb65c52d25 | 48 | */ |
AhmedPlaymaker | 79:35cb65c52d25 | 49 | void _setLength(int length); |
AhmedPlaymaker | 79:35cb65c52d25 | 50 | |
AhmedPlaymaker | 79:35cb65c52d25 | 51 | private: |
AhmedPlaymaker | 79:35cb65c52d25 | 52 | int _length; |
AhmedPlaymaker | 83:329da564799a | 53 | //Pointer to the game pad object pad. |
AhmedPlaymaker | 83:329da564799a | 54 | Gamepad *_pad; |
AhmedPlaymaker | 83:329da564799a | 55 | //Pointer to the N5110 object lcd. |
AhmedPlaymaker | 83:329da564799a | 56 | N5110 *_lcd; |
AhmedPlaymaker | 79:35cb65c52d25 | 57 | |
AhmedPlaymaker | 79:35cb65c52d25 | 58 | }; |
AhmedPlaymaker | 79:35cb65c52d25 | 59 | #endif |