Advertisement
Guest User

Untitled

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