Código :
onClipEvent (load) { var grav:Number = 0; var run:Number = 5; var wlk:Number = 2.5; var speed:Number = run; var jumpHeight:Number = 12; var dbl:Number = 10; var tri:Number = 10; var djump:Boolean = false; var tjump:Boolean = false; var thro:Boolean = false; var slow:Number = .7; var slowspd:Number = speed/2; var setspeed:Number = speed; var scale:Number = _xscale; var ex:Number = 5; this.gotoAndStop(2); } onClipEvent (enterFrame) { grav++; _y += grav; if (Key.isDown(65)) { setspeed = wlk; } else { setspeed = run; } while (_root.ground.hitTest(_x, _y, true)) { djump = false; tjump = false; _y--; grav = 0; } if (_root.water.hitTest(_x, _y, true)) { grav *= slow*1.25; speed = slowspd; } else { speed = setspeed; } if (Key.isDown(Key.RIGHT)) { _x += speed; _xscale = scale; if (_root.ground.hitTest(_x, _y+3, true)) { this.play(); } else { if (djump == false) { this.gotoAndStop(10); } else if (tjump == false) { this.gotoAndStop(11); } else { this.gotoAndStop(11); } } } else if (Key.isDown(Key.LEFT)) { _x -= speed; _xscale = -scale; if (_root.ground.hitTest(_x, _y+3, true)) { this.play(); } else { if (djump == false) { this.gotoAndStop(10); } else if (tjump == false) { this.gotoAndStop(11); } else { this.gotoAndStop(11); } } } else { if (_root.ground.hitTest(_x, _y+3, true) && !Key.isDown(68) && !Key.isDown(83)) { this.gotoAndStop(1); } } if (Key.isDown(68) && !Key.isDown(Key.UP) && !Key.isDown(Key.RIGHT) && !Key.isDown(Key.LEFT) && !Key.isDown(83) && _root.ground.hitTest(_x, _y+3, true)) { this.gotoAndStop(8); } if (Key.isDown(83) && !Key.isDown(Key.RIGHT) && !Key.isDown(Key.LEFT) && !Key.isDown(Key.UP) && !Key.isDown(68) && _root.ground.hitTest(_x, _y+3, true) && _currentframe != 6) { this.gotoAndPlay(20); } else if (Key.isDown(83) && grav>1) { this.gotoAndStop(20); } if (Key.isDown(Key.UP) && _root.ground.hitTest(_x, _y+3, true)) { grav = -jumpHeight; _y -= 4; this.gotoAndStop(10); } else if (Key.isDown(Key.UP) && djump == false && grav>0 && tjump == false) { grav = -dbl; djump = true; this.gotoAndStop(11); } else if (Key.isDown(68) && tjump == false && grav>1) { grav = -tri; tjump = true; this.gotoAndStop(11); } if (_root.ground.hitTest(_x+(_width/2)+ex, _y-(_height/2), true) || _root.ground.hitTest(_x+(_width/2)+ex, _y-(_height/6), true) || _root.ground.hitTest(_x+(_width/2)+ex, _y-_height, true)) { _x -= speed; } if (_root.ground.hitTest(_x-(_width/2)-ex, _y-(_height/2), true) || _root.ground.hitTest(_x-(_width/2)-ex, _y-(_height/6), true) || _root.ground.hitTest(_x-(_width/2)-ex, _y-_height, true)) { _x += speed; } if (_root.ground.hitTest(_x, _y-_height-15, true)) { grav = 1; } } onClipEvent (enterFrame) { if (Key.isDown(Key.SPACE)) { if (_root.ground.hitTest(_x, _y+3, true)) { this.gotoAndPlay(20); } else { if (djump == false) { this.gotoAndStop(10); } else if (tjump == false) { this.gotoAndStop(11); } else { this.gotoAndStop(11); } } } }