SHARE
TWEET

Untitled

a guest Apr 19th, 2019 73 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.         if(player.getColor()=='#0f0')
  25.             player.setColor('#f00');
  26.         else if(player.getColor()=='#f00')
  27.             player.setColor('#ff0');
  28.         else if(player.getColor()=='#ff0')
  29.             player.setColor('#0f0');
  30.            
  31.        
  32.  
  33.     });
  34.  
  35.  
  36.     map.defineObject('redLock', {
  37.         symbol: '☒',
  38.         color: "#f00", // red
  39.         impassable: function(player, object) {
  40.             return player.getColor() != object.color;
  41.         }
  42.     });
  43.  
  44.     map.defineObject('greenLock', {
  45.         symbol: '☒',
  46.         color: "#0f0", // green
  47.         impassable: function(player, object) {
  48.             return player.getColor() != object.color;
  49.         }
  50.     });
  51.  
  52.     map.defineObject('yellowLock', {
  53.         symbol: '☒',
  54.         color: "#ff0", // yellow
  55.         impassable: function(player, object) {
  56.             return player.getColor() != object.color;
  57.         }
  58.     });
  59.  
  60.     for (var x = 20; x <= 40; x++) {
  61.         map.placeObject(x, 11, 'block');
  62.         map.placeObject(x, 13, 'block');
  63.     }
  64.     map.placeObject(22, 12, 'greenLock');
  65.     map.placeObject(25, 12, 'redLock');
  66.     map.placeObject(28, 12, 'yellowLock');
  67.     map.placeObject(31, 12, 'greenLock');
  68.     map.placeObject(34, 12, 'redLock');
  69.     map.placeObject(37, 12, 'yellowLock');
  70.     map.placeObject(40, 12, 'exit');
  71.     for (var y = 0; y < map.getHeight(); y++) {
  72.         if (y != 12) {
  73.             map.placeObject(40, y, 'block');
  74.         }
  75.         for (var x = 41; x < map.getWidth(); x++) {
  76.             map.setSquareColor(x, y, '#080');
  77.         }
  78.     }
  79. }
  80.  
  81. function validateLevel(map) {
  82.     map.validateExactlyXManyObjects(1, 'exit');
  83. }
  84.  
  85. function onExit(map) {
  86.     if (!map.getPlayer().hasItem('phone')) {
  87.         map.writeStatus("We need the phone!");
  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