![](/media/cache/profiles/LinkedIn_0NghoZJ.jpeg.50x50_q85.jpg)
Snake vs Block Game to be run upon K64F.
Diff: GameObjects/SnakeFood/SnakeFood.h
- Revision:
- 97:819c0689efa7
- Parent:
- 83:329da564799a
--- a/GameObjects/SnakeFood/SnakeFood.h Thu May 09 09:23:57 2019 +0000 +++ b/GameObjects/SnakeFood/SnakeFood.h Thu May 09 09:39:02 2019 +0000 @@ -5,49 +5,53 @@ #include "N5110.h" #include "Gamepad.h" - +/** SnakeFood Class +@brief This class draws and updates snake food sprites after every collision. +@author Ahmed N.Adamjee +@date 9th May 2019 +*/ class SnakeFood { - public: +public: + /** Constructor */ SnakeFood(); + /** Destructor */ ~SnakeFood(); - - /** Initialise SnakeFood - * - * This function initialises the SnakeFood library. + + /** + * @brief Initialises the snake food 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 SnakeFood sprite onto the screen. + + /** + * @brief This function draws the SnakeFood sprite onto the screen. */ void draw(); - - /** Update - * - * This function updates the position of the SnakeFood as it moves down the screen. + + /** + * @brief This function updates the position of the SnakeFood as it moves down the screen. */ void update(); - - /** Get Position - * - * This function obtains the coordinates of the top-left pixel in the SnakeFood sprite. + + /** + * @brief This function obtains the coordinates of the top-left pixel in the SnakeFood sprite. + * @returns Vector2D snakefoodpos @details This is a struct that returns the x and y position of the origin of the snake food sprite to be read. */ Vector2D get_pos(); - - /** 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 food. */ void set_pos(Vector2D p); - Vector2D velocity; + + Vector2D velocity; //This is a struct that stores the x and y axis velocities of the snakefood. - private: - int reset; +private: + int reset; //reset is used to draw a new set of food. int _fx; //food x int _fy; //food y - int _blockbuff; //Pointer to the game pad object pad. Gamepad *_pad;