Squishing Monsters

We're going to make it so if the character jumps on top of the normal monster, it will squish/kill it.

Obj: monsterDead

Create a new object monsterDead.

  • Create event - Set Alarm0 to 10 steps
  • Alarm0 event - Destroy Instance

Kill monster if jump on it

We want to kill the monster if we jump on top of it. In order to do this we have to have 2 conditions met: 

Condition #1: The player should be moving downwards

vspeed > 0

 

Condition #2: The player has to be above the monster (or at least 8 pixels below the top of the monster)

y < other.y + 8


Go into your character object and then into the Collision with monster event. Add the action Test Expression to the top of the actions...

Copy/type in the following (we're combining these 2 things into a single expression). 

vspeed > 0 and y < other.y + 8

Then add the following actions after it...

  • Play Sound (kill monster)
  • Set Score: give player 50 points
  • Move Fixed: center, speed 0 (so doesn't move)
  • Change Instance: set to other (so monster, not character) and then change into monsterDead object, perform "yes"

We have 2 sets of actions. First add an Else to separate them...

Then drag start & end blocks at the beginning and end of the 2 sets of actions so we have this...


Test it out and make sure it works.