Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 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.  
  49. player.setPhoneCallback(map.defineObject('raftt', {
  50. 'type': 'dynamic',
  51. 'symbol': '▓',
  52. 'color': '#420',
  53. 'transport': true, // (prevents player from drowning in water)
  54. 'behavior': function (me) {
  55. me.move('up');
  56. }
  57. }))
  58. player.setPhoneCallback(map.defineObject('raftdt', {
  59. 'type': 'dynamic',
  60. 'symbol': '▓',
  61. 'color': '#420',
  62. 'transport': true, // (prevents player from drowning in water)
  63. 'behavior': function (me) {
  64. me.move('down');
  65. }
  66. }))
  67. map.placeObject(49, 23, 'raftt');
  68. map.placeObject(49, 22, 'raftt');
  69. map.placeObject(49, 20, 'raftt');
  70. map.placeObject(49, 21, 'raftt');
  71. map.placeObject(49, 1, 'raftdt');
  72. map.placeObject(49, 2, 'raftdt');
  73. map.placeObject(49, 3, 'raftdt');
  74. map.placeObject(49, 4, 'raftdt');
  75. map.placeObject(49, 5, 'raftdt');
  76. map.placeObject(49, 6, 'raftdt');
  77. map.placeObject(49, 7, 'raftdt');
  78. map.placeObject(49, 8, 'raftdt');
  79. map.placeObject(49, 9, 'raftdt');
  80. map.placeObject(49, 10, 'raftdt');
  81.  
  82. }
  83.  
  84. function validateLevel(map) {
  85. map.validateExactlyXManyObjects(1, 'exit');
  86. map.validateExactlyXManyObjects(1, 'raft');
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement