Creating New Life: The 1UP Powerup, Part 2

Sherry Fisher
2 min readDec 4, 2023

--

Objective: To fix my 1UP powerup script to repair damage to player.

Damaged player

In Part 1, I created the 1UP powerup but ran out of time and had to leave it with a couple of issues. First, the player received an error message if their lives were already full and they collected the 1UP. The second issue was I did not account for the damage the player had sustained previously. The powerup should repair the damaged ship. Below is my previous code. I should have known it would not be this easy!

To resolve the issues, I added if-else statements to the OneUpPowerup method. If the lives are already full, then the method is exited and nothing executes. If lives equal 2, then the player gets one life and the left engine is repaired. If lives equal 1, then the player gets one life and the right engine is repaired.

Then I test to ensure it is all working now. It took many minutes of game play to test all the conditions, so I won’t post the whole video as it is pretty long, but here is a short clip demonstrating the new powerup.

https://www.youtube.com/watch?v=KAAZc4wOQJ4

--

--