SHARE
TWEET

Untitled

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