Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. /**********************
  2. * fordingTheRiver.js *
  3. **********************
  4. *
  5. * And there's the river. Fortunately, I was prepared for this.
  6. * See the raft on the other side?
  7. *
  8. * Everything is going according to plan.
  9. */
  10.  
  11. function startLevel(map) {
  12. var raftDirection = 'down';
  13.  
  14. map.placePlayer(map.getWidth()-1, map.getHeight()-1);
  15. var player = map.getPlayer();
  16.  
  17. map.defineObject('raft', {
  18. 'type': 'dynamic',
  19. 'symbol': '▓',
  20. 'color': '#420',
  21. 'transport': true, // (prevents player from drowning in water)
  22. 'behavior': function (me) {
  23. me.move(raftDirection);
  24. }
  25. });
  26.  
  27. map.defineObject('water', {
  28. 'symbol': '░',
  29. 'color': '#44f',
  30. 'onCollision': function (player) {
  31. player.killedBy('drowning in deep dark water');
  32. }
  33. });
  34.  
  35. for (var x = 0; x < map.getWidth(); x++) {
  36. for (var y = 5; y < 15; y++) {
  37. map.placeObject(x, y, 'water');
  38. }
  39. }
  40.  
  41. map.placeObject(20, 5, 'raft');
  42. map.placeObject(0, 2, 'exit');
  43. map.placeObject(0, 1, 'block');
  44. map.placeObject(1, 1, 'block');
  45. map.placeObject(0, 3, 'block');
  46. map.placeObject(1, 3, 'block');
  47.  
  48. var count = 0;
  49.  
  50. map.defineObject('switch', {
  51. 'type': 'dynamic',
  52. 'symbol': 'S',
  53. 'color': '#F00',
  54. 'transport': true,
  55. 'behavior': function (me) {
  56. /*count++;
  57. if (count==10)
  58. {
  59. count = 0;
  60. if (raftDirection == 'down')
  61. {
  62. raftDirection = 'up';
  63. color = '#0F0';
  64. }
  65. else
  66. {
  67. raftDirection = 'down';
  68. color = '#0F0';
  69. }
  70. }*/
  71. }
  72. });
  73.  
  74. for (var y = 5; y < 15; ++y)
  75. map.placeObject(30, y, 'switch');
  76. }
  77.  
  78. function validateLevel(map) {
  79. map.validateExactlyXManyObjects(1, 'exit');
  80. map.validateExactlyXManyObjects(1, 'raft');
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement