Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. stop();
  2. var xspeed = 0;
  3. var yspeed = 0;
  4. var gravity = 25;
  5. var if_grav = true;
  6. var j = 0;
  7. var jump = 10;
  8. var is_jumping = false;
  9. var jump_block = 0;
  10. var scale = _xscale;
  11. var on_air = true;
  12. var dissapear = false;
  13. var sets = 0;
  14. var dissapear_start = false;
  15. onEnterFrame = function () {
  16.     movement();
  17.     sounds();
  18.     level_functions();
  19.     function level_functions() {
  20.         ground.gotoAndStop(_currentlabel);
  21.         if (_currentlabel == 'level1') {
  22.             dissapear = false;
  23.         }
  24.         if(_currentlabel == 'level2'){
  25.             setPlayerWithTime(90,90);
  26.         }
  27.     }
  28.     function setPlayerWithTime(x_p,y_p){
  29.         dissapear_start = true;
  30.         if(dissapear != true){
  31.             player._x = -70,
  32.             player._y = -70;
  33.         }
  34.         if(dissapear == true){
  35.             if(sets <= 0){
  36.                 sets++;
  37.                 player._x = x_p;
  38.                 player._y = y_p;
  39.                
  40.             }
  41.          timer.gotoAndStop(192);
  42.         }
  43.        
  44.     }
  45.     jump_sound = new Sound(this);
  46.     jump_sound.attachSound('jump_sound');
  47.     land_sound = new Sound(this);
  48.     land_sound.attachSound('land_sound');
  49.     complete_sound = new Sound(this);
  50.     complete_sound.attachSound('complete_sound');
  51.     function movement() {
  52.         xspeed *= 0.80;
  53.         yspeed *= 0.93;
  54.         player._x += xspeed;
  55.         player._y += yspeed;
  56.         if (ground.hitTest(player._x, player._y+player._height/2, true)) {
  57.             xspeed = 0;
  58.             xspeed += 1;
  59.         } else {
  60.             gravity = 1;
  61.             if (Key.isDown(Key.LEFT)) {
  62.                 xspeed -= 2;
  63.             }
  64.         }
  65.         if (ground.hitTest(player._x+player._width, player._y+player._height/2, true)) {
  66.             xspeed = 0;
  67.             xspeed -= 1;
  68.         } else {
  69.             if (Key.isDown(Key.RIGHT)) {
  70.                 xspeed += 2;
  71.             }
  72.         }
  73.         if (ground.hitTest(player._x+player._width/2, player._y, true)) {
  74.             yspeed = 0;
  75.             yspeed += 1;
  76.         } else {
  77.             if (Key.isDown(Key.UP)) {
  78.                 jack = 1;
  79.                 if (j<=0) {
  80.                     j++;
  81.                     yspeed -= jump;
  82.                     jump_sound.start();
  83.                 }
  84.                 is_jumping = true;
  85.             } else {
  86.                 is_jumping = false;
  87.                 jack = 0;
  88.             }
  89.         }
  90.         if (ground.hitTest(player._x+player._width/2, player._y+player._height, true)) {
  91.             if_grav = false;
  92.         } else {
  93.             if_grav = true;
  94.         }
  95.         if (if_grav == true) {
  96.             yspeed += gravity;
  97.             jump_block = 0;
  98.             on_air = true;
  99.         }
  100.         if (if_grav == false) {
  101.             if (jump_block<=0) {
  102.                 yspeed = 0;
  103.                 jump_block++;
  104.                 land_sound.start();
  105.                 j = 0;
  106.             }
  107.             on_air = false;
  108.         }
  109.         if (Key.isDown(Key.LEFT)) {
  110.             rough.ax.gotoAndStop(2);
  111.             rough.ax._xscale = -scale;
  112.         } else if (Key.isDown(Key.RIGHT)) {
  113.             rough.ax.gotoAndStop(2);
  114.             rough.ax._xscale = scale;
  115.         } else {
  116.             if (on_air == false) {
  117.                 rough.ax.gotoAndStop(1);
  118.             } else {
  119.                 rough.ax.gotoAndStop(3);
  120.             }
  121.         }
  122.         rough._x = player._x;
  123.         rough._y = player._y;
  124.         player._alpha = 0;
  125.         if(Key.isDown(Key.DOWN)){
  126.             if(player.hitTest(door)){
  127.                 nextFrame();
  128.                 complete_sound.start();
  129.                 reset_vars();
  130.             }
  131.         }
  132.     }
  133.     function reset_vars() {
  134.         xspeed = 0;
  135.         yspeed = 0;
  136.         gravity = 25;
  137.         if_grav = true;
  138.         j = 0;
  139.         jump = 10;
  140.         is_jumping = false;
  141.         jump_block = 0;
  142.         scale = _xscale;
  143.         on_air = true;
  144.         dissapear = false;
  145.         sets = 0;
  146.         dissapear_start = false;
  147.         timer.gotoAndStop(1);
  148.     }
  149. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement