All pastes #615957 Raw Edit

platform code for josh

public text v1 · immutable
·published 2007-07-12 11:40 UTC
rendered paste body
onClipEvent (load) {
              speed = 0;
              maxmove = 15;
              jumping = true;
              jump = 0;
			  var doGroundHitTest = function() {
				  if (this.hitTest(_root.ground) ||
					  this.hitTest(_root.ground3) ||
					  this.hitTest(_root.ground4) ||
					  this.hitTest(_root.ground5) ||
					  this.hitTest(_root.ground6) ||
					  this.hitTest(_root.ground7) ||
					  this.hitTest(_root.ground8) ||
					  this.hitTest(_root.ground9) ||
					  this.hitTest(_root.ground10) ||
					  this.hitTest(_root.ground11) ||
					  this.hitTest(_root.ground2)) {
					  return true;
				  } else {
					  return false;
				  }
			  }
      }
      onClipEvent (enterFrame) {
              if (!doGroundHitTest() && !jumping) {
                      this._y += 6;					  
              }
              if (_root.dead) {
                      this.gotoAndStop("dead");
              } else {
                      speed *= .85;
                      if (speed>0) {
                              dir = "right";
                      } else if (speed<0) {
  19.
                              dir = "left";
                      }
                      if (dir == "right") {
                              this._x += speed;
                              _root._x -= speed;
                      }
                      if (dir == "left" && !_root.left_wall.hitTest(this._x - 50, this._y, true)) {
                              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;
                              this.gotoAndStop("idle");
                      }
                      if (!jumping) {
                              jumping = true;
					  }
                      if (jumping) {
                              this.gotoAndStop("jump");
                              this._y -= jump;
                              jump -= .5;
                              if (jump<0) {
                                      falling = true;
                              }
                              if (jump<-15) {
                                      jump = -15;
                              }
                      }
                      if (doGroundHitTest() && falling) {
                              jump = 12;
                              jumping = false;
                              falling = false;
                      }
					  if (this.hitTest(_root.bad) ||
						  this.hitTest(_root.bad2)) {
						  _root._x = 0;
						  _root.gotoAndStop(2);
					  }
              }
      }