Guest User

Untitled

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