This is an old revision of the document!
Only task headings have been provided. You are not expected to know how to do the task given by just that description (although in some cases it can be adequately figured out). Instead, if no further information is yet present, ASK FOR DETAILS on the discord, then contribute that clarity here.
If something is present but needs polish: spruce it up.
If something is present but is incorrect: please fix it.
This is intended to be an informative, useful document that all can benefit from.
Those with prior experience, please be mindful not to gobble up all the low-hanging fruit from the newcomers.
Game where you have a set of bricks that are breakable by the ball. You also have a paddle to bounce the ball towards the bricks. If the ball falls under the paddle, end game or lose lives.
There are many ways to check for collisions. First, an object that needs to be collided with has to have a hitbox. This means there needs to be a variable representation of an object's dimensions with an x variable and y variable. Since many parts of this game will have a hitbox, It might be smart to make a struct. A struct is a user defined data type that groups together variables; good for organization and helps with parameters with functions. You can make a struct containing x and y variables. This will make it so you don't have to individually make variables anymore, and can group them into one object through encapsulation. Though when using structs, if you want to pass them as parameters, you would have to learn about pointers.
Pointers are simply a variable that stores a memory address of other variables. pointers themselves have their own data types aswell, like an int datatype to the number 52. The pointer datatype has the goal of formatting data to represent a memory address of some given variable. Because of this, the pointer also needs to know to what type of variable it is pointing to. There could be a pointer that points to a memory address of an integer, or a pointer that points to the memory address of a string. In order to represent a memory address of a variable, it needs to know what type of variable it is pointing to. Pointers don't just point to the memory address of something, they can be dereferenced and reveal the value at which they are pointing at. to dereference a pointer, and reveal the value at the memory address that it is pointing at, there are many techniques. First let's define a pointer. To define a pointer, memory needs to be allocated manually within c, but only to the data that it is pointing to. int *hi; This is how you define a pointer. By itself, it is saying make a new pointer type of thing, that points to an integer. But in this format, the computer only allocates the memory for a pointer type, which stores a memory address, and not the thing being pointed to. The integer that is being pointed to has not yet had memory allocated for it. Normally behind the scenes, when you create a variable of some type of thing, memory is allocated automatically, but for pointers, they need to manually allocate memory for the thing that the pointer is pointing to.
malloc( [bytes] ) is a function that returns a pointer to the first memory address of a section of memory that is allocated based on the parameter of how big you want that space to be (in bytes).
one would need to allocate enough memory to represent an integer, if a pointer is pointing to that type.
There is a function that returns how big a datatype is in bytes: sizeof([type])
so to allocated enough memory for an integer manually you would do: malloc(sizeof(int)), which returns a pointer to the first address of the section of allocated memory whose size is the parameter passed in (how many bytes to make up an integer type of thing). to summarize it returns the pointer to the first address of a block of memory that is the size of an integer.
the pointer that is return though is a pointer that points to nothing, aka a null pointer. the pointer needs to be casted to change it's type to a int pointer.
(*int)malloc(sizeof(int)) -returns an int pointer
the variable that was first created can now be assigned to this
int *hi = (*int)malloc(sizeof(int));
now after all that, it can now be understood that a memory block that represents an integer has been allocated, and the starting address of that memory is now stored as a value to a pointer type, which when called, will give the starting address of the integer that is points to.