Skip to content

Latest commit

 

History

History
105 lines (86 loc) · 1.72 KB

10_ambush.md

File metadata and controls

105 lines (86 loc) · 1.72 KB

amahdy: Escape

map.defineObject('attackDrone', {
    'type': 'dynamic',
    'symbol': 'd',
    'color': 'red',
    'onCollision': function (player) {
        player.killedBy('an attack drone');
    },
    'behavior': function (me) {
          if (me.canMove('up')) {
              me.move('up');
          }else {
              me.move('left');
          }
    }
});

...

map.defineObject('defenseDrone', {
    'type': 'dynamic',
    'symbol': 'd',
    'color': 'green',
    'onCollision': function (player) {
        player.killedBy('a defense drone');
    },
    'behavior': function (me) {
          if (me.canMove('up')) {
              me.move('up');
          }else {
              me.move('right');
          }
    }
});

Jhack (giacgbj)

if( me.getY() < 13 )
  me.move( 'down' );
else if( me.getX() > 0 )
  me.move('left');

and

if( me.getY() < 13 )
  me.move('down');
else if( me.getX() < map.getWidth() )
  me.move('right');

Drones Madness

esolitos

attackDrone

if( me.canMove('down') ) {
    me.move('down');
} else if (me.canMove('right')) {
    me.move('right');
} else {
    me.move('left');
}

reinforcementDrone

me.move('left');

defenseDrone

if( me.canMove('down') ) {
    me.move('down');
} else if (me.canMove('left')) {
    me.move('left');
} else {
    me.move('right');
}

pk

all three drone types random moves toward ceil or right:

(Math.random()>.5) ? me.move('right') : me.move('up');

Super Easy Solution

Just reset the collision function:

this.onCollision = function(){};