Ahmed Adamjee
/
SnakeVSBlock
Snake vs Block Game to be run upon K64F.
Diff: SnakevsBlock/SnakevsBlock.cpp
- Revision:
- 40:1debed7ec01c
- Parent:
- 39:210ac915e0a0
- Child:
- 41:4edac50f010d
--- a/SnakevsBlock/SnakevsBlock.cpp Mon Apr 22 05:28:37 2019 +0000 +++ b/SnakevsBlock/SnakevsBlock.cpp Mon Apr 22 07:10:52 2019 +0000 @@ -20,7 +20,7 @@ foodbuff = 0; send=0; speed = 1; - blockgap = 400; + blockgap = 450; blockbuff = -50; velocity = 1; for(int i=0; i<=14; i++) { @@ -235,16 +235,16 @@ { //Obtains all required coordinates for checking block sides and snake collision. Vector2D b_pos = _b.get_pos(); - snake_pos[0] = _s.get_pos(length); - snake_pos[1] = _s.get_pos_before1(length); - snake_pos[2] = _s.get_pos_before2(length); - snake_pos[3] = _s.get_pos_before3(length); - snake_pos[4] = _s.get_pos_before4(length); - snake_pos[5] = _s.get_pos_before5(length); - snake_pos[6] = _s.get_pos_before6(length); - snake_pos[7] = _s.get_pos_before7(length); - snake_pos[8] = _s.get_pos_before8(length); - snake_pos[9] = _s.get_pos_before9(length); + snake_pos[0] = _s.get_pos(length); //gets the position of the top beed and saves in array. + snake_pos[1] = _s.get_pos_before1(length); //gets the position of the second beed and saves in array. + snake_pos[2] = _s.get_pos_before2(length); //gets the position of the third beed and saves in array. + snake_pos[3] = _s.get_pos_before3(length); //gets the position of the fourth beed and saves in array. + snake_pos[4] = _s.get_pos_before4(length); //gets the position of the fifth beed and saves in array. + snake_pos[5] = _s.get_pos_before5(length); //gets the position of the sixth beed and saves in array. + snake_pos[6] = _s.get_pos_before6(length); //gets the position of the seventh beed and saves in array. + snake_pos[7] = _s.get_pos_before7(length); //gets the position of the eight beed and saves in array. + snake_pos[8] = _s.get_pos_before8(length); //gets the position of the ninth beed and saves in array. + snake_pos[9] = _s.get_pos_before9(length); //gets the position of the last beed and saves in array. //If statements check if the snake sprite has collided with any //of the blocks' sides and then stop the snake moving in x axis