Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Dec 6th, 2018 54 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. /*
  2.  * robotNav.js
  3.  *
  4.  * The green key is located in a slightly more
  5.  * complicated room. You'll need to get the robot
  6.  * past these obstacles.
  7.  */
  8.  
  9. function startLevel(map) {
  10.     // Hint: you can press R or 5 to "rest" and not move the
  11.     // player, while the robot moves around.
  12.  
  13.     map.placePlayer(0, map.getHeight() - 1);
  14.     var player = map.getPlayer();
  15.  
  16.     map.defineObject('robot', {
  17.         'type': 'dynamic',
  18.         'symbol': 'R',
  19.         'color': 'gray',
  20.         'onCollision': function (player, me) {
  21.             me.giveItemTo(player, 'greenKey');
  22.         },
  23.         'behavior': function (me) {
  24.      if( me.getX() == 1 && me.getY() < 4 ){
  25.     me.move('down');
  26.  
  27. } else if( me.getY() == 4) {
  28.     if( me.canMove('right') ) {
  29.         me.move('right');
  30.     } else {
  31.         me.move('down');
  32.     }
  33.  
  34.  
  35. } else if( me.getY() > 4 ) {
  36.  
  37.     if( me.canMove('right') ) {
  38.         me.move('right');
  39.     } else if ( me.getX() != map.getWidth() -2 ) {
  40.         me.move('up');
  41.     } else {
  42.         me.move('down');
  43.     }
  44. }
  45.  
  46.         }
  47.     });
  48.  
  49.     map.defineObject('barrier', {
  50.         'symbol': '░',
  51.         'color': 'purple',
  52.         'impassable': true,
  53.         'passableFor': ['robot']
  54.     });
  55.  
  56.     map.placeObject(map.getWidth() - 1, map.getHeight() - 1, 'exit');
  57.     map.placeObject(1, 1, 'robot');
  58.     map.placeObject(map.getWidth() - 2, 8, 'greenKey');
  59.     map.placeObject(map.getWidth() - 2, 9, 'barrier');
  60.  
  61.     for (var x = 0; x < map.getWidth(); x++) {
  62.         map.placeObject(x, 0, 'block');
  63.         if (x != map.getWidth() - 2) {
  64.             map.placeObject(x, 9, 'block');
  65.         }
  66.     }
  67.  
  68.     for (var y = 1; y < 9; y++) {
  69.         map.placeObject(0, y, 'block');
  70.         map.placeObject(map.getWidth() - 1, y, 'block');
  71.     }
  72.  
  73.     for (var i = 0; i < 4; i++) {
  74.         map.placeObject(20 - i, i + 1, 'block');
  75.         map.placeObject(35 - i, 8 - i, 'block');
  76.     }
  77. }
  78.  
  79. function validateLevel(map) {
  80.     map.validateExactlyXManyObjects(1, 'exit');
  81.     map.validateExactlyXManyObjects(1, 'robot');
  82.     map.validateAtMostXObjects(1, 'greenKey');
  83. }
  84.  
  85. function onExit(map) {
  86.     if (!map.getPlayer().hasItem('greenKey')) {
  87.         map.writeStatus("We need to get that key!");
  88.         return false;
  89.     } else {
  90.         return true;
  91.     }
  92. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top