Guest User

Untitled

a guest
May 25th, 2019
73
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. player.setPhoneCallback(function (){raftDirection='up';});
  49.  
  50.  
  51.  
  52. }
  53.  
  54. function validateLevel(map) {
  55. map.validateExactlyXManyObjects(1, 'exit');
  56. map.validateExactlyXManyObjects(1, 'raft');
  57. }
RAW Paste Data