Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- onClipEvent (Load) {
- jumping = true;
- jump = 0;
- speed = 0;
- maxmove = 15;
- attacking = false;
- dir =
- falling = true;
- }
- onClipEvent (EnterFrame) {
- if (!_root.ground.hitTest(this._x, this._y, true) && !jumping) {
- this._y += 6;
- _root._y -= 6;
- }
- if (_root.dead) {
- this.gotoAndStop("dead");
- } else {
- speed *= .85;
- if (speed>0) {
- dir = "right";
- } else if (speed<0) {
- dir = "left";
- }
- if (dir == "right"){
- this._x += speed;
- _root._x -= speed;
- }
- if (dir == "left") {
- this._x += speed;
- _root._x -= speed;
- }
- if (Key.isDown(Key.LEFT)) {
- if (speed>-maxmove) {
- speed--;
- }
- this.gotoAndStop("run");
- this._xscale = -100;
- } else if (Key.isDown(Key.RIGHT)) {
- if (speed<maxmove) {
- speed++;
- }
- this._xscale = 100;
- this.gotoAndStop("run");
- }
- if (speed<1 && speed>-1 && !attacking) {
- speed = 0;
- }
- if (Key.isDown(Key.UP) && !jumping) {
- jumping = true;
- }
- if (jumping) {
- this.gotoAndStop("jump");
- this._y -= jump;
- _root._y += jump;
- jump -= .5;
- if (jump<0) {
- falling = true;
- }
- if (jump<-15) {
- jump = -15;
- }
- }
- if (_root.ground.hitTest(this._x, this._y, true) && falling) {
- jump = 9;
- jumping = false;
- falling = false;
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment