![](/media/cache/profiles/LinkedIn_0NghoZJ.jpeg.50x50_q85.jpg)
Snake vs Block Game to be run upon K64F.
Diff: GameEngine/SnakevsBlock/SnakevsBlock.h
- Revision:
- 98:3061aa318fa2
- Parent:
- 96:1ab67b3e6898
- Child:
- 100:6403c1705a08
--- a/GameEngine/SnakevsBlock/SnakevsBlock.h Thu May 09 09:39:02 2019 +0000 +++ b/GameEngine/SnakevsBlock/SnakevsBlock.h Thu May 09 09:59:05 2019 +0000 @@ -92,111 +92,111 @@ * @brief This function contains the Get Position functions of all the class objects used in the game and saves them to use in an array throughout the class. */ void get_pos(); - -private: - - /** - *@brief This function checks if the Snake has come into contact with it's food. - */ - void CheckSnakeFoodCollision(); - - /** - * @brief This function automatically detects each combination of collision in the y postion. - * @param food_sr @details creted in a loop that runs 3 times to detect collision with all the three food objects. - */ - void CheckSnakeFoodYCollision(int food_sr); - - /** - * @brief This function automatically detects each combination of collision in the x postion. - * @param food_sr @details creted in a loop that runs 3 times to detect collision with all the three food objects. - */ - void CheckSnakeFoodXCollision(int food_sr); - - /** - * @brief This function automatically detects which food we are interacting with and increases the snake length accordingly. - * @param food_sr @details creted in a loop that runs 3 times to detect collision with all the three food objects. - */ - void ImplementSnakeFoodCollision(int food_sr); - - /** - * @brief This function checks if the Snake has come into contact with any Block. - */ - void CheckSnakeBlockCollision(); /** - * @brief This function returns the srn of the block we are colliding with. - * @param Block @details value of int block which is compared to a preset ranges, to allocate a serial number to the colliding block. - */ - int CheckBlock(int Block); - - /** * @brief this is to stop/move the background (food and blocks), when collision occurs at a length greater than 10.lock. * @param srn @details this is the serial number of blocks and tells us which of the 5 blocks we are colliding with */ void _setVelocity(int srn); - - /** - * @brief This function allows the appropriate maths to take place after every collision. - */ - void ImplementSnakeBlockCollision(); - - /** - * @brief This function checks if the Snake has come into contact with any the sides of the block and stops it moving. - */ - void CheckSnakeBlockSidesCollision(); - + /** * @brief This function makes the default motion of the snake freemoving before a collision is checked for, to forget the previous collision. */ void MakeDefaultMotionFree(); - - /** - * @brief This function checks if the Snake and blocks collide anywhere in the Y axis. - * @param i @details is the index of the snake beed and allows to check for all possible collisions with the snake respective to it's length. - */ - void CheckSnakeBlockSidesYCollision(int i); - - /** - * @brief This function checks if the Snake and blocks collide anywhere in the X axis. - * @param i @details is the index of the snake beed and allows to check for all possible collisions with the snake respective to it's length. - */ - void CheckSnakeBlockSidesXCollision(int i); - - /** - * @brief Checks if the colliding wall is on east side or west side and then calls ImplementBarrierCollision(i) to carry out the required task. - * @param X @details is just the X axis coordinate of the nokia screen. - * @param i @details is the index of the snake beed and allows to check for all possible collisions with the snake respective to it's length. - */ - void CheckSnakeBlockSidesEastWestCollision(int X, int i); - - /** - * @brief 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. - * @param bar_sr_no @details is the index of which barrier collision we are detecting. - */ - void CheckSnakeBarrierCollision(int bar_sr_no); - - /** - * @brief This function checks if the Snake and blocks collide anywhere in the Y axis. - * @param i @details is the index of the snake beed and allows to check for all possible collisions with the snake respective to it's length. - * @param bar_sr_no @details is the index of which barrier collision we are detecting. - */ - 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. /** - * @brief Checks if the colliding barrier's side is on east side or west side of snake and then calls ImplementBarrierCollision(i) to carry out the required task. - * @param i @details is the index of the snake beed and allows to check for all possible collisions with the snake respective to it's length. - * @param bar_sr_no @details is the index of which barrier collision we are detecting. - */ - void CheckSnakeBarrierEastWestCollision(int i, int bar_sr_no); //i checks for all possible collisions with the snake respective to it's length. - - /** * @brief 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 on screen. */ void makeVirtualLengthMaxTen(); - /** - * @brief This function implements the sides collision by making the x axis speed of the particular snake beed 0. - * @param i @details is the index of the snake beed and allows to check for all possible collisions with the snake respective to it's length. +private: + + /* + This function checks if the Snake has come into contact with it's food. + */ + void CheckSnakeFoodCollision(); + + /* + This function automatically detects each combination of collision in the y postion. + food_sr -> creted in a loop that runs 3 times to detect collision with all the three food objects. + */ + void CheckSnakeFoodYCollision(int food_sr); + + /* + This function automatically detects each combination of collision in the x postion. + food_sr -> creted in a loop that runs 3 times to detect collision with all the three food objects. + */ + void CheckSnakeFoodXCollision(int food_sr); + + /* + This function automatically detects which food we are interacting with and increases the snake length accordingly. + food_sr -> creted in a loop that runs 3 times to detect collision with all the three food objects. + */ + void ImplementSnakeFoodCollision(int food_sr); + + /* + * @brief This function checks if the Snake has come into contact with any Block. + */ + void CheckSnakeBlockCollision(); + + /* + This function returns the srn of the block we are colliding with. + Block -> value of int block which is compared to a preset ranges, to allocate a serial number to the colliding block. + */ + int CheckCollidingBlock(int Block); + + /* + This function allows the appropriate maths to take place after every collision. + */ + void ImplementSnakeBlockCollision(); + + /* + This function checks if the Snake has come into contact with any the sides of the block and stops it moving. + */ + void CheckSnakeBlockSidesCollision(); + + /* + This function checks if the Snake and blocks collide anywhere in the Y axis. + i -> is the index of the snake beed and allows to check for all possible collisions with the snake respective to it's length. + */ + void CheckSnakeBlockSidesYCollision(int i); + + /* + This function checks if the Snake and blocks collide anywhere in the X axis. + i -> is the index of the snake beed and allows to check for all possible collisions with the snake respective to it's length. + */ + void CheckSnakeBlockSidesXCollision(int i); + + /* + Checks if the colliding wall is on east side or west side and then calls ImplementBarrierCollision(i) to carry out the required task. + X -> is just the X axis coordinate of the nokia screen. + i -> is the index of the snake beed and allows to check for all possible collisions with the snake respective to it's length. + */ + void CheckSnakeBlockSidesEastWestCollision(int X, int i); + + /* + 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. + bar_sr_no -> is the index of which barrier collision we are detecting. + */ + void CheckSnakeBarrierCollision(int bar_sr_no); + + /* + This function checks if the Snake and blocks collide anywhere in the Y axis. + i -> is the index of the snake beed and allows to check for all possible collisions with the snake respective to it's length. + bar_sr_no -> is the index of which barrier collision we are detecting. + */ + 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. + + /* + * Checks if the colliding barrier's side is on east side or west side of snake and then calls ImplementBarrierCollision(i) to carry out the required task. + * i -> is the index of the snake beed and allows to check for all possible collisions with the snake respective to it's length. + * bar_sr_no -> is the index of which barrier collision we are detecting. + */ + void CheckSnakeBarrierEastWestCollision(int i, int bar_sr_no); //i checks for all possible collisions with the snake respective to it's length. + + /* + This function implements the sides collision by making the x axis speed of the particular snake beed 0. + i -> is the index of the snake beed and allows to check for all possible collisions with the snake respective to it's length. */ void ImplementBarrierCollision(int i);