![](/media/cache/profiles/LinkedIn_0NghoZJ.jpeg.50x50_q85.jpg)
Snake vs Block Game to be run upon K64F.
GameEngine/LengthManager/LengthManager.cpp@83:329da564799a, 2019-05-06 (annotated)
- Committer:
- AhmedPlaymaker
- Date:
- Mon May 06 14:28:35 2019 +0000
- Revision:
- 83:329da564799a
- Parent:
- 79:35cb65c52d25
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 | #include "LengthManager.h" |
AhmedPlaymaker | 79:35cb65c52d25 | 2 | |
AhmedPlaymaker | 79:35cb65c52d25 | 3 | LengthManager::LengthManager() |
AhmedPlaymaker | 79:35cb65c52d25 | 4 | { |
AhmedPlaymaker | 79:35cb65c52d25 | 5 | |
AhmedPlaymaker | 79:35cb65c52d25 | 6 | } |
AhmedPlaymaker | 79:35cb65c52d25 | 7 | |
AhmedPlaymaker | 79:35cb65c52d25 | 8 | LengthManager::~LengthManager() |
AhmedPlaymaker | 79:35cb65c52d25 | 9 | { |
AhmedPlaymaker | 79:35cb65c52d25 | 10 | |
AhmedPlaymaker | 79:35cb65c52d25 | 11 | } |
AhmedPlaymaker | 79:35cb65c52d25 | 12 | |
AhmedPlaymaker | 79:35cb65c52d25 | 13 | |
AhmedPlaymaker | 79:35cb65c52d25 | 14 | |
AhmedPlaymaker | 83:329da564799a | 15 | void LengthManager::init(N5110 *lcd) |
AhmedPlaymaker | 79:35cb65c52d25 | 16 | { |
AhmedPlaymaker | 83:329da564799a | 17 | _lcd = lcd; |
AhmedPlaymaker | 79:35cb65c52d25 | 18 | _length = 4; |
AhmedPlaymaker | 79:35cb65c52d25 | 19 | } |
AhmedPlaymaker | 79:35cb65c52d25 | 20 | |
AhmedPlaymaker | 79:35cb65c52d25 | 21 | void LengthManager::MinusLength() |
AhmedPlaymaker | 79:35cb65c52d25 | 22 | { |
AhmedPlaymaker | 79:35cb65c52d25 | 23 | _length -= 1; |
AhmedPlaymaker | 79:35cb65c52d25 | 24 | } |
AhmedPlaymaker | 79:35cb65c52d25 | 25 | |
AhmedPlaymaker | 79:35cb65c52d25 | 26 | void LengthManager::PlusLength() |
AhmedPlaymaker | 79:35cb65c52d25 | 27 | { |
AhmedPlaymaker | 79:35cb65c52d25 | 28 | _length += 1; |
AhmedPlaymaker | 79:35cb65c52d25 | 29 | } |
AhmedPlaymaker | 79:35cb65c52d25 | 30 | |
AhmedPlaymaker | 83:329da564799a | 31 | void LengthManager::print_length_on_screen() |
AhmedPlaymaker | 79:35cb65c52d25 | 32 | { |
AhmedPlaymaker | 79:35cb65c52d25 | 33 | char bufferscore[14]; |
AhmedPlaymaker | 79:35cb65c52d25 | 34 | sprintf(bufferscore,"%d",_length); |
AhmedPlaymaker | 83:329da564799a | 35 | _lcd->printString(bufferscore,1,0); |
AhmedPlaymaker | 79:35cb65c52d25 | 36 | } |
AhmedPlaymaker | 79:35cb65c52d25 | 37 | |
AhmedPlaymaker | 79:35cb65c52d25 | 38 | int LengthManager::_getLength() |
AhmedPlaymaker | 79:35cb65c52d25 | 39 | { |
AhmedPlaymaker | 79:35cb65c52d25 | 40 | return _length; |
AhmedPlaymaker | 79:35cb65c52d25 | 41 | } |
AhmedPlaymaker | 79:35cb65c52d25 | 42 | |
AhmedPlaymaker | 79:35cb65c52d25 | 43 | void LengthManager::_setLength(int length) |
AhmedPlaymaker | 79:35cb65c52d25 | 44 | { |
AhmedPlaymaker | 79:35cb65c52d25 | 45 | _length = length; |
AhmedPlaymaker | 79:35cb65c52d25 | 46 | } |