The Princess Is In Another Castle
Requirements:
-
Create a class for a player that has the following properties:
-
nameof typeString -
totalCoinsof typeNumber -
statusof typeString(options arePowered Up,Big,Small, andDead) -
hasStarof typeBoolean(Is a star active?) -
setNameof typefunction- Has a parameter callednamePickedwhere you pass in "Mario" or "Luigi". Setsnameto "Mario" or "Luigi". -
gotHitof typefunction- this is called whenever the player is hit by an enemy.gotHit()will set thestatusproperty accordingly. (Statuses go from "Powered Up" to "Big" to "Small" to "Dead".) -
gotPowerupof typefunction- 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) -
gameActiveof typeBoolean, true by default, becomes false whenstatusis Dead -
addCoinoffunction- adds a coin to totalCoins -
printof typefunction- 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 addCoin() function
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: