Advertisement
Guest User

Untitled

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