Ahmed Adamjee
/
SnakeVSBlock
Snake vs Block Game to be run upon K64F.
Diff: GameEngine/SnakevsBlock/SnakevsBlock.cpp
- Revision:
- 77:5c6bd659c32d
- Parent:
- 76:7fa91122907f
- Child:
- 79:35cb65c52d25
--- a/GameEngine/SnakevsBlock/SnakevsBlock.cpp Sun May 05 15:00:34 2019 +0000 +++ b/GameEngine/SnakevsBlock/SnakevsBlock.cpp Sun May 05 16:02:24 2019 +0000 @@ -111,7 +111,7 @@ { _length = _l._getLength(); //saves the snake length into a private variable. SnakevsBlock::makeVirtualLengthMaxTen(); //stops the length at 10 for collision and drawing purposes. - _s.draw(lcd, _virtualLength, level); //Draws the Snake. + _s.draw(lcd, _virtualLength); //Draws the Snake. if(_dropbuff >= 0) { _f.draw(lcd); //Draws the first food after a loop delay of 0. } @@ -131,6 +131,7 @@ void SnakevsBlock::update(N5110 &lcd, Gamepad &pad) //Updates objects on screen. { + SnakevsBlock::MakeDefaultMotionFree(); //this makes the default motion of the snake freemoving before a collision is checked for, to forget the previous collision. send_block_number = 0; //this is for the game to decide wether to send the number on the block for the current itteration to the blaocks class. //we dont need to remember if it has already gone past the screen. The saved number in this changes if the snake collides with the block in CheckSnakeBlockCollision. SnakevsBlock::CheckSnakeFoodCollision(pad); //Function checks for when the snake collides with it's food. @@ -316,8 +317,6 @@ //If statements check if the snake sprite has collided with any //of the blocks' sides and then stop the snake moving in x axis - SnakevsBlock::MakeDefaultMotionFree(); //this makes the default motion of the snake freemoving before a collision is checked for, to forget the previous collision. - for(int i=0; i<=9; i++) { //i checks for all possible collisions with the snake respective to it's length. SnakevsBlock::CheckSnakeBlockSidesYCollision(i); //checks if the snake and the block are at the same position in y axis. }