![](/media/cache/profiles/LinkedIn_0NghoZJ.jpeg.50x50_q85.jpg)
Snake vs Block Game to be run upon K64F.
Diff: GameEngine/SnakevsBlock/SnakevsBlock.h
- Revision:
- 82:c51ae8a501d1
- Parent:
- 81:4c1641e10dcd
- Child:
- 83:329da564799a
--- a/GameEngine/SnakevsBlock/SnakevsBlock.h Mon May 06 09:05:09 2019 +0000 +++ b/GameEngine/SnakevsBlock/SnakevsBlock.h Mon May 06 10:49:50 2019 +0000 @@ -163,6 +163,19 @@ */ void CheckSnakeBlockSidesEastWestCollision(int X, int i); + /** Check for Snake and Barrier collisions. + * + * This function checks if the Snake has come into contact with any the sides of the barriers and stops it moving in the X axis if true. + */ + void CheckSnakeBarrierCollision(Gamepad &pad, int bar_sr_no); + + /** Check Collision in Y axis + * + * This function checks if the Snake and blocks collide anywhere in the Y axis. + */ + void CheckSnakeBarrierYCollision(int i, int bar_sr_no); //i is the index of the snake beed and checks for all possible collisions with the snake respective to it's length. + void CheckSnakeBarrierEastWestCollision(int i, int bar_sr_no); //i checks for all possible collisions with the snake respective to it's length. + /** Make Virtual Length Max Ten * * This makes the virtual length -> 10 for the side collision implementation because if the length is fifteen and the last beed collides, it still is the 10th beed @@ -174,7 +187,7 @@ * * This function implements the sides collision by making the x axis speed of the particular snake beed 0. */ - void ImplementSnakeBlockSidesCollision(int i); + void ImplementBarrierCollision(int i); //OBJECT DECLARATIONS. Snake _s; @@ -194,7 +207,7 @@ Vector2D snake_pos[10]; //saves the position of all the snake beeds in an array for ease of collision processing. Vector2D food_pos[3]; //saves the position of all 3 snake food on the screen in a single array for ease of collision processing. Vector2D b_pos; //saves the origin of the blocks on the screen (this is the top left corner of the block row). - Vector2D bar_pos; //saves the origin of the barrier on the screen (this is the top left corner of the barrier). + Vector2D bar_pos[2]; //saves the origin of the barrier on the screen (this is the top left corner of the barrier). //LEVEL PROGRESSION, FAILURE AND STATISTICS PARAMETERS. int level; // this is diffrent to int _length as this stops at 10 to not complicate collisions as the snake doesn't grow longer than 10 visually.