Combined Code
movieClip 2 {
}
movieClip 12 {
frame 12 {
stop();
}
}
movieClip 32 {
frame 1 {
stop();
}
frame 2 {
stop();
}
instance of movieClip 12 {
onClipEvent (load) {
gotoAndPlay(1);
}
}
instance of movieClip 12 {
onClipEvent (load) {
gotoAndPlay(5);
}
}
frame 14 {
gotoAndStop(1);
_root.level1.player.spawn = false;
}
instance of movieClip 12 {
onClipEvent (load) {
gotoAndStop(12);
}
}
frame 35 {
gotoAndPlay(15);
}
}
movieClip 34 {
}
movieClip 35 {
instance of movieClip 2 {
onClipEvent (enterFrame) {
megaman1 = _root.level1.player;
upper = this._y - this._height / 2;
left = this._x - this._width / 2;
right = this._x + this._width / 2;
lower = this._y + this._height / 2;
if (this.hitTest(megaman1)) {
if (megaman1._y > this._y) {
megaman1.yVel = 0;
} else {
if (!megaman1.walk) {
megaman1.fall = false;
megaman1.walk = true;
megaman1.nFrame = 42;
megaman1.climbr = false;
megaman1.climbl = false;
megaman1.yVel = 0;
megaman1._y = this._y - 40;
}
}
}
}
}
instance player of movieClip 32 {
onClipEvent (load) {
nFrame = 3;
yBoundU = 150;
yBoundD = 330;
xBoundL = 200;
xBoundR = 440;
lEdge = 0;
rEdge = 0;
fat = false;
rFace = true;
run = false;
spawn = true;
walk = false;
jump = false;
fall = false;
climbl = false;
climbr = false;
xVel = 0;
yVel = 0;
xVelMax = 10;
yVelMax = 30;
xDrag = 0.7;
xStopVel = 2;
xRun = 3;
yGrav = 0.9;
yJump = -15;
}
onClipEvent (enterFrame) {
trace('DEBUG\nrun=' + run + '\nwalk=' + walk + '\nfall:' + fall + '\nnFrame=' + nFrame);
if (spawn && nFrame == 3) {
gotoAndPlay(3);
nFrame = 0;
} else {
if (Key.isDown(37)) {
xVel -= xRun;
climbr = false;
}
if (Key.isDown(39)) {
xVel += xRun;
climbl = false;
}
if (Key.isDown(38)) {
jump = true;
} else {
jump = false;
}
}
xVel *= xDrag;
if (Math.abs(xVel) < xStopVel || climbr || climbl) {
xVel = 0;
if (run || nFrame == 1) {
gotoAndStop(1);
run = false;
}
} else {
if (!run && walk) {
gotoAndPlay(15);
run = true;
}
if (xVel > 0 && !rFace) {
_xscale = _xscale * -1;
rFace = true;
}
if (xVel < 0 && rFace) {
_xscale = _xscale * -1;
rFace = false;
}
}
if (Math.abs(xVel) > xVelMax) {
xVel *= xVelMax / Math.abs(xVel);
}
_x = _x + xVel;
if (_x < lEdge || _x > rEdge) {
walk = false;
fall = true;
run = false;
nFrame = 38;
}
if (!walk) {
yVel += yGrav;
}
if (walk && jump && !fat) {
yVel = yJump;
walk = false;
run = false;
fat = true;
gotoAndStop(38);
}
if (yVel >= 0) {
if (!walk) {
fall = true;
yVel += yGrav;
}
if (yVel > 20) {
gotoAndStop(41);
}
} else {
if (!jump) {
yVel += yGrav;
}
if (yVel < -15) {
gotoAndStop(40);
} else {
if (yVel < -5) {
gotoAndStop(39);
} else {
gotoAndStop(38);
}
}
}
if (nFrame == 1) {
fat = false;
if (Math.abs(xVel) < xStopVel || climbr || climbl) {
gotoAndStop(1);
} else {
gotoAndPlay(15);
}
nFrame = 0;
}
if (nFrame == 43) {
gotoAndStop(43);
nFrame = 1;
}
if (nFrame == 42) {
gotoAndStop(42);
nFrame = 43;
}
if (nFrame == 37) {
gotoAndStop(37);
nFrame = 0;
}
if (nFrame == 36) {
gotoAndStop(36);
nFrame = 37;
}
if (walk) {
yVel = 0;
}
if (Math.abs(yVel) > yVelMax) {
yVel *= yVelMax / Math.abs(yVel);
}
_y = _y + yVel;
if (_x > xBoundR) {
_root.level1._x -= _x - xBoundR;
xBoundL += _x - xBoundR;
xBoundR += _x - xBoundR;
}
if (_x < xBoundL) {
_root.level1._x += xBoundL - _x;
xBoundR -= xBoundL - _x;
xBoundL -= xBoundL - _x;
}
if (_y > yBoundD) {
_root.level1._y -= _y - yBoundD;
yBoundU += _y - yBoundD;
yBoundD += _y - yBoundD;
}
if (_y < yBoundU) {
_root.level1._y += yBoundU - _y;
yBoundD -= yBoundU - _y;
yBoundU -= yBoundU - _y;
}
}
}
instance of movieClip 34 {
onClipEvent (enterFrame) {
megaman1 = _root.level1.player;
if (this.hitTest(megaman1)) {
if (megaman1._y > this._y) {
megaman1.yVel = 0;
} else {
if (!megaman1.walk) {
megaman1.fall = false;
megaman1.walk = true;
megaman1.nFrame = 42;
megaman1.climbr = false;
megaman1.climbl = false;
megaman1.yVel = 0;
megaman1._y = this._y - 40;
}
}
}
if (this.hitTest(megaman1)) {
if (megaman1._x > this._x) {
megaman1._x = this._x + (this._width + megaman1._width) / 2;
megaman1.climbl = true;
} else {
megaman1._x = this._x - (this._width + megaman1._width) / 2;
megaman1.climbr = true;
}
}
}
onClipEvent (enterFrame) {
}
}
instance of movieClip 2 {
onClipEvent (enterFrame) {
megaman1 = _root.level1.player;
upper = this._y - this._height / 2;
left = this._x - this._width / 2;
right = this._x + this._width / 2;
lower = this._y + this._height / 2;
if (this.hitTest(megaman1)) {
pLoc = 0;
if (megaman1._y < upper) {
pLoc += 6;
} else {
if (megaman1._y < lower) {
pLoc += 3;
}
}
if (megaman1._x > right) {
pLoc += 3;
} else {
if (megaman1._x > left) {
pLoc += 2;
} else {
pLoc += 1;
}
}
trace('Direction Collisions pLoc: ' + pLoc);
switch (pLoc) {
case 1:
if (left - megaman1._x < megaman._y - bottom) {
megaman1.xVel = 0;
megaman._x = left - 15;
megaman1.climbr = true;
} else {
megaman._y = bottom + 20;
megaman1.yVel = 2;
}
break;
case 2:
megaman1.yVel = 2;
megaman._y = bottom + 20;
break;
case 3:
if (megaman1._x - right < megaman1._y - bottom) {
megaman1.xVel = 0;
megaman._x = right + 15;
megaman.climbl = true;
} else {
megaman.yVel = 2;
megaman._y = bottom + 20;
}
break;
case 4:
megaman1.xVel = 0;
megaman._x = left - 15;
megaman1.climbr = true;
break;
case 5:
if (!megaman1.walk) {
megaman1.fall = false;
megaman1.walk = true;
megaman1.nFrame = 42;
megaman1.climbr = false;
megaman1.climbl = false;
megaman1.yVel = 0;
megaman1._y = upper - 15;
}
break;
case 6:
megaman1.xVel = 0;
megaman._x = right + 15;
megaman.climbl = true;
break;
case 7:
if (left - megaman1._x < top - megaman1._y) {
megaman1.xVel = 0;
megaman._x = left - 15;
megaman.climbr = true;
} else {
if (!megaman1.walk) {
megaman1.fall = false;
megaman1.walk = true;
megaman1.nFrame = 42;
megaman1.climbr = false;
megaman1.climbl = false;
megaman1.yVel = 0;
megaman1._y = upper - 15;
megaman1.lEdge = left;
megaman1.rEdge = right;
}
}
break;
case 8:
if (!megaman1.walk) {
megaman1.fall = false;
megaman1.walk = true;
megaman1.nFrame = 42;
megaman1.climbr = false;
megaman1.climbl = false;
megaman1.yVel = 0;
megaman1._y = upper - 15;
megaman1.lEdge = left;
megaman1.rEdge = right;
}
break;
case 9:
if (megaman1._x - right < top - megaman1._y) {
megaman1.xVel = 0;
megaman.climbl = true;
megaman._x = right + 15;
} else {
if (!megaman1.walk) {
megaman1.fall = false;
megaman1.walk = true;
megaman1.nFrame = 42;
megaman1.climbr = false;
megaman1.climbl = false;
megaman1.yVel = 0;
megaman1._y = upper - 15;
megaman1.lEdge = left;
megaman1.rEdge = right;
}
}
}
}
}
}
instance of movieClip 2 {
onClipEvent (enterFrame) {
megaman1 = _root.level1.player;
upper = this._y - this._height / 2;
left = this._x - this._width / 2;
right = this._x + this._width / 2;
lower = this._y + this._height / 2;
if (this.hitTest(megaman1)) {
pLoc = 0;
if (megaman1._y < upper) {
pLoc += 6;
} else {
if (megaman1._y < lower) {
pLoc += 3;
}
}
if (megaman1._x > right) {
pLoc += 3;
} else {
if (megaman1._x > left) {
pLoc += 2;
} else {
pLoc += 1;
}
}
trace('Direction Collisions pLoc: ' + pLoc);
switch (pLoc) {
case 1:
if (left - megaman1._x < megaman._y - bottom) {
megaman1.xVel = 0;
megaman._x = left - 15;
megaman1.climbr = true;
} else {
megaman._y = bottom + 20;
megaman1.yVel = 2;
}
break;
case 2:
megaman1.yVel = 2;
megaman._y = bottom + 20;
break;
case 3:
if (megaman1._x - right < megaman1._y - bottom) {
megaman1.xVel = 0;
megaman._x = right + 15;
megaman.climbl = true;
} else {
megaman.yVel = 2;
megaman._y = bottom + 20;
}
break;
case 4:
megaman1.xVel = 0;
megaman._x = left - 15;
megaman1.climbr = true;
break;
case 5:
if (!megaman1.walk) {
megaman1.fall = false;
megaman1.walk = true;
megaman1.nFrame = 42;
megaman1.climbr = false;
megaman1.climbl = false;
megaman1.yVel = 0;
megaman1._y = upper - 15;
}
break;
case 6:
megaman1.xVel = 0;
megaman._x = right + 15;
megaman.climbl = true;
break;
case 7:
if (left - megaman1._x < top - megaman1._y) {
megaman1.xVel = 0;
megaman._x = left - 15;
megaman.climbr = true;
} else {
if (!megaman1.walk) {
megaman1.fall = false;
megaman1.walk = true;
megaman1.nFrame = 42;
megaman1.climbr = false;
megaman1.climbl = false;
megaman1.yVel = 0;
megaman1._y = upper - 15;
megaman1.lEdge = left;
megaman1.rEdge = right;
}
}
break;
case 8:
if (!megaman1.walk) {
megaman1.fall = false;
megaman1.walk = true;
megaman1.nFrame = 42;
megaman1.climbr = false;
megaman1.climbl = false;
megaman1.yVel = 0;
megaman1._y = upper - 15;
megaman1.lEdge = left;
megaman1.rEdge = right;
}
break;
case 9:
if (megaman1._x - right < top - megaman1._y) {
megaman1.xVel = 0;
megaman.climbl = true;
megaman._x = right + 15;
} else {
if (!megaman1.walk) {
megaman1.fall = false;
megaman1.walk = true;
megaman1.nFrame = 42;
megaman1.climbr = false;
megaman1.climbl = false;
megaman1.yVel = 0;
megaman1._y = upper - 15;
megaman1.lEdge = left;
megaman1.rEdge = right;
}
}
}
}
}
}
instance of movieClip 2 {
onClipEvent (enterFrame) {
megaman1 = _root.level1.player;
upper = this._y - this._height / 2;
left = this._x - this._width / 2;
right = this._x + this._width / 2;
lower = this._y + this._height / 2;
if (this.hitTest(megaman1)) {
pLoc = 0;
if (megaman1._y < upper) {
pLoc += 6;
} else {
if (megaman1._y < lower) {
pLoc += 3;
}
}
if (megaman1._x > right) {
pLoc += 3;
} else {
if (megaman1._x > left) {
pLoc += 2;
} else {
pLoc += 1;
}
}
trace('Direction Collisions pLoc: ' + pLoc);
switch (pLoc) {
case 1:
if (left - megaman1._x < megaman._y - bottom) {
megaman1.xVel = 0;
megaman._x = left - 15;
megaman1.climbr = true;
} else {
megaman._y = bottom + 20;
megaman1.yVel = 2;
}
break;
case 2:
megaman1.yVel = 2;
megaman._y = bottom + 20;
break;
case 3:
if (megaman1._x - right < megaman1._y - bottom) {
megaman1.xVel = 0;
megaman._x = right + 15;
megaman.climbl = true;
} else {
megaman.yVel = 2;
megaman._y = bottom + 20;
}
break;
case 4:
megaman1.xVel = 0;
megaman._x = left - 15;
megaman1.climbr = true;
break;
case 5:
if (!megaman1.walk) {
megaman1.fall = false;
megaman1.walk = true;
megaman1.nFrame = 42;
megaman1.climbr = false;
megaman1.climbl = false;
megaman1.yVel = 0;
megaman1._y = upper - 15;
}
break;
case 6:
megaman1.xVel = 0;
megaman._x = right + 15;
megaman.climbl = true;
break;
case 7:
if (left - megaman1._x < top - megaman1._y) {
megaman1.xVel = 0;
megaman._x = left - 15;
megaman.climbr = true;
} else {
if (!megaman1.walk) {
megaman1.fall = false;
megaman1.walk = true;
megaman1.nFrame = 42;
megaman1.climbr = false;
megaman1.climbl = false;
megaman1.yVel = 0;
megaman1._y = upper - 15;
megaman1.lEdge = left;
megaman1.rEdge = right;
}
}
break;
case 8:
if (!megaman1.walk) {
megaman1.fall = false;
megaman1.walk = true;
megaman1.nFrame = 42;
megaman1.climbr = false;
megaman1.climbl = false;
megaman1.yVel = 0;
megaman1._y = upper - 15;
megaman1.lEdge = left;
megaman1.rEdge = right;
}
break;
case 9:
if (megaman1._x - right < top - megaman1._y) {
megaman1.xVel = 0;
megaman.climbl = true;
megaman._x = right + 15;
} else {
if (!megaman1.walk) {
megaman1.fall = false;
megaman1.walk = true;
megaman1.nFrame = 42;
megaman1.climbr = false;
megaman1.climbl = false;
megaman1.yVel = 0;
megaman1._y = upper - 15;
megaman1.lEdge = left;
megaman1.rEdge = right;
}
}
}
}
}
}
instance of movieClip 2 {
onClipEvent (enterFrame) {
megaman1 = _root.level1.player;
upper = this._y - this._height / 2;
left = this._x - this._width / 2;
right = this._x + this._width / 2;
lower = this._y + this._height / 2;
if (this.hitTest(megaman1)) {
pLoc = 0;
if (megaman1._y < upper) {
pLoc += 6;
} else {
if (megaman1._y < lower) {
pLoc += 3;
}
}
if (megaman1._x > right) {
pLoc += 3;
} else {
if (megaman1._x > left) {
pLoc += 2;
} else {
pLoc += 1;
}
}
trace('Direction Collisions pLoc: ' + pLoc);
switch (pLoc) {
case 1:
if (left - megaman1._x < megaman._y - bottom) {
megaman1.xVel = 0;
megaman._x = left - 15;
megaman1.climbr = true;
} else {
megaman._y = bottom + 20;
megaman1.yVel = 2;
}
break;
case 2:
megaman1.yVel = 2;
megaman._y = bottom + 20;
break;
case 3:
if (megaman1._x - right < megaman1._y - bottom) {
megaman1.xVel = 0;
megaman._x = right + 15;
megaman.climbl = true;
} else {
megaman.yVel = 2;
megaman._y = bottom + 20;
}
break;
case 4:
megaman1.xVel = 0;
megaman._x = left - 15;
megaman1.climbr = true;
break;
case 5:
if (!megaman1.walk) {
megaman1.fall = false;
megaman1.walk = true;
megaman1.nFrame = 42;
megaman1.climbr = false;
megaman1.climbl = false;
megaman1.yVel = 0;
megaman1._y = upper - 15;
}
break;
case 6:
megaman1.xVel = 0;
megaman._x = right + 15;
megaman.climbl = true;
break;
case 7:
if (left - megaman1._x < top - megaman1._y) {
megaman1.xVel = 0;
megaman._x = left - 15;
megaman.climbr = true;
} else {
if (!megaman1.walk) {
megaman1.fall = false;
megaman1.walk = true;
megaman1.nFrame = 42;
megaman1.climbr = false;
megaman1.climbl = false;
megaman1.yVel = 0;
megaman1._y = upper - 15;
megaman1.lEdge = left;
megaman1.rEdge = right;
}
}
break;
case 8:
if (!megaman1.walk) {
megaman1.fall = false;
megaman1.walk = true;
megaman1.nFrame = 42;
megaman1.climbr = false;
megaman1.climbl = false;
megaman1.yVel = 0;
megaman1._y = upper - 15;
megaman1.lEdge = left;
megaman1.rEdge = right;
}
break;
case 9:
if (megaman1._x - right < top - megaman1._y) {
megaman1.xVel = 0;
megaman.climbl = true;
megaman._x = right + 15;
} else {
if (!megaman1.walk) {
megaman1.fall = false;
megaman1.walk = true;
megaman1.nFrame = 42;
megaman1.climbr = false;
megaman1.climbl = false;
megaman1.yVel = 0;
megaman1._y = upper - 15;
megaman1.lEdge = left;
megaman1.rEdge = right;
}
}
}
}
}
}
}