Monsters Moving

marker

To avoid monsters from falling off platforms, we introduce another object, which we call a marker. This marker will be an invisible blue block. Whenever a monster touches it, it reverses its direction of motion. 

monster moving back and forth

Create a new object monster. Set to the right facing monster sprite. 

Start with a Create event and set it to Move to the right at speed 4.

When the monster hits a block, it needs to reverse horizontal direction.

Add a Collision with marker event and set it to reverse direction. You can just duplicate the previous event.

facing direction

To have the monster facing the right direction, we need the End Step event. This event happens just before the instances are drawn. In it we set the correct sprite based on the the horizontal speed. If it is larger than 0 we let the monster face right and otherwise we let it face left. 

  • Test Variable:  if hspeed > 0
  • If it is, then Change Sprite to monsterR
  • Else
  • Change Sprite to monsterL

Room

  • add monsters on the floor and platforms (not in the air) as shown below
  • add markers just past the edges of platforms so they don't fall off. 

Test it out. If they work, keep going...