Step 9: Star Destroyer Lose Life

Goal:


Two enemies down, one more to go. Let’s finish with our enemies by adding the lives lost and hit broadcast code to the Star Destroyer.

We never coded what happens if the X-Wing ran into the Star Destroyer so we are going to add that in as well.

Steps:

  1. From the sprite menu, select the one called Star_Destroyer.
  2. Find the block of code where we put the Star Destroyer collision code.
  3. From Control, place an IF statement block after the one for the Time_Bomb.
  4. From Sensing, place a touch mouse-pointer block inside of the IF statement and set it to X_Wing.
  5. From Variables, place a change by block.
  6. Set the variable to score and the amount to -5.
  7. From Variables, place change by block.
  8. Set the variable to Lives and the amount to -1.
  9. From Events, place a broadcast block and set it to Hit.

Code: