Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- stop();
- var xspeed = 0;
- var yspeed = 0;
- var gravity = 25;
- var if_grav = true;
- var j = 0;
- var jump = 10;
- var is_jumping = false;
- var jump_block = 0;
- var scale = _xscale;
- var on_air = true;
- var dissapear = false;
- var sets = 0;
- var dissapear_start = false;
- onEnterFrame = function () {
- movement();
- sounds();
- level_functions();
- function level_functions() {
- ground.gotoAndStop(_currentlabel);
- if (_currentlabel == 'level1') {
- dissapear = false;
- }
- if(_currentlabel == 'level2'){
- setPlayerWithTime(90,90);
- }
- }
- function setPlayerWithTime(x_p,y_p){
- dissapear_start = true;
- if(dissapear != true){
- player._x = -70,
- player._y = -70;
- }
- if(dissapear == true){
- if(sets <= 0){
- sets++;
- player._x = x_p;
- player._y = y_p;
- }
- timer.gotoAndStop(192);
- }
- }
- jump_sound = new Sound(this);
- jump_sound.attachSound('jump_sound');
- land_sound = new Sound(this);
- land_sound.attachSound('land_sound');
- complete_sound = new Sound(this);
- complete_sound.attachSound('complete_sound');
- function movement() {
- xspeed *= 0.80;
- yspeed *= 0.93;
- player._x += xspeed;
- player._y += yspeed;
- if (ground.hitTest(player._x, player._y+player._height/2, true)) {
- xspeed = 0;
- xspeed += 1;
- } else {
- gravity = 1;
- if (Key.isDown(Key.LEFT)) {
- xspeed -= 2;
- }
- }
- if (ground.hitTest(player._x+player._width, player._y+player._height/2, true)) {
- xspeed = 0;
- xspeed -= 1;
- } else {
- if (Key.isDown(Key.RIGHT)) {
- xspeed += 2;
- }
- }
- if (ground.hitTest(player._x+player._width/2, player._y, true)) {
- yspeed = 0;
- yspeed += 1;
- } else {
- if (Key.isDown(Key.UP)) {
- jack = 1;
- if (j<=0) {
- j++;
- yspeed -= jump;
- jump_sound.start();
- }
- is_jumping = true;
- } else {
- is_jumping = false;
- jack = 0;
- }
- }
- if (ground.hitTest(player._x+player._width/2, player._y+player._height, true)) {
- if_grav = false;
- } else {
- if_grav = true;
- }
- if (if_grav == true) {
- yspeed += gravity;
- jump_block = 0;
- on_air = true;
- }
- if (if_grav == false) {
- if (jump_block<=0) {
- yspeed = 0;
- jump_block++;
- land_sound.start();
- j = 0;
- }
- on_air = false;
- }
- if (Key.isDown(Key.LEFT)) {
- rough.ax.gotoAndStop(2);
- rough.ax._xscale = -scale;
- } else if (Key.isDown(Key.RIGHT)) {
- rough.ax.gotoAndStop(2);
- rough.ax._xscale = scale;
- } else {
- if (on_air == false) {
- rough.ax.gotoAndStop(1);
- } else {
- rough.ax.gotoAndStop(3);
- }
- }
- rough._x = player._x;
- rough._y = player._y;
- player._alpha = 0;
- if(Key.isDown(Key.DOWN)){
- if(player.hitTest(door)){
- nextFrame();
- complete_sound.start();
- reset_vars();
- }
- }
- }
- function reset_vars() {
- xspeed = 0;
- yspeed = 0;
- gravity = 25;
- if_grav = true;
- j = 0;
- jump = 10;
- is_jumping = false;
- jump_block = 0;
- scale = _xscale;
- on_air = true;
- dissapear = false;
- sets = 0;
- dissapear_start = false;
- timer.gotoAndStop(1);
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement