Guest User

Untitled

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