![](/media/cache/profiles/LinkedIn_0NghoZJ.jpeg.50x50_q85.jpg)
Snake vs Block Game to be run upon K64F.
Diff: GameObjects/Blocks/Blocks.cpp
- Revision:
- 83:329da564799a
- Parent:
- 81:4c1641e10dcd
- Child:
- 95:b068b0735f45
--- a/GameObjects/Blocks/Blocks.cpp Mon May 06 10:49:50 2019 +0000 +++ b/GameObjects/Blocks/Blocks.cpp Mon May 06 14:28:35 2019 +0000 @@ -273,13 +273,16 @@ {0,1,1,1,1,1,1,1,1,1,1,1,1,1,0}, }; */ -void Blocks::init() +void Blocks::init(N5110 *lcd) { + _lcd = lcd; reset = 0; + _bx = NULL; + _by = NULL; } -void Blocks::draw(N5110 &lcd, int length) +void Blocks::draw(int length) { _length = length; velocity.x = 0; @@ -300,18 +303,18 @@ reset = reset+1; //to stop this if function to keep executing. } - Blocks::DrawFrame(lcd); + Blocks::DrawFrame(); - Blocks::ChooseBlocks(lcd); + Blocks::ChooseBlocks(); } -void Blocks::DrawFrame(N5110 &lcd) { +void Blocks::DrawFrame() { for(int i = 3; i <= 83; i += 16) { - lcd.drawSprite(_bx+i,_by,11,1,(int *)Frame); //Function to draw the frame at all i coordinates as x. + _lcd->drawSprite(_bx+i,_by,11,1,(int *)Frame); //Function to draw the frame at all i coordinates as x. } } -void Blocks::ChooseBlocks(N5110 &lcd) { +void Blocks::ChooseBlocks() { int i = 0; int pos = 4; //this refers to the x coordinate of the blocks. while((i<5)&&(pos<=68)) { @@ -320,49 +323,49 @@ // This case creates empty block break; case 1: - lcd.drawSprite(pos,_by,11,15,(int *)One); + _lcd->drawSprite(pos,_by,11,15,(int *)One); break; case 2: - lcd.drawSprite(pos,_by,11,15,(int *)Two); + _lcd->drawSprite(pos,_by,11,15,(int *)Two); break; case 3: - lcd.drawSprite(pos,_by,11,15,(int *)Three); + _lcd->drawSprite(pos,_by,11,15,(int *)Three); break; case 4: - lcd.drawSprite(pos,_by,11,15,(int *)Four); + _lcd->drawSprite(pos,_by,11,15,(int *)Four); break; case 5: - lcd.drawSprite(pos,_by,11,15,(int *)Five); + _lcd->drawSprite(pos,_by,11,15,(int *)Five); break; case 6: - lcd.drawSprite(pos,_by,11,15,(int *)Six); + _lcd->drawSprite(pos,_by,11,15,(int *)Six); break; case 7: - lcd.drawSprite(pos,_by,11,15,(int *)Seven); + _lcd->drawSprite(pos,_by,11,15,(int *)Seven); break; case 8: - lcd.drawSprite(pos,_by,11,15,(int *)Eight); + _lcd->drawSprite(pos,_by,11,15,(int *)Eight); break; case 9: - lcd.drawSprite(pos,_by,11,15,(int *)Nine); + _lcd->drawSprite(pos,_by,11,15,(int *)Nine); break; case 10: - lcd.drawSprite(pos,_by,11,15,(int *)Ten); + _lcd->drawSprite(pos,_by,11,15,(int *)Ten); break; case 11: - lcd.drawSprite(pos,_by,11,15,(int *)Eleven); + _lcd->drawSprite(pos,_by,11,15,(int *)Eleven); break; case 12: - lcd.drawSprite(pos,_by,11,15,(int *)Twelve); + _lcd->drawSprite(pos,_by,11,15,(int *)Twelve); break; case 13: - lcd.drawSprite(pos,_by,11,15,(int *)Thirteen); + _lcd->drawSprite(pos,_by,11,15,(int *)Thirteen); break; case 14: - lcd.drawSprite(pos,_by,11,15,(int *)Fourteen); + _lcd->drawSprite(pos,_by,11,15,(int *)Fourteen); break; case 15: - lcd.drawSprite(pos,_by,11,15,(int *)Fifteen); + _lcd->drawSprite(pos,_by,11,15,(int *)Fifteen); break; default: break;