This is an old revision of the document!
What is a node struct? A node struct is used to represent an element, in our case, a brick, within a list.
An example of a structure for a node is as follows:
struct BrickNode { bool Active; int X, Y; // Position on screen int Width, Height; // Size of hitbox for brick BrickNode* next; // Pointer to the next brick node };
What is meant by malloc a node? while it is when you dynamically allocate memory create a new node in a list.
here is an example of what it could possible look like:
// Creates a new node for each brick BrickNode* newBrick = (BrickNode*)malloc(sizeof(BrickNode)); </code? =====LINKING NODES TOGETHER===== Format for linking nodes together: <code C> newBrick->next = BrickList;
This line of code is linking the new brick node into the list. here's how it works:
newBrick
which is a node for each brick, is set to point to the current head of the list essentially putting a new node at the beginning of the list. This is done with
->next = BrickList