User Tools

Site Tools


notes:cprog:spring2025:projects:mtb4

This is an old revision of the document!


Table of Contents

MTB4

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.

URLs

power ups

It might be a good idea to implement structs to represent powerups. Within this struct, it would have an x and y value (this could be a struct in and of itself called point, which has two ints: x and y). The struct could also have a variable called type that represents what type of powerup it is, e.g., type = 1 for damage, and type = 2 for duplicating that ball. One easy way to represent all the possible powerups as integer values is through the use of enums (enumerations).

struct Powerup { Point position; int type; }

struct Point { int x, int y };

What is an enumerator? Microsoft definition: An enumeration type (or enum type) is a value type defined by a set of named constants of the underlying integral numeric type. this means that you can define named constants that have an underlying numeric value.

Example: enum Teachers { MATT = 1, JOE = 2 };

instead of literally typing 1, you could just write MATT, and it would automatically be replaced by the value 1.

Back to the context of powerups you could make an enum as such:

enum POWERUPS { Duplicate = 1, MoarDamage = 2, Faster = 3 };

then make a struct:

struct Powerup { Point position; int type; }

then define a struct with the desired powerup and position:

void main() { Powerup *ptrPowerup; ptrPowerup→position.x = screen_width / 2; ptrPowerup→position.y = screen_height / 2; ptrPowerup→type = DUPLICATE; }

after providing values, now everytime that you call ptrPowerup→type it will return 1, because DUPLICATE is defined as such.

notes/cprog/spring2025/projects/mtb4.1741811049.txt.gz · Last modified: 2025/03/12 20:24 by tstrickl