Bombs

Explosion animation

Obj: explosion

This object just shows the animation. When it’s done, it destroys itself. Note that this goes wrong if the person is next to the bomb! So make sure the triggers are not next to the bombs. 

 

Create a new object explosion and set the sprite.

Set the depth to "-10".

Start by adding a Create event and add a Destroy Instances action.

Check the box for relative.

Copy the Destroy Instances action (CTRL+C) and paste it (CTRL+V) 8 times (so you have a total of 9 of them). 

We want the bomb to destroy walls & monsters in the blocks around it as well.

So we will be setting the X & Y values as follows. (They should all be relative).

  1.  X = 16, Y = -16
  1. X = 16, Y = -16
  2. X = 16, Y = 16
  3. X = 16, Y = 48
  4. X =-16, Y = -16
  5. X = -16, Y = 16
  6. X = -16, Y = 48
  7. X = 48, Y = -16
  8. X = 48, Y = 16
  9. X = 48, Y = 48

If you go to "Show Information" it should look like this - and it's a quick way to see if you have any mistakes like in my example picture...

Check the values. To get out of this view, click on the check mark button...

Add one more event: Animation End with the Destroy Instance action.


Trigger the explosion

Obj: bomb

Create a new object bomb, with a bomb sprite (or dynamite). This object will just sit in the room, doing nothing. 

To make sure monsters move over it (instead of under it) we set its depth to 10.  Highest depth is drawn first, so lie behind others.

Obj: trigger

Create a new object trigger with the sprite. 

  • Collision with person
    • Play Sound (explosion)
    • Change Instance: changes the bomb object into the explosion object; set perform to "yes"
    • Destroy Instance

Room

Go in your testing room and delete everything (flag, door, diamonds, monsters). Then add a few bombs, with one of them being surrounded by extra walls like this in the upper left part of the room. Place the trigger near the person.

You can first test it out with having a bomb surrounded by walls like this... and when you trigger the bombs delete a wall in all directions like this...


Get it checked that it works. If you have the main controller somewhere in your testing room, then it's easy to blow it up over and over to get checked (use the "R" key to restart the room).