Ahmed Adamjee
/
SnakeVSBlock
Snake vs Block Game to be run upon K64F.
Diff: GameEngine/SnakevsBlock/SnakevsBlock.h
- Revision:
- 62:ebf6ecf8a6d5
- Parent:
- 59:c65a2e933c47
- Child:
- 63:205f0ca48473
diff -r f3c402bc2ad0 -r ebf6ecf8a6d5 GameEngine/SnakevsBlock/SnakevsBlock.h --- a/GameEngine/SnakevsBlock/SnakevsBlock.h Tue Apr 30 08:32:30 2019 +0000 +++ b/GameEngine/SnakevsBlock/SnakevsBlock.h Tue Apr 30 14:53:38 2019 +0000 @@ -16,64 +16,64 @@ class SnakevsBlock { - public: +public: SnakevsBlock(); ~SnakevsBlock(); - + /** Initialise Game Machine * * This function initialises the game machine. */ void init(); - + /** Reset Game Machine * * This function prepares the game machine for the next level. */ void reset( ); - + /** Initialise objects * * This function initialises the objects that are used to functionalise the game. */ void object_initialisations(); - + /** Read Input * * This function obtains numeric data from the gamepads joystick. */ void read_input(Gamepad &pad, FXOS8700CQ &device, int gm); - - /** Draw + + /** Draw * * This function contains the draw functions of the other libraries used in the game. */ void draw(N5110 &lcd, Gamepad &pad); - + /** Update * * This function contains the update functions of the other libraries used in the game. */ int update(N5110 &lcd, Gamepad &pad, SDFileSystem &sd); - + /** Get Position * * This function contains the Get Position functions of the otehr libraries used in the game. */ void get_pos(); - + /** Check Block * * This function returns the srn of the block we are colliding with; */ int CheckBlock(int Block); - + /** Implement Collision * * This function allows the appropriate maths to take place after every collision. */ void ImplementCollision(Gamepad &pad); - + int snakex; //x position of top beed int snakey; //y position of top beed int length; //saves the length of the snake, for collision detection relative to it's length and calculations. @@ -93,8 +93,10 @@ Vector2D snake_pos[15]; //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). - - private: + + //Gamepad @enginePad + +private: Snake _s; LengthCalc _l; WinLoose _wl; @@ -110,29 +112,53 @@ float _mag; int _detect_slowly; //this makes sure that when the length is more than 10, the colliding block doesnt decrease the all the length in a single itteration. int n; - + /** Check for Snake and Food collision * * This function checks if the Snake has come into contact with it's food. */ void CheckSnakeFoodCollision(Gamepad &pad); - + /** Check for Snake and Block collision * * This function checks if the Snake has come into contact with any Block. */ void CheckSnakeBlockCollision(Gamepad &pad); - + /** Implement velocity alteration. * * this is to stop/move the background (food and blocks), when collision occurs at a length greater than 10.lock. */ void _set_velocity(); - + /** Check for Snake and Block Sides collision * * This function checks if the Snake has come into contact with any the sides of the block and stops it moving. */ void CheckSnakeBlockSidesCollision(Gamepad &pad); + + /** Check Collision in Y axis + * + * This function checks if the Snake and blocks collide anywhere in the Y axis. + */ + void check_Collision_Y_axis(int i); + + /** Check Collision in X axis + * + * This function checks if the Snake and blocks collide anywhere in the X axis. + */ + void check_Collision_X_axis(int i); + + /** Check Collision East or West + * + * checks if the colliding wall is on east side or west side and then calls StopX_AxisMotion(length,i) to carry out the required task. + */ + void checkCollision_EastorWest(int b_x_combination, int i); + + /** Stop X Axis Motion + * + * This function implements the sides collision by making the x axis speed of the particular snake beed 0. + */ + void StopX_AxisMotion(int length, int i); }; #endif \ No newline at end of file