Ahmed Adamjee
/
SnakeVSBlock
Snake vs Block Game to be run upon K64F.
Diff: GameObjects/Blocks/Blocks.h
- Revision:
- 95:b068b0735f45
- Parent:
- 84:9950d561fdf8
- Child:
- 96:1ab67b3e6898
diff -r 4e603bd6c381 -r b068b0735f45 GameObjects/Blocks/Blocks.h --- a/GameObjects/Blocks/Blocks.h Wed May 08 23:36:12 2019 +0000 +++ b/GameObjects/Blocks/Blocks.h Thu May 09 08:35:02 2019 +0000 @@ -5,69 +5,76 @@ #include "N5110.h" #include "Gamepad.h" - +/** Blocks Class +@brief This class draws and updates blocks after every collision, and randomly, but logically assigns numbers to the block. +@author Ahmed N.Adamjee +@date 8th May 2019 +*/ class Blocks { - public: +public: + /** Constructor */ Blocks(); + /** Destructor */ ~Blocks(); - /** Initialise Blocks - * - * This function initialises the Blocks library. + + /** + * @brief Initialises the blocks position struct and reset variable and gets pointers of lcd from int main() to be used privately in the entire class. + * @param N5110 *lcd @details pointer to the N5110 object in main, address of this pointer is saved to make availability to the entire class, without passing address to each function. */ void init(N5110 *lcd); - - /** Draw - * - * This function draws the Blocks onto the screen. + + /** + * @brief This function draws the blocks onto the screen and selects numbers to be stored in them. + * @param length @details This is the length of the snake, which is recieved from the SnakevsBlocks class to store numbers with relation to it's length. */ void draw(int length); - - /** Draw Frame - * - * This function draws the Blocks' sides onto the screen. + + /** + * @brief This function draws the Block's sides onto the screen as the blocks are basically individual boxes without sides. */ void DrawFrame(); - - /** Choose Blocks - * - * This function chooses the correct block using a case structure and draws them onto the screen. + + /** + * @brief This function chooses the correct block using a case structure and draws them onto the screen. */ void ChooseBlocks(); - - /** Update - * - * This function updates the position of the Blocks as they move down the screen. + + /** + * @brief This function updates the position of the Blocks as they move down the screen by reacting to collisions if any. + * @param blocknum @details saves the numbers inside the block with respect to it's serial number. + * @param blockgap @details this is the amount in pixels of the gap between blocks and sets the frequency of block fall. + * @param srn @details sr number of the block we are refering to (1 to 5). + * @param send_block_number @details makes sure that the block number is only updated when this is at a logic of 1. */ - void update(int blocknum, int blockgap, int srn, int send_block_number); - - /** Get Position - * - * This function obtains the coordinates of the top-left pixel in the Blocks sprites. + void update(int blocknum, int blockgap, int srn, bool send_block_number); + + /** + * @brief This function sends the coordinates of the top-left pixel in the Blocks sprites. + * @returns Vector2D blockpos @details This is a struct that saves the x and y psition of the origin of the blocks sprite to be read. */ Vector2D get_pos(); - - /** Get Number - * - * This function obtains the number inside the Blocks sprite at a specefic location. + + /** + * @brief This function sends the number inside the Blocks sprite at a specefic location. + * @returns caseselect[5] @details The array of all the numbers saved inside the blocks. */ int * get_number(); - - /** Set Position - * - * This function is used to change the position of the sprite to specific coordinates when called. + + /** + * @brief This function is used to change the position of the sprite to specific coordinates when called. + * @param Vector2D p @details Stores the values from the struct obtained as the new coordinates of the block. */ void set_pos(Vector2D p); + + double round; //used to save the rounded number to set the value inside the block. - int caseselect[5]; - int send; - Vector2D velocity; - - + int caseselect[5]; //The array of all the numbers saved inside the blocks. + Vector2D velocity; //This is a struct that stores the x and y axis velocities of the blocks. - private: - int _length; - int reset; +private: + int _length; //length of the snake + int reset; //reset is used to draw a new set of blocks. int _bx; //block x int _by; //block y