[Tools][Expand/Collapse All]Note that automatic extraction of ActionScript 3 is still pretty much unsupported by swfchan. AS1/AS2 works okay most of the time.Frame 1 (12.32 KiB) ● ●
function initDemo() {
borderTop = 140;
borderBottom = 280;
borderLeft = 140;
borderRight = 470;
vX = 0;
pills = false;
toxic = false;
vY = 0;
underwater = false;
moving = false;
waveCount = 0;
moveSpeed = 0.5;
hippaul.swapDepths(200);
_root.onEnterFrame = function () {
handleKeys();
if (Key.isDown(39)) {
titley.rightKey.gotoAndStop(3);
} else {
titley.rightKey.gotoAndStop(1);
}
if (Key.isDown(40)) {
titley.downKey.gotoAndStop(3);
} else {
titley.downKey.gotoAndStop(1);
}
if (Key.isDown(37)) {
titley.leftKey.gotoAndStop(3);
} else {
titley.leftKey.gotoAndStop(1);
}
if (Key.isDown(38)) {
titley.upKey.gotoAndStop(3);
} else {
titley.upKey.gotoAndStop(1);
}
friction();
moveHippo();
checkBorders();
setAngle();
wave();
};
}
function initEngine() {
breath = 20;
hippaul.gotoAndStop(1);
borderTop = 70;
borderBottom = 400;
borderLeft = 40;
borderRight = 560;
level = 1;
vX = 0;
vY = 0;
fruitLeft = 5;
time = 20;
lives = 3;
livesContainer.life1._visible = true;
livesContainer.life2._visible = true;
livesContainer.life3._visible = true;
powerUp = "";
underwater = false;
pauseEngine = false;
moving = false;
waveCount = 0;
logCount = 0;
fruitCount = 0;
hippaul.swapDepths(200);
toxic = false;
pills = false;
logTimer = 0;
fruitTimer = 0;
powerupTimer = 0;
powerupCount = 0;
invul = false;
current = 3;
logs = new Array();
moveSpeed = 0.5;
_root.onEnterFrame = function () {
if (!pauseEngine) {
handleKeys();
friction();
moveHippo();
checkBorders();
setAngle();
wave();
log();
fruit();
powerUps();
drainOxy();
}
};
}
function handleKeys() {
yMoving = false;
xMoving = false;
moving = false;
if (Key.isDown(39)) {
if (vX < 5) {
vX = vX + moveSpeed;
} else if (!pills) {
vX = 5;
} else {
vX = 10;
}
xMoving = true;
moving = true;
}
if (Key.isDown(37)) {
if (vX > -5) {
vX = vX - moveSpeed;
} else if (!pills) {
vX = -5;
} else {
vX = -10;
}
xMoving = true;
moving = true;
}
if (Key.isDown(38)) {
if (vY > -5) {
vY = vY - moveSpeed;
} else if (!pills) {
vY = -5;
} else {
vY = -10;
}
yMoving = true;
moving = true;
}
if (Key.isDown(40)) {
if (vY < 5) {
vY = vY + moveSpeed;
} else if (!pills) {
vY = 5;
} else {
vY = 10;
}
yMoving = true;
moving = true;
}
}
function moveHippo() {
hippaul._x = hippaul._x + vX;
hippaul._y = hippaul._y + vY;
}
function friction() {
if (!xMoving) {
if (vX > 0) {
vX = vX - 0.5;
} else if (vX < 0) {
vX = vX + 0.5;
}
}
if (!yMoving) {
if (vY > 0) {
vY = vY - 0.5;
} else if (vY < 0) {
vY = vY + 0.5;
}
}
}
function checkBorders() {
if (hippaul._x > borderRight) {
hippaul._x = borderRight;
vX = 0;
} else if (hippaul._x < borderLeft) {
hippaul._x = borderLeft;
vX = 0;
}
if (hippaul._y > borderBottom) {
hippaul._y = borderBottom;
vY = 0;
} else if (hippaul._y < borderTop) {
hippaul._y = borderTop;
vY = 0;
}
}
function setAngle() {
if ((vX != 0) || (vY != 0)) {
hippaul._rotation = (Math.atan2(vY, vX) * 57.2957795130823) + 90;
}
}
function wave() {
var _local2 = _root;
if (moving) {
var _local1 = "wave" + waveCount;
_local2.attachMovie("waterWave", _local1, 50 + waveCount);
waveCount++;
if (waveCount > 19) {
waveCount = 0;
}
_local2[_local1]._x = hippaul._x;
_local2[_local1]._y = hippaul._y;
_local2[_local1]._rotation = (Math.atan2(vY, vX) * 57.2957795130823) + 90;
}
}
function log() {
var _local1 = this;
var _local3 = _root;
logTimer++;
if (logTimer > (100 - (level * 7))) {
k = 0;
while (k < (Math.floor(level / 5) + 1)) {
var _local2 = "log" + logCount;
logCount++;
if (logCount > 19) {
logCount = 0;
}
_local3.attachMovie("log", _local2, 71 + logCount);
addLog(_local2);
_local3[_local2]._x = -10;
_local3[_local2]._y = random(330) + borderTop;
_local3[_local2].name = _local2;
trace(_local3[_local2]._y);
_local3[_local2].onEnterFrame = function () {
var _local1 = this;
_local1._x = _local1._x + current;
if ((!underwater) && (((((((((hippaul.body.hitTest(_local1._x - 170, _local1._y + 10, true) || (hippaul.body.hitTest(_local1._x - 127.5, _local1._y + 10, true))) || (hippaul.body.hitTest(_local1._x - 85, _local1._y + 10, true))) || (hippaul.body.hitTest(_local1._x - 42.5, _local1._y + 10, true))) || (hippaul.body.hitTest(_local1._x, _local1._y + 10, true))) || (hippaul.body.hitTest(_local1._x - 170, _local1._y - 10, true))) || (hippaul.body.hitTest(_local1._x - 127.5, _local1._y - 10, true))) || (hippaul.body.hitTest(_local1._x - 85, _local1._y - 10, true))) || (hippaul.body.hitTest(_local1._x - 42.5, _local1._y - 10, true))) || (hippaul.body.hitTest(_local1._x, _local1._y - 10, true)))) {
if (!toxic) {
getHit();
} else {
if (!submerging) {
hippaul.gotoAndPlay(2);
}
chomp.start();
removeLog(_local1.name);
_local1.removeMovieClip();
}
}
if (_local1._x > 790) {
removeLog(_local1.name);
_local1.removeMovieClip();
}
};
logTimer = 0;
k++;
}
}
}
function fruit() {
var _local1 = _root;
var _local3 = this;
fruitTimer++;
if (fruitTimer > (50 - level)) {
var _local2 = "fruit" + fruitCount;
fruitCount++;
if (fruitCount > 19) {
fruitCount = 0;
}
_local1.attachMovie("fruit", _local2, 91 + fruitCount);
_local1[_local2].gotoAndStop(random(_local1[_local2]._totalframes) + 1);
_local1[_local2]._x = -10;
_local1[_local2]._y = random(330) + borderTop;
i = 0;
while (i < logs.length) {
if (_local1[_local2].hitTest(_local1[logs[i]])) {
_local1[_local2]._y = random(330) + borderTop;
}
i++;
}
_local1[_local2].onEnterFrame = function () {
var _local1 = this;
_local1._x = _local1._x + current;
if ((_local1.hitTest(hippaul) && (!underwater)) && (!pauseEngine)) {
if (!submerging) {
hippaul.gotoAndPlay(2);
}
chomp.start();
fruitLeft--;
checkLevelUp();
_local1.removeMovieClip();
}
if (_local1._x > 700) {
_local1.removeMovieClip();
}
};
fruitTimer = 0;
}
}
function powerUps() {
var _local1 = _root;
var _local3 = this;
if (random(1000) == 0) {
trace("power ups");
var _local2 = "powerup" + powerupCount;
powerupCount++;
if (powerupCount > 9) {
powerupCount = 0;
}
_local1.attachMovie("powerup", _local2, 111 + powerupCount);
_local1[_local2].powerType = powerTypes[random(3)];
_local1[_local2].gotoAndStop(_local1[_local2].powerType);
_local1[_local2]._x = -10;
_local1[_local2]._y = random(330) + borderTop;
i = 0;
while (i < logs.length) {
if (_local1[_local2].hitTest(_local1[logs[i]])) {
_local1[_local2]._y = random(330) + borderTop;
}
i++;
}
_local1[_local2].onEnterFrame = function () {
var _local1 = this;
_local1._x = _local1._x + current;
if ((_local1.hitTest(hippaul) && (!pauseEngine)) && (!underwater)) {
_root["eat" + _local1.powerType]();
chomp.start();
_local1.removeMovieClip();
}
if (_local1._x > 700) {
_local1.removeMovieClip();
}
};
}
}
function checkLevelUp() {
if (fruitLeft <= 0) {
current = current + 0.5;
nextLevel.gotoAndPlay(2);
level++;
fruitLeft = 5 + (level * 2);
}
}
function getHit() {
if (!invul) {
invul = true;
lives--;
livesContainer["life" + (lives + 1)]._visible = false;
if (lives == 0) {
trace("GAME OVER");
pauseEngine = true;
hippaul.gotoAndPlay("explode");
}
hitCount = 0;
hitInterval = setInterval(hitFunc, 87);
}
}
function hitFunc() {
hitCount++;
trace("hit interval");
if (hippaul._visible) {
hippaul._visible = false;
} else {
hippaul._visible = true;
}
if (hitCount > 20) {
invul = false;
hippaul._visible = true;
clearInterval(hitInterval);
}
}
function addLog(name) {
logs.push(name);
}
function soundFaderOut(soundToFade) {
var _local1 = _root;
oVol = oVol - 10;
_local1[soundToFade].setVolume(oVol);
if (oVol <= 0) {
_local1[soundToFade].stop();
_local1.gameMusic.start(0, 9999);
_local1.gameMusic.setVolume(0);
_local1.iVol = 0;
_local1.faderIn = setInterval(_local1.soundFaderIn, 200, "gameMusic");
clearInterval(faderOut);
}
}
function soundFaderIn(soundToFade) {
iVol = iVol + 10;
_root[soundToFade].setVolume(iVol);
if (iVol >= 100) {
clearInterval(faderIn);
}
trace((("settin sound " + soundToFade) + " volume to ") + iVol);
}
function removeLog(name) {
var _local1 = name;
i = 0;
while (i < logs.length) {
if (logs[i] == _local1) {
logs.splice(i, 1);
return;
}
i++;
}
}
function drainOxy() {
if (underwater) {
breath = breath - 0.1;
if (breath < 0) {
invul = true;
breath = 20;
underwater = false;
lives--;
livesContainer["life" + (lives + 1)]._visible = false;
if (lives == 0) {
trace("GAME OVER");
pauseEngine = true;
hippaul.gotoAndPlay("explode");
} else {
hippaul.gotoAndStop(1);
}
hitCount = 0;
hitInterval = setInterval(hitFunc, 87);
}
} else if (breath < 20) {
breath = breath + 0.2;
} else {
breath = 20;
}
oxyMeter.gotoAndStop((20 - Math.round(breath)) + 1);
}
function eattoxicWaste() {
trace("TOXIC");
hippaul._xscale = 200;
hippaul._yscale = 200;
toxicColor = new Color(hippaul);
var _local1 = {ra:"0", rb:"0", ga:"100", gb:"100", ba:"0", bb:"0", aa:"100", ab:"255"};
toxicColor.setTransform(_local1);
tc = 0;
meow = 101;
cd = "up";
toxicInt = setInterval(toxicCount, 40);
toxic = true;
}
function toxicCount() {
tc++;
if ((tc >= 400) || (pauseEngine)) {
hippaul._xscale = 100;
hippaul._yscale = 100;
toxic = false;
clearInterval(toxicInt);
var _local1 = {ra:"100", rb:"0", ga:"100", gb:"0", ba:"100", bb:"0", aa:"100", ab:"0"};
toxicColor.setTransform(_local1);
delete toxicColor;
} else {
if (meow == 200) {
cd = "down";
} else if (meow == 100) {
cd = "up";
}
if (cd == "up") {
meow++;
} else {
meow--;
}
var _local1 = {ra:"100", rb:"0", ga:"100", gb:meow, ba:"100", bb:"0", aa:"100", ab:"0"};
toxicColor.setTransform(_local1);
}
}
function eatdynamite() {
trace("boom");
chomp.start();
if (!invul) {
invul = true;
lives--;
livesContainer["life" + (lives + 1)]._visible = false;
if (lives == 0) {
pauseEngine = true;
hippaul.gotoAndPlay("explode");
}
hitCount = 0;
hitInterval = setInterval(hitFunc, 87);
}
}
function eatpills() {
moveSpeed = 2.5;
pills = true;
pillsInt = setInterval(pillsCount, 10000);
trace("pills");
}
function pillsCount() {
moveSpeed = 0.5;
pills = false;
clearInterval(pillsInt);
}
titleMusic = new Sound();
titleMusic.attachSound("title");
gameMusic = new Sound();
gameMusic.attachSound("inGame");
splash = new Sound();
splash.attachSound("splash");
chomp = new Sound();
chomp.attachSound("chomp");
powerTypes = new Array("toxicWaste", "dynamite", "pills");
_root.onEnterFrame = function () {
};
stop();
_root.onEnterFrame = function () {
var _local1 = _root;
loadPercent = _local1.getBytesLoaded() / _local1.getBytesTotal();
_local1.lineStyle("2", "0x000000", 100);
_local1.clear();
_local1.moveTo(0, 0);
_local1.beginFill("0x0066CC", 50);
_local1.lineTo(600, 0);
_local1.lineTo(600, 450 * loadPercent);
_local1.lineTo(0, 0);
_local1.endFill();
_local1.moveTo(0, 0);
_local1.beginFill("0x0066CC", 50);
_local1.lineTo(0, 450);
_local1.lineTo(600 * loadPercent, 0);
_local1.lineTo(0, 0);
_local1.endFill();
_local1.moveTo(600, 450);
_local1.beginFill("0x0066CC", 50);
_local1.lineTo(0, 450);
_local1.lineTo(600, 450 - (450 * loadPercent));
_local1.lineTo(0, 0);
_local1.endFill();
_local1.moveTo(600, 450);
_local1.beginFill("0x0066CC", 50);
_local1.lineTo(600, 0);
_local1.lineTo(600 - (600 * loadPercent), 450);
_local1.lineTo(0, 0);
_local1.endFill();
if (loadPercent == 1) {
_local1.clear();
wonpwnTimer = 0;
gotoAndPlay ("wonpwnLogo");
_local1.onEnterFrame = "";
}
};
Frame 10 (257 B)
if (wonpwnTimer > 80) {
gotoAndStop ("game");
} else if (wonpwnTimer == 40) {
iVol = 0;
titleMusic.start(0, 1024);
titleMusic.setVolume(0);
faderIn = setInterval(soundFaderIn, 200, "titleMusic");
wonpwnTimer++;
} else {
wonpwnTimer++;
}
Frame 11 (28 B)
gotoAndPlay ("wonpwnLogo");
Frame 20 (32 B)
stop();
titley.gotoAndStop(2);
Instance of Symbol 106 MovieClip "titley" in Frame 20 (45 B)
onClipEvent (load) {
this.swapDepths(260);
}
Instance of Symbol 116 MovieClip "gameOver" in Frame 20 (45 B)
onClipEvent (load) {
this.swapDepths(250);
}
Instance of Symbol 121 MovieClip "oxyMeter" in Frame 20 (45 B)
onClipEvent (load) {
this.swapDepths(210);
}
Instance of Symbol 124 MovieClip "nextLevel" in Frame 20 (45 B)
onClipEvent (load) {
this.swapDepths(220);
}
Symbol 12 MovieClip [fruit] Frame 1 (8 B)
stop();
Symbol 18 MovieClip [powerup] Frame 1 (8 B)
stop();
Symbol 21 MovieClip [waterWave] Frame 15 (24 B)
this.removeMovieClip();
Symbol 27 Button (49 B)
on (press) {
getURL ("http://www.wonpwn.com");
}
Symbol 54 MovieClip Frame 1 (8 B)
stop();
Symbol 54 MovieClip Frame 3 (17 B)
gotoAndStop (1);
Symbol 54 MovieClip Frame 12 (83 B)
stop();
_root.underwater = true;
_root.submerging = false;
this.swapDepths(70);
Symbol 54 MovieClip Frame 15 (101 B)
_root.underwater = false;
_root.submerging = false;
gotoAndStop ("normal");
this.swapDepths(200);
Symbol 54 MovieClip Frame 90 (32 B)
_root.gameOver.play();
stop();
Symbol 62 Button (288 B)
on (keyPress "<Space>") {
if (!pauseEngine) {
if (underwater && (!submerging)) {
hippaul.gotoAndPlay("under2");
submerging = true;
splash.start();
} else if (!submerging) {
hippaul.gotoAndPlay("underwater");
submerging = true;
splash.start();
}
}
}
Symbol 68 MovieClip Frame 1 (8 B)
stop();
Symbol 68 MovieClip Frame 2 (8 B)
stop();
Symbol 74 Button (115 B)
on (rollOver) {
hippo.gotoAndStop(2);
}
on (rollOut) {
hippo.gotoAndStop(1);
}
on (release) {
gotoAndStop (3);
}
Symbol 79 MovieClip Frame 360 (8 B)
stop();
Symbol 81 Button (122 B)
on (rollOver) {
hippo.gotoAndStop(2);
}
on (rollOut) {
hippo.gotoAndStop(1);
}
on (release) {
_parent.gotoAndStop(4);
}
Symbol 100 Button (158 B)
on (release) {
gotoAndStop (1);
_root.initEngine();
_root.oVol = 100;
_root.faderOut = setInterval(_root.soundFaderOut, 200, "titleMusic", "gameMusic");
}
Symbol 106 MovieClip Frame 1 (8 B)
stop();
Symbol 106 MovieClip Frame 2 (8 B)
stop();
Symbol 106 MovieClip Frame 4 (85 B)
_root.initDemo();
leftKey.stop();
rightKey.stop();
downKey.stop();
upKey.stop();
Symbol 115 Button (59 B)
on (release) {
_root.initEngine();
this.gotoAndStop(1);
}
Symbol 116 MovieClip Frame 1 (8 B)
stop();
Symbol 116 MovieClip Frame 40 (8 B)
stop();
Symbol 121 MovieClip Frame 1 (8 B)
stop();
Symbol 124 MovieClip Frame 1 (8 B)
stop();
Symbol 124 MovieClip Frame 40 (17 B)
gotoAndStop (1);