Advertisement
Guest User

Untitled

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