Skip to content

Instantly share code, notes, and snippets.

@Visgean
Created February 5, 2015 23:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Visgean/81aac615f54db161d7ba to your computer and use it in GitHub Desktop.
Save Visgean/81aac615f54db161d7ba to your computer and use it in GitHub Desktop.
map.defineObject('bl_up', {
'type': 'dynamic',
'symbol': '.',
'color': 'yellow',
'interval': 100,
'projectile': true,
'behavior': function (me) {
me.move('up');
}
});
map.defineObject('bl_down', {
'type': 'dynamic',
'symbol': '.',
'color': 'yellow',
'interval': 100,
'projectile': true,
'behavior': function (me) {
me.move('down');
}
});
map.defineObject('bl_right', {
'type': 'dynamic',
'symbol': '.',
'color': 'yellow',
'interval': 100,
'projectile': true,
'behavior': function (me) {
me.move('right');
}
});
map.defineObject('bl_left', {
'type': 'dynamic',
'symbol': '.',
'color': 'yellow',
'interval': 100,
'projectile': true,
'behavior': function (me) {
me.move('left');
}
});
map.overrideKey('up', function () {
var pl = map.getPlayer();
map.placeObject(pl.getX(), pl.getY() - 4, 'bl_up');
pl.move('up');
});
map.overrideKey('down', function () {
var pl = map.getPlayer();
map.placeObject(pl.getX(), pl.getY() + 4, 'bl_down');
pl.move('down');
});
map.overrideKey('right', function () {
var pl = map.getPlayer();
map.placeObject(pl.getX() + 4, pl.getY(), 'bl_right');
pl.move('right');
});
map.overrideKey('left', function () {
var pl = map.getPlayer();
map.placeObject(pl.getX() - 4, pl.getY(), 'bl_left');
pl.move('left');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment