Snake vs Block Game to be run upon K64F.
Blocks Class Reference
#include <Blocks.h>
Public Member Functions | |
Blocks () | |
Constructor. | |
~Blocks () | |
Destructor. | |
void | init (N5110 *lcd) |
Initialises the blocks position struct and reset variable and gets pointers of lcd from int main() to be used privately in the entire class. | |
void | draw (int length) |
This function draws the blocks onto the screen and selects numbers to be stored in them. | |
void | DrawFrame () |
This function draws the Block's sides onto the screen as the blocks are basically individual boxes without sides. | |
void | ChooseBlocks () |
This function chooses the correct block using a case structure and draws them onto the screen. | |
void | update (int blocknum, int blockgap, int srn, bool send_block_number) |
This function updates the position of the Blocks as they move down the screen by reacting to collisions if any. | |
Vector2D | get_pos () |
This function sends the coordinates of the top-left pixel in the Blocks sprites. | |
int * | get_number () |
This function sends the number inside the Blocks sprite at a specefic location. | |
void | set_pos (Vector2D p) |
This function is used to change the position of the sprite to specific coordinates when called. |
Detailed Description
Blocks Class.
This class draws and updates blocks after every collision, and randomly, but logically assigns numbers to the block.
- Date:
- 9th May 2019
Definition at line 13 of file Blocks.h.
Constructor & Destructor Documentation
Blocks | ( | ) |
Constructor.
Definition at line 3 of file Blocks.cpp.
~Blocks | ( | ) |
Destructor.
Definition at line 8 of file Blocks.cpp.
Member Function Documentation
void ChooseBlocks | ( | ) |
This function chooses the correct block using a case structure and draws them onto the screen.
Definition at line 317 of file Blocks.cpp.
void draw | ( | int | length ) |
This function draws the blocks onto the screen and selects numbers to be stored in them.
- Parameters:
-
length This is the length of the snake, which is recieved from the SnakevsBlocks class to store numbers with relation to it's length.
Definition at line 285 of file Blocks.cpp.
void DrawFrame | ( | ) |
This function draws the Block's sides onto the screen as the blocks are basically individual boxes without sides.
Definition at line 311 of file Blocks.cpp.
int * get_number | ( | ) |
This function sends the number inside the Blocks sprite at a specefic location.
- Returns:
- caseselect[5]
The array of all the numbers saved inside the blocks.
Definition at line 385 of file Blocks.cpp.
Vector2D get_pos | ( | ) |
This function sends the coordinates of the top-left pixel in the Blocks sprites.
- Returns:
- Vector2D blockpos
This is a struct that returns the x and y position of the origin of the blocks sprite to be read.
Definition at line 378 of file Blocks.cpp.
void init | ( | N5110 * | lcd ) |
Initialises the blocks position struct and reset variable and gets pointers of lcd from int main() to be used privately in the entire class.
- Parameters:
-
N5110 *lcd
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.
Definition at line 276 of file Blocks.cpp.
void set_pos | ( | Vector2D | p ) |
This function is used to change the position of the sprite to specific coordinates when called.
- Parameters:
-
Vector2D p
Stores the values from the struct obtained as the new coordinates of the block.
Definition at line 404 of file Blocks.cpp.
void update | ( | int | blocknum, |
int | blockgap, | ||
int | srn, | ||
bool | send_block_number | ||
) |
This function updates the position of the Blocks as they move down the screen by reacting to collisions if any.
- Parameters:
-
blocknum saves the numbers inside the block with respect to it's serial number. blockgap this is the amount in pixels of the gap between blocks and sets the frequency of block fall. srn sr number of the block we are refering to (1 to 5). send_block_number makes sure that the block number is only updated when this is at a logic of 1.
Definition at line 391 of file Blocks.cpp.
Generated on Wed Jul 13 2022 04:14:35 by 1.7.2