Advertisement
Guest User

Untitled

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