Ahmed Adamjee
/
SnakeVSBlock
Snake vs Block Game to be run upon K64F.
Diff: GameEngine/SnakevsBlock/SnakevsBlock.cpp
- Revision:
- 54:20abd16c7d74
- Parent:
- 53:527cf297b088
- Child:
- 55:df0825049171
diff -r 527cf297b088 -r 20abd16c7d74 GameEngine/SnakevsBlock/SnakevsBlock.cpp --- a/GameEngine/SnakevsBlock/SnakevsBlock.cpp Fri Apr 26 19:09:39 2019 +0000 +++ b/GameEngine/SnakevsBlock/SnakevsBlock.cpp Fri Apr 26 19:32:57 2019 +0000 @@ -201,7 +201,11 @@ //of the blocks which are a maximum of 5, if so then the snake length reduces and the block number reduces //the block has to move slower and come down after every 2/3 iterations(dependent on the snake size.(think about this) for(int block=0; block<=83; block+=1) { //this loop automatically detects for each section of block and each combination of collision - if (((snakey == b_pos.y + 11)||(snakey == b_pos.y + 10)||(snakey == b_pos.y + 9)) && (snakex + 1 == b_pos.x + block)) { + if (((snakey == b_pos.y + 11)|| + (snakey == b_pos.y + 10)|| + (snakey == b_pos.y + 9)|| + (snakey == b_pos.y + 8))&& + (snakex + 1 == b_pos.x + block)) { //the or for the block's y position is due to the fact the exact y co-ordinate might not be collided if the snake's length has increased in the same itteration. //printf("snake collision working \n"); //audio feedback