Box Breaking
Durability
Durability
The boxes can have a resistance level to damage.
The boxes can have a resistance level to damage.
Once that level reaches 0 - the box becomes breakable.
Once that level reaches 0 - the box becomes breakable.
Code Explanation
Code Explanation
When the Durability of the box is 0 or less
When the Durability of the box is 0 or less
AND the Hit animation is NOT playing
AND the Hit animation is NOT playing
Destroy the box
Destroy the box
Play an assoicated sound effect.
Play an assoicated sound effect.
Once Durability is <= 0 AND Hit is NOT playing:
Once Durability is <= 0 AND Hit is NOT playing:
Repeat the following code 4 times:
Repeat the following code 4 times:
Spawn the broken box sprite
Spawn the broken box sprite
Set the current frame to the current loop number
Set the current frame to the current loop number
Apply physics to send pieces in random directions
Apply physics to send pieces in random directions
Wait for 2 seconds
Wait for 2 seconds
Flash the broken pieces
Flash the broken pieces
Wait 1 second
Wait 1 second
Destroy the broken pieces
Destroy the broken pieces