Blocks & Holes

Block: moving

Obj: block

Create a new object block with the sprite. 

Make it solid and set the parent to "wall".

  • Collision with person
    • Check Empty:  (4*other.hspeed, 4*other.vspeed); objects = "All", relative.
    • add Start and End blocks, between them add:
      • Play Sound (push)
      • Jump to Position: (4*other.hspeed,4*other.vspeed), relative

Obj: person

Go into your person object and add a Collision with block event - add the Comment "do nothing" (this just helps make it work, prevents some other action from automatically happening).

Room

Go into your testing room, add a few block objects (not near any walls) 

Test it out - does the person push them in all directions?


Blocks: get rid of holes

Obj: hole

Create a new object hole with any sprite from the "holes" folder.

Make it solid and set parent to "wall" (so the person can't go through it).

  • Collision with block
    • Play Sound ("hole")
    • Destroy instance (self = hole)
    • Destroy instance (other = block )

Obj: block

Go into your block object. Copy the Jump to Position action and paste it below.

Now add Else and then Start and End blocks around it.

Inside the bottom section, add 

  • Check Object: object "hole", (4*other.hspeed, 4*other.vspeed), relative

Room

Now place a few holes in the testing room with walls - one really close to the person so we can quickly check that the person can't go through it. The other that we'll push a block into.

Test it out:

  • your person should not be able to go through them, and
  • if the block collides, the hole should disappear.

Have your game playing and get it checked ...