SHARE
TWEET

Untitled

a guest May 25th, 2019 63 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.         player.setColor('#f00');
  25. var player = map.getPlayer();
  26.  
  27. map.placeObject(21, 12, 'greenUnlock');
  28. map.placeObject(24, 12, 'redUnlock');
  29. map.placeObject(27, 12, 'yellowUnlock');
  30. map.placeObject(30, 12, 'greenUnlock');
  31. map.placeObject(33, 12, 'redUnlock');
  32. map.placeObject(36, 12, 'yellowUnlock');
  33. });
  34.  
  35. map.defineObject('redUnlock', {
  36. symbol: '☒',
  37. color: "#f00", // red
  38. 'onCollision': function (player) {
  39.     player.setColor('#f00');
  40. }
  41. });
  42.  
  43. map.defineObject('greenUnlock', {
  44. symbol: '☒',
  45. color: "#0f0", // green
  46. 'onCollision': function (player) {
  47.     player.setColor('#0f0');
  48. }
  49. });
  50.  
  51. map.defineObject('yellowUnlock', {
  52. symbol: '☒',
  53. color: "#ff0", // yellow
  54. 'onCollision': function (player) {
  55.     player.setColor('#ff0');
  56. }
  57.  
  58.  
  59.  
  60.  
  61.     });
  62.  
  63.  
  64.     map.defineObject('redLock', {
  65.         symbol: '☒',
  66.         color: "#f00", // red
  67.         impassable: function(player, object) {
  68.             return player.getColor() != object.color;
  69.         }
  70.     });
  71.  
  72.     map.defineObject('greenLock', {
  73.         symbol: '☒',
  74.         color: "#0f0", // green
  75.         impassable: function(player, object) {
  76.             return player.getColor() != object.color;
  77.         }
  78.     });
  79.  
  80.     map.defineObject('yellowLock', {
  81.         symbol: '☒',
  82.         color: "#ff0", // yellow
  83.         impassable: function(player, object) {
  84.             return player.getColor() != object.color;
  85.         }
  86.     });
  87.  
  88.     for (var x = 20; x <= 40; x++) {
  89.         map.placeObject(x, 11, 'block');
  90.         map.placeObject(x, 13, 'block');
  91.     }
  92.     map.placeObject(22, 12, 'greenLock');
  93.     map.placeObject(25, 12, 'redLock');
  94.     map.placeObject(28, 12, 'yellowLock');
  95.     map.placeObject(31, 12, 'greenLock');
  96.     map.placeObject(34, 12, 'redLock');
  97.     map.placeObject(37, 12, 'yellowLock');
  98.     map.placeObject(40, 12, 'exit');
  99.     for (var y = 0; y < map.getHeight(); y++) {
  100.         if (y != 12) {
  101.             map.placeObject(40, y, 'block');
  102.         }
  103.         for (var x = 41; x < map.getWidth(); x++) {
  104.             map.setSquareColor(x, y, '#080');
  105.         }
  106.     }
  107. }
  108.  
  109. function validateLevel(map) {
  110.     map.validateExactlyXManyObjects(1, 'exit');
  111. }
  112.  
  113. function onExit(map) {
  114.     if (!map.getPlayer().hasItem('phone')) {
  115.         map.writeStatus("We need the phone!");
  116.         return false;
  117.     } else {
  118.         return true;
  119.     }
  120. }
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top