Advertisement
Guest User

Untitled

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