Ahmed Adamjee
/
SnakeVSBlock
Snake vs Block Game to be run upon K64F.
Diff: GameObjects/Blocks/Blocks.cpp
- Revision:
- 81:4c1641e10dcd
- Parent:
- 77:5c6bd659c32d
- Child:
- 83:329da564799a
--- a/GameObjects/Blocks/Blocks.cpp Mon May 06 08:00:56 2019 +0000 +++ b/GameObjects/Blocks/Blocks.cpp Mon May 06 09:05:09 2019 +0000 @@ -7,7 +7,7 @@ Blocks::~Blocks() { - + } //Frame Sprite. @@ -275,7 +275,7 @@ */ void Blocks::init() { - k = 0; + reset = 0; } @@ -285,7 +285,7 @@ velocity.x = 0; velocity.y = 1; - if(k == 0){ + if(reset == 0){ _bx = 0; _by = -11; int i=0; //this variable is used to save the positions of the random numbers generated in a block @@ -297,7 +297,7 @@ caseselect[rand()%5] = floor(round); round = _length/(2); //to make sure at least two smaller than the snake size (two because one is already smaller) caseselect[rand()%5] = floor(round); - k = k+1; //to stop this if function to keep executing. + reset = reset+1; //to stop this if function to keep executing. } Blocks::DrawFrame(lcd); @@ -315,8 +315,7 @@ int i = 0; int pos = 4; //this refers to the x coordinate of the blocks. while((i<5)&&(pos<=68)) { - state = caseselect[i]; - switch(state) { + switch(caseselect[i]) { case 0: // This case creates empty block break; @@ -390,7 +389,7 @@ { //and srn gives the srn of the block, snake is colliding with. // this if function makes sure the block appears at the rate of blockgap. if(_by >= (blockgap)){ - k = 0; + reset = 0; } _bx += velocity.x; _by += velocity.y;