Ahmed Adamjee
/
SnakeVSBlock
Snake vs Block Game to be run upon K64F.
Diff: SnakevsBlock/SnakevsBlock.cpp
- Revision:
- 28:d2c621d67e3b
- Parent:
- 27:3b4775a0d0bb
- Child:
- 29:c6358c39a70e
--- a/SnakevsBlock/SnakevsBlock.cpp Thu Apr 11 06:50:47 2019 +0000 +++ b/SnakevsBlock/SnakevsBlock.cpp Fri Apr 12 16:43:16 2019 +0000 @@ -195,25 +195,20 @@ //If statements check if the snake sprite has collided with any //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=1; block<=65; block+=16) { //this loop automatically detects for each section of block - if(block == 65) { - block += 2; - } - for(int i = block; i <= (block+15); i++) { //this loop automatically detects each combination of collision - if ((snake_pos.y == b_pos.y + 10) && (snake_pos.x + 1 == b_pos.x + i)) { - + for(int block=1; block<=82; block+=1) { //this loop automatically detects for each section of block and each combination of collision + if ((snake_pos.y == b_pos.y + 10) && (snake_pos.x + 1 == b_pos.x + block)) { //printf("snake collision working \n"); //audio feedback - if(blocknum > 0) { + if(blocknum > 0) { //change this to speed y = 0 when length = 10. b_pos.y = 0; } - if(block == 64) { - block += 2; - } - srn = ((block + 5)/17); + if((block>=1)&&(block<=18)) {srn = 0;} + if((block>=19)&&(block<=34)) {srn = 1;} + if((block>=35)&&(block<=50)) {srn = 2;} + if((block>=51)&&(block<=66)) {srn = 3;} + if((block>=67)&&(block<=82)) {srn = 4;} blocknum = b_number[srn]; ImplementCollision(pad); - } } } }