class XORFaller : Movable { @CostumeAttribute var dir = 0 var opposite = 0 override fun begin() { super.begin() opposite = (dir + 2) % 4 speed = 8 } override fun myTurn() { val next = look(dir) if (next.squashable( dir)) { move(dir) } } override fun canPush( direction : int, speed : int, strength : int ) : boolean { if (direction == dir || direction == opposite) { return false } val next = look( direction ) if (next.squashable( direction ) ) { return true } return false } override fun push( direction : int, speed : int ) { move( direction ) } override fun moved( movement : Movement ) { super.moved( movement ) if (movement.direction == dir) { val next = look(dir).item() if (next.isPlayer()) { next.kill() } } // Don't stop moving if we can move again // Without this, a detonator could explode a bomb in mid-air (because // the bomb would pause between moves). if ( ! isMoving() ) { myTurn() } } }