Create a class for a player that has the following properties:
Boolean(Is a star active?)
function- sets 'name' to "Mario" or "Luigi". Has a parameter called
namePickedwhere you pass in "Mario" or "Luigi"
function- this is called whenever the player is hit by an enemy.
gotHit()will set the
statusproperty accordingly. (Statuses go from "Powered Up" to "Big" to "Small" to "Dead".)
function- called when a powerup is received and sets the status accordingly. (Statuses go from "Small" to "Big" to "Powered Up". If you are Powered Up and it hits this function, you get a star)
Boolean, true by default, becomes false when
function- adds a coin to totalCoins
function- prints to the console the name, totalCoins, status, and star properties. Make sure you make this look nice such as:
- Name: Luigi,
- Status: Small, etc, etc
Use that class to create the object.
Create a random range function that returns either 0, 1, or 2.
If the value is 0 call the
gotHit() function on the object.
If the value is 1 call the
gotPowerup() function on the object
If the value is 2 call the
Then call the print method on the object.
Now put the random range function inside a
setInterval function that ends after
gameActive === false
The end product will look something like this: