![](/media/cache/profiles/LinkedIn_0NghoZJ.jpeg.50x50_q85.jpg)
Snake vs Block Game to be run upon K64F.
GameEngine/SnakevsBlock/SnakevsBlock.h
- Committer:
- AhmedPlaymaker
- Date:
- 2019-04-26
- Revision:
- 51:387249f9b333
- Parent:
- SnakevsBlock/SnakevsBlock.h@ 49:441c32f6603e
- Child:
- 56:142e9fdb77a8
File content as of revision 51:387249f9b333:
#ifndef SNAKEVSBLOCK_H #define SNAKEVSBLOCK_H #include "mbed.h" #include "N5110.h" #include "FXOS8700CQ.h" #include "Gamepad.h" #include "Snake.h" #include "LengthCalc.h" #include "WinLoose.h" #include "SnakeFood.h" #include "Blocks.h" #include "StartScreen.h" #include "Stats.h" #include "SDFileSystem.h" class SnakevsBlock { 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); /** Update * * This function contains the update functions of the other libraries used in the game. */ int update(N5110 &lcd, Gamepad &pad, SDFileSystem &sd); /** Draw * * This function contains the draw functions of the other libraries used in the game. */ void draw(N5110 &lcd, Gamepad &pad); /** 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; int velocity; //this is to stop/move the background (food and blocks), when collision occurs at a length greater than 10. int level; char bufferlevel[14]; //this helps me print the level on screen. int garbage; //to save the angle at the point button A is pressed. float angle; //saves the angle of tilt. int foodbuff; //this makes food 1,2,and 3 come at seperate times int blocknum; int blockgap; //to change frequency of fall int blockbuff; // to manage the fall of food relative to the blocks int srn; int send_block_number; //makes sure that the block number is only updated when send is activated. int back; //enables the player to go back on main menu if back is pressed. int b[15]; int b0_to_b14[15]; int *b_number; //pointer to save the numbers inside the block. Vector2D snake_pos[15]; Vector2D food_pos[3]; Vector2D b_pos; private: Snake _s; LengthCalc _l; WinLoose _wl; SnakeFood _f; SnakeFood _ff; SnakeFood _fff; Blocks _b; Stats _Setstats; int _speed; int _length; Direction _d; 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); }; #endif