Frame 1
function startGame() {
isOver = false;
startSound.start();
ballNum = ballTotal;
score_mc.score_txt.text = "0 pts";
score_mc.balls_txt.text = "x" + ballNum;
theTime = timerNum;
timerFunction();
theTimer = setInterval(timerFunction, 1000);
intro_mc._visible = false;
instructions_mc._visible = false;
clearAll();
attachAll();
startFire();
startMove();
theScore = 0;
redScore = 0;
blueScore = 0;
game_mc.count_mc.blueScore_txt.text = blueScore;
game_mc.count_mc.redScore_txt.text = redScore;
if (gameOver_mc._alpha > 0) {
gameOver_mc.onEnterFrame = function () {
gameOver_mc._alpha = gameOver_mc._alpha - 10;
if (gameOver_mc._alpha <= 0) {
gameOver_mc._alpha = 0;
gameOver_mc._visible = false;
delete gameOver_mc.onEnterFrame;
}
};
}
score_mc.onEnterFrame = function () {
score_mc._alpha = score_mc._alpha + 10;
if (score_mc._alpha >= 100) {
score_mc._alpha = 100;
delete score_mc.onEnterFrame;
}
};
}
function gameOver() {
clearInterval(theTimer);
trace("game over");
var _local2 = 0;
while (_local2 < enemyNum) {
var _local3 = ("blue" + _local2) + "_mc";
game_mc[_local3].guy_mc.gotoAndStop(1);
delete game_mc[_local3].onEnterFrame;
_local2++;
}
_local2 = 0;
while (_local2 < enemyNum) {
var _local3 = ("red" + _local2) + "_mc";
game_mc[_local3].guy_mc.gotoAndStop(1);
delete game_mc[_local3].onEnterFrame;
_local2++;
}
game_mc.bell_mc.stop();
delete game_mc.bell_mc.onEnterFrame;
delete this.onMouseMove;
delete this.onMouseDown;
gameOver_mc._visible = true;
fadeObject(score_mc, 10);
gameOver_mc.finalScore_txt.text = theScore + " pts";
gameOver_mc.onEnterFrame = function () {
gameOver_mc.playAgain_mc.enabled = false;
gameOver_mc.playAgain_mc._alpha = 50;
gameOver_mc._alpha = gameOver_mc._alpha + 10;
if (gameOver_mc._alpha >= 100) {
gameOver_mc._alpha = 100;
delete gameOver_mc.onEnterFrame;
gameOver_mc.finalScore_txt.text = theScore + " pts";
var tempRed = redScore;
var tempBlue = blueScore;
game_mc.count_mc.onEnterFrame = function () {
if (tempRed > 0) {
theScore--;
tempRed--;
game_mc.count_mc.redScore_txt.text = tempRed;
gameOver_mc.finalScore_txt.text = theScore + " pts";
} else if (tempBlue > 0) {
theScore++;
tempBlue--;
game_mc.count_mc.blueScore_txt.text = tempBlue;
gameOver_mc.finalScore_txt.text = theScore + " pts";
} else {
delete game_mc.count_mc.onEnterFrame;
gameOver_mc.playAgain_mc.onEnterFrame = function () {
if (gameOver_mc.playAgain_mc._alpha >= 100) {
gameOver_mc.playAgain_mc._alpha = 100;
delete gameOver_mc.playAgain_mc.onEnterFrame;
} else {
gameOver_mc.playAgain_mc._alpha = gameOver_mc.playAgain_mc._alpha + 10;
gameOver_mc.playAgain_mc.enabled = true;
}
};
}
};
}
};
}
function clearAll() {
var _local1 = 0;
while (_local1 < enemyNum) {
blueName = ("blue" + _local1) + "_mc";
redName = ("red" + _local1) + "_mc";
removeMovieClip(game_mc[blueName]);
removeMovieClip(game_mc[redName]);
_local1++;
}
_local1 = 0;
while (_local1 < treeNum) {
removeMovieClip(game_mc[("tree" + _local1) + "_mc"]);
_local1++;
}
removeMovieClip(game_mc.bell_mc);
removeMovieClip(game_mc.house_mc);
}
function timerFunction() {
if (theTime > 1) {
theTime = theTime - 1;
} else {
theTime = 0;
isOver = true;
if (!game_mc.odama_mc) {
gameOver();
}
}
var _local3 = Math.floor(theTime / 60);
var _local1 = theTime % 60;
var _local2 = _local1.toString();
if (_local1 < 10) {
_local2 = "0" + _local1.toString();
}
score_mc.time_txt.text = (_local3 + ":") + _local2;
score_mc.time2_txt.text = score_mc.time_txt.text;
}
function attachEn(theSide, theNum, theX, theY) {
if (theSide == "blue") {
var _local5 = "blueGroup";
var _local4 = 1;
} else {
var _local5 = "redGroup";
var _local4 = 2;
}
theNum = theNum.toString();
var _local1 = (theSide + theNum) + "_mc";
game_mc.attachMovie(_local5, _local1, theY, {_x:theX, _y:theY});
game_mc[_local1].swapDepths(theY);
game_mc[_local1].theNum = theNum;
game_mc[_local1].gotoAndStop(_local4);
game_mc[_local1].onEnterFrame = eMove;
}
function attachAll() {
var _local2 = 0;
while (_local2 < enemyNum) {
var _local4 = Math.round(Math.random() * 75) + 33;
var _local3 = Math.round(Math.random() * 90) + 95;
attachEn("blue", _local2, _local4, _local3);
_local4 = Math.round(Math.random() * 75) + 280;
_local3 = Math.round(Math.random() * 90) + 95;
attachEn("red", _local2, _local4, _local3);
_local2++;
}
treeNum = 4;
_local2 = 0;
while (_local2 < treeNum) {
var _local7 = Math.round(Math.random() * 228) + 104;
var _local5 = Math.round(Math.random() * 61) + 120;
var _local9 = _local5;
var _local1 = ("tree" + _local2) + "_mc";
game_mc.attachMovie("tree", _local1, _local9, {_x:_local7, _y:_local5});
game_mc[_local1]._x = _local7;
game_mc[_local1]._y = _local5;
game_mc[_local1].theTree = _local2;
var _local8 = (game_mc[_local1]._y - 67) / 114;
var _local6 = 30;
game_mc[_local1]._yscale = Math.round(100 - ((_local6 - (_local8 * _local6)) + 1));
game_mc[_local1]._xscale = game_mc[_local1]._yscale;
_local2++;
}
game_mc.attachMovie("tree", "tree1", 702, {_x:63, _y:310});
game_mc.attachMovie("tree", "tree2", 703, {_x:314, _y:312});
var _local13 = Math.round(Math.random() * 148) + 134;
var _local11 = Math.round(Math.random() * 30) + 161;
game_mc.attachMovie("house", "house_mc", _local11, {_x:_local13, _y:_local11});
var _local15 = 250;
var _local12 = 80;
var _local14 = _local12;
game_mc.attachMovie("bell", "bell_mc", _local14, {_x:_local15, _y:_local12});
moveDist = 2;
game_mc.bell_mc.hit = false;
game_mc.bell_mc.vX = moveDist;
game_mc.bell_mc.moveTime = random(40) + 30;
game_mc.bell_mc.onEnterFrame = function () {
var _local1 = game_mc.bell_mc;
if (!_local1.hit) {
_local1.play();
if ((_local1._x >= (farX - 70)) or (_local1._x <= 60)) {
_local1.moveTime = random(40) + 40;
if (_local1._x >= (farX - 70)) {
_local1.vX = -moveDist;
}
if (_local1._x <= 60) {
_local1.vX = moveDist;
}
} else {
_local1.moveTime--;
if (_local1.moveTime <= 0) {
bellDirection();
}
}
_local1._x = _local1._x + _local1.vX;
} else {
_local1.stop();
}
};
}
function bellDirection() {
var _local1 = game_mc.bell_mc;
_local1.moveTime = random(40) + 40;
if (!_local1.hit) {
var _local2 = random(2);
if (_local2 == 0) {
_local1.vX = moveDist;
} else {
_local1.vX = -moveDist;
}
}
}
function startFire() {
this.onMouseDown = function () {
if (!game_mc.odama_mc) {
fire.start();
cannon_mc.fireBall_mc.play();
damaSpeed = 10;
ballNum = ballNum - 1;
score_mc.balls_txt.text = "x" + ballNum;
var _local13 = cannon_mc.spot_mc._x;
var _local12 = cannon_mc.spot_mc._y;
var _local6 = {x:_local13, y:_local12};
var cannonAngle = cannon_mc._rotation;
cannon_mc.localToGlobal(_local6);
game_mc.attachMovie("odama", "odama_mc", 600, {_x:_local6.x, _y:_local6.y});
var dama = game_mc.odama_mc;
dama.onEnterFrame = function () {
if (damaSpeed <= 0) {
damaSpeed = 1;
}
if ((dama._y <= 64) and (dama._y >= 54)) {
var _local5 = game_mc.bell_mc;
var _local10 = (dama._width / 2) + dama._x;
var _local11 = ((_local5._width / 2) + _local5._x) - 20;
var _local6 = Math.abs(_local10 - _local11);
if (_local6 < 25) {
_local5.bellring_mc.play();
dama.hitBell = true;
_local5.hit = true;
var _local8 = Math.round((25 - _local6) * 80);
theVol = _local8 / 20;
bong.setVolume(theVol);
bong.start();
var newScore = (theScore + _local8);
score_mc.onEnterFrame = function () {
theScore = theScore + 100;
if (theScore >= newScore) {
theScore = newScore;
delete score_mc.onEnterFrame;
}
score_mc.score_txt.text = theScore + " pts";
};
dama.gotoAndStop(2);
fadeObject(game_mc.odama_mc, 5);
if (ballNum == 0) {
gameOver();
}
if (isOver) {
gameOver();
}
}
}
if (!dama.hitBell) {
dama._y = dama._y - (Math.sin((Math.PI * (cannonAngle + 90)) / 180) * damaSpeed);
dama._x = dama._x - (Math.cos((Math.PI * (cannonAngle + 90)) / 180) * damaSpeed);
}
if ((dama._y <= 53) or (dama._x <= 0)) {
dama.gotoAndStop(2);
fadeObject(game_mc.odama_mc, 10);
if (ballNum == 0) {
gameOver();
}
if (isOver) {
gameOver();
}
}
if ((dama.hitArea_mc.hitTest(game_mc.rightSide_mc) or dama.hitArea_mc.hitTest(game_mc.rightSide2_mc)) or dama.hitArea_mc.hitTest(game_mc.leftSide_mc)) {
dama.gotoAndStop(2);
fadeObject(game_mc.odama_mc, 10);
if (ballNum == 0) {
gameOver();
}
if (isOver) {
gameOver();
}
}
var _local9 = (dama._y - 44) / 240;
var _local7 = 40;
dama._yscale = 100 - ((_local7 - (_local9 * _local7)) + 1);
dama._xscale = dama._yscale;
var _local3 = 0;
while (_local3 < treeNum) {
var _local2 = game_mc[("tree" + _local3) + "_mc"];
if (dama.hitArea_mc.hitTest(_local2.hitArea_mc)) {
if (!_local2.hit) {
hitTree.start();
damaSpeed = damaSpeed - 1;
_local2.hit = true;
_local2.play();
}
}
_local3++;
}
var _local4 = game_mc.house_mc;
if (dama.hitArea_mc.hitTest(_local4.hitArea_mc)) {
if (!_local4.hit) {
hitHouse.start();
damaSpeed = damaSpeed - 2;
_local4.hit = true;
_local4.play();
}
}
_local3 = 0;
while (_local3 < enemyNum) {
var _local1 = game_mc[("blue" + _local3) + "_mc"];
if (dama.hitArea_mc.hitTest(_local1.hitArea_mc)) {
if (!_local1.hit) {
hitEn.start();
damaSpeed = damaSpeed - 0.3;
_local1.hit = true;
blueScore++;
game_mc.count_mc.blueScore_txt.text = blueScore;
_local1.gotoAndPlay(4);
}
}
_local3++;
}
_local3 = 0;
while (_local3 < enemyNum) {
var _local1 = game_mc[("red" + _local3) + "_mc"];
if (dama.hitArea_mc.hitTest(_local1.hitArea_mc)) {
if (!_local1.hit) {
hitEn.start();
damaSpeed = damaSpeed - 0.3;
_local1.hit = true;
redScore++;
game_mc.count_mc.redScore_txt.text = redScore;
_local1.gotoAndPlay(4);
}
}
_local3++;
}
};
}
};
}
function turnDirection(enemy) {
enemy.moveTime = random(40) + 20;
if (!enemy.hit) {
var _local1 = random(2) + 1;
var _local3 = random(360);
var _local6 = Math.cos((_local3 * Math.PI) / 180);
var _local4 = Math.sin((_local3 * Math.PI) / 180);
var _local7 = _local1 * _local6;
var _local5 = _local1 * _local4;
enemy.vX = _local7;
enemy.vY = _local5;
}
}
function checkHit(newX, newY) {
var _local3 = false;
if ((newX > farX) or (newX < 1)) {
_local3 = true;
}
if ((newX < 40) and (newY < 85)) {
_local3 = true;
}
if ((newY > farY) or (newY < zeroY)) {
_local3 = true;
}
var _local1 = 0;
while (_local1 < treeNum) {
var _local2 = game_mc[("tree" + _local1) + "_mc"].hitArea_mc;
if (_local2.hitArea_mc.hitTest(newX, newY, false)) {
_local3 = true;
}
_local1++;
}
if (game_mc.house_mc.hitArea_mc.hitTest(newX, newY, false)) {
_local3 = true;
}
return(_local3);
}
function eMove() {
var _local5 = this._x + this.vX;
var _local4 = (this._y - 7) + this.vY;
var _local6 = checkHit(_local5, _local4);
if (!_local6) {
this._x = this._x + this.vX;
this._y = this._y + this.vY;
if (this.vX >= 0) {
if (!this.hit) {
this.gotoAndStop(1);
}
} else if (!this.hit) {
this.gotoAndStop(2);
}
if ((Math.abs(this.vX) + 0.8) < Math.abs(this.vY)) {
if (!this.hit) {
this.gotoAndStop(3);
}
}
var _local3 = (this._y - 44) / 200;
var _local2 = 30;
this._yscale = Math.round(100 - ((_local2 - (_local3 * _local2)) + 1));
this._xscale = this._yscale;
} else {
moveTime = 0;
turnDirection(this);
}
this.moveTime--;
if (this.moveTime <= 0) {
turnDirection(this);
}
this.swapDepths(this._y);
}
function startMove() {
this.onMouseMove = function () {
updateAfterEvent();
var _local4 = this._xmouse - cannonBaseX;
var _local3 = this._ymouse - cannonBaseY;
var _local2 = Math.atan2(_local3, _local4);
_local2 = (_local2 * 180) / Math.PI;
if ((_local2 >= -145) and (_local2 <= -40)) {
cannon_mc._rotation = _local2 + 90;
}
};
}
function moveObject(theObject, theDirection, theTarget) {
var velocity = 0;
var accel = 0;
var k = 0.9;
var target = theTarget;
var m = 1.8;
var decay = 0.2;
var startPos = theObject[theDirection];
theObject.onEnterFrame = function () {
accel = (-(k / m)) * (startPos - target);
velocity = velocity * decay;
velocity = velocity + accel;
startPos = startPos + velocity;
theObject[theDirection] = startPos;
if (theObject[theDirection] == target) {
delete theObject.onEnterFrame;
}
};
}
function fadeObject(theObject, theSpeed) {
theObject.onEnterFrame = function () {
theObject._alpha = theObject._alpha - theSpeed;
if (theObject._alpha <= 0) {
theObject._alpha = 0;
game_mc.bell_mc.hit = false;
delete theObject.onEnterFrame;
removeMovieClip(theObject);
}
};
}
_quality = "BEST";
var zeroX = 33;
var zeroY = 90;
var farX = 360;
var farY = 260;
var theScore = 0;
var redScore = 0;
var blueScore = 0;
var ballTotal = 10;
var ballNum = ballTotal;
var damaSpeed = 10;
var timerNum = 45;
var theTime = timerNum;
var isOver = false;
var treeNum;
var enemyNum = 40;
var eSpeed = 2;
var moveTime = 0;
var moveCount = 0;
var moveDist = 2;
var cannonBaseX = 192;
var cannonBaseY = 356;
var cannonAngle;
this.createEmptyMovieClip("startSound", 999998);
var startSound = new Sound(startSound);
startSound.attachSound("startGame");
startSound.setVolume(100);
this.createEmptyMovieClip("bong", 999997);
var bong = new Sound(bong);
bong.attachSound("bong");
bong.setVolume(100);
this.createEmptyMovieClip("fire", 999996);
var fire = new Sound(this);
fire.attachSound("fire");
fire.setVolume(100);
this.createEmptyMovieClip("hitHouse", 999995);
var hitHouse = new Sound(this);
hitHouse.attachSound("hitHouse");
hitHouse.setVolume(100);
this.createEmptyMovieClip("hitTree", 999994);
var hitTree = new Sound(this);
hitTree.attachSound("hitTree");
hitTree.setVolume(100);
this.createEmptyMovieClip("hitEn", 999988);
var hitEn = new Sound(this);
hitEn.attachSound("hitEn");
hitEn.setVolume(100);
this.onEnterFrame = function () {
var _local3 = this.getBytesLoaded();
var _local2 = this.getBytesTotal();
var _local4 = (_local3 / _local2) * 100;
loader.loadBar._yscale = _local4;
if (_local3 == _local2) {
loader.play();
delete this.onEnterFrame;
}
};
stop();
Frame 2
intro_mc.playNow_mc.onPress = function () {
startGame();
};
intro_mc.playNow_mc.onRollOver = function () {
intro_mc.playNow_mc.gotoAndStop(2);
};
intro_mc.playNow_mc.onRollOut = function () {
intro_mc.playNow_mc.gotoAndStop(1);
};
intro_mc.readInst_mc.onPress = function () {
intro_mc._visible = false;
};
intro_mc.readInst_mc.onRollOver = function () {
intro_mc.readInst_mc.gotoAndStop(2);
};
intro_mc.readInst_mc.onRollOut = function () {
intro_mc.readInst_mc.gotoAndStop(1);
};
gameOver_mc.playAgain_mc.onRelease = function () {
startGame();
};
gameOver_mc.playAgain_mc.onPress = function () {
gameOver_mc.playAgain_mc.gotoAndStop(3);
};
gameOver_mc.playAgain_mc.onRollOver = function () {
gameOver_mc.playAgain_mc.gotoAndStop(2);
};
gameOver_mc.playAgain_mc.onRollOut = function () {
gameOver_mc.playAgain_mc.gotoAndStop(1);
};
gameOver_mc.visit_mc.onPress = function () {
getURL ("http://odama.nintendo.com", "_blank");
};
gameOver_mc.visit_mc.onRollOver = function () {
gameOver_mc.visit_mc.gotoAndStop(2);
};
gameOver_mc.visit_mc.onRollOut = function () {
gameOver_mc.visit_mc.gotoAndStop(1);
};
instructions_mc.instPlay_mc.onPress = function () {
startGame();
};
instructions_mc.instPlay_mc.onRollOver = function () {
instructions_mc.instPlay_mc.gotoAndStop(2);
};
instructions_mc.instPlay_mc.onRollOut = function () {
instructions_mc.instPlay_mc.gotoAndStop(1);
};
gameOver_mc._visible = false;
stop();
Symbol 26 MovieClip [odama] Frame 1
stop();
Symbol 44 MovieClip [redGroup] Frame 1
var vX;
var vY;
var moveCount = 0;
var moveTime = 0;
var scaler = -100;
var speed;
var hit = false;
Symbol 44 MovieClip [redGroup] Frame 2
stop();
Symbol 44 MovieClip [redGroup] Frame 3
stop();
Symbol 44 MovieClip [redGroup] Frame 26
this._x = this._parent._parent.farX - 1;
this._y = 181 - theNum;
Symbol 56 MovieClip [blueGroup] Frame 1
var vX;
var vY;
var theNum;
var moveCount = 0;
var moveTime = 0;
var scaler = 100;
var speed;
var hit = false;
stop();
Symbol 56 MovieClip [blueGroup] Frame 26
this._x = 1;
this._y = 181 - theNum;
Symbol 58 MovieClip [blueGuy] Frame 1
var vX;
var vY;
var moveCount = 0;
var moveTime = 0;
var scaler = 100;
var hit = false;
stop();
Symbol 68 MovieClip Frame 15
stop();
Symbol 78 MovieClip [tree] Frame 1
var hit = false;
var theTree;
stop();
Symbol 78 MovieClip [tree] Frame 7
stop();
Symbol 91 MovieClip [house] Frame 1
var hit = false;
stop();
Symbol 91 MovieClip [house] Frame 7
stop();
Symbol 97 MovieClip Frame 1
stop();
Symbol 97 MovieClip Frame 17
Symbol 104 MovieClip [bell] Frame 1
var hit;
var moveTime;
var vX;
Symbol 115 MovieClip [loader] Frame 1
stop();
Symbol 115 MovieClip [loader] Frame 26
_parent.play();
Symbol 115 MovieClip [loader] Frame 35
stop();
Symbol 135 MovieClip Frame 1
stop();
Symbol 174 MovieClip Frame 1
stop();
Symbol 184 MovieClip Frame 1
stop();
Symbol 187 MovieClip Frame 1
stop();
Symbol 196 MovieClip Frame 1
stop();
Symbol 202 MovieClip Frame 1
stop();