SHARE
TWEET

Untitled

a guest Jul 17th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*************
  2. * colors.js *
  3.  *************
  4.  *
  5.  * You're almost at the exit. You just need to get past this
  6.  * color lock.
  7.  *
  8.  * Changing your environment is no longer enough. You must
  9.  * learn to change yourself. I've sent you a little something
  10.  * that should help with that.
  11.  */
  12.  
  13. function startLevel(map) {
  14.     map.placePlayer(0, 12);
  15.  
  16.     map.placeObject(5, 12, 'phone');
  17.  
  18.     // The function phone lets you call arbitrary functions,
  19.     // as defined by player.setPhoneCallback() below.
  20.     // The function phone callback is bound to Q or Ctrl-6.
  21.     map.getPlayer().setPhoneCallback(function () {
  22.         var player = map.getPlayer();
  23.  
  24.         var color = player.getColor();
  25.         switch (color) {
  26.             case "#f00":
  27.                 player.setColor('#0f0');
  28.                 break;
  29.             case "#0f0":
  30.                 player.setColor('#ff0');
  31.                 break;
  32.             case "#ff0":
  33.                 player.setColor('#f00');
  34.                 break;
  35.         }
  36.        
  37.        
  38.  
  39.  
  40.  
  41.  
  42.     });
  43.  
  44.  
  45.     map.defineObject('redLock', {
  46.         symbol: '☒',
  47.         color: "#f00", // red
  48.         impassable: function(player, object) {
  49.             return player.getColor() != object.color;
  50.         }
  51.     });
  52.  
  53.     map.defineObject('greenLock', {
  54.         symbol: '☒',
  55.         color: "#0f0", // green
  56.         impassable: function(player, object) {
  57.             return player.getColor() != object.color;
  58.         }
  59.     });
  60.  
  61.     map.defineObject('yellowLock', {
  62.         symbol: '☒',
  63.         color: "#ff0", // yellow
  64.         impassable: function(player, object) {
  65.             return player.getColor() != object.color;
  66.         }
  67.     });
  68.  
  69.     for (var x = 20; x <= 40; x++) {
  70.         map.placeObject(x, 11, 'block');
  71.         map.placeObject(x, 13, 'block');
  72.     }
  73.     map.placeObject(22, 12, 'greenLock');
  74.     map.placeObject(25, 12, 'redLock');
  75.     map.placeObject(28, 12, 'yellowLock');
  76.     map.placeObject(31, 12, 'greenLock');
  77.     map.placeObject(34, 12, 'redLock');
  78.     map.placeObject(37, 12, 'yellowLock');
  79.     map.placeObject(40, 12, 'exit');
  80.     for (var y = 0; y < map.getHeight(); y++) {
  81.         if (y != 12) {
  82.             map.placeObject(40, y, 'block');
  83.         }
  84.         for (var x = 41; x < map.getWidth(); x++) {
  85.             map.setSquareColor(x, y, '#080');
  86.         }
  87.     }
  88. }
  89.  
  90. function validateLevel(map) {
  91.     map.validateExactlyXManyObjects(1, 'exit');
  92. }
  93.  
  94. function onExit(map) {
  95.     if (!map.getPlayer().hasItem('phone')) {
  96.         map.writeStatus("We need the phone!");
  97.         return false;
  98.     } else {
  99.         return true;
  100.     }
  101. }
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