Power Up System
SWITCH STATEMENT | GAME BASED EXAMPLE
GOAL: Create a simple switch statement to compare the value of a variable against the value of a collected power up to activate the correct ability.
CODE BREAK-DOWN
LINE 5 --> Switch statement is declared that will evaluate the value of the variable _powerUp and compare it to each case
LINE 7, 10, & 13 --> Once the statement finds a case value that matches the value of _powerUp, the program runs the associated code
LINE 16 --> If none of the case values matches the value of _powerUp, then the program runs the associated code found in the Default Case
Last updated