This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
notes:cprog:spring2025:projects:mtb4 [2025/03/12 20:24] – [logic to implement] tstrickl | notes:cprog:spring2025:projects:mtb4 [2025/03/13 03:45] (current) – [power ups] bdildine | ||
---|---|---|---|
Line 40: | Line 40: | ||
}; | }; | ||
- | instead of literally typing 1, you could just write MATT, and it would automatically be replaced by the value 1. | + | instead of literally typing 1, you could just write MATT, and it would represent |
- | Back to the context of powerups you could make an enum as such: | + | Back to the context of powerups, you could make an enum as such: |
enum POWERUPS | enum POWERUPS | ||
{ | { | ||
- | Duplicate | + | DUPLICATE |
- | MoarDamage | + | MOARDAMAGE |
- | Faster | + | FASTER |
}; | }; | ||
Line 56: | Line 56: | ||
{ | { | ||
Point position; | Point position; | ||
- | int type; | + | POWERUPS |
} | } | ||
- | then define | + | then create |
+ | < | ||
void main() | void main() | ||
{ | { | ||
- | | + | |
- | | + | |
| | ||
- | | + | |
} | } | ||
+ | </ | ||
+ | now everytime that you call ptrPowerup-> | ||
- | after providing values, now everytime | + | Some Power-Ups you could make could range from trivial to more difficult. One could be a Power-Up |
+ | You can accomplish this by checking if the Power-Up is active, then selecting a different region before drawing the paddle and the given coordinates. | ||
+ | You will of course need to change the boundaries in which the ball collides with the bigger paddle as well. | ||
+ | If you are using an array to track your Power-Ups, it would look something like: | ||
+ | < | ||
+ | if ( PowerUpCollected[1] == true ) | ||
+ | { | ||
+ | select_region( RegionLargePaddle ); | ||
+ | } else { | ||
+ | select_region( RegionPaddle ); | ||
+ | } | ||
+ | draw_region_at( PaddleX, PaddleY ); | ||
+ | </ |