LIVES AND RESPAWNING
✓ Test your program - it should be displaying "Lives - 5" at the top.
Respawning the Player
We're going to override the die() method for the player class. This allows us to only remove the player from the game when it is out of lives. When the player still has lives, we'll simply move it, restore health, and reduce the life counter.
✓ Test your program! The player should be able to respawn.
Why invulnerability on respawn?
This is an optional step. All projects benefit from it, but it's only *required* if your player does not have a health system implemented.
A common problem in this kind of game is that the player might respawn on top of a bullet or in a dangerous location. To make things more easier for our players, we'll make their ship invulnerable for a few seconds.
In the act() method, we'll decrease that time by one so long as it is greater than zero.
A common strategy for showing invulnerability is to cause the image to "flicker" - displaying every other frame.
In your player's render method, we'll modify your call to the super.render() by surrounding it with a conditional. We want to render the image in one of two scenarios:
The timer is zero (player can take damage)
The timer is even (invulnerable - show every other frame)
✓ Test your program - the player won't actually be invulnerable, but it should flicker for about two seconds on respawn.
Actually Blocking Damage
Ignoring damage is actually pretty simple: we'll override the takeDamage method. Rather than rewriting it, we'll just say: "If I am not invulnerable, take damage like normal."
✓ Test your program - invulnerability should be working!