home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 112
/
jogo-disk-112.iso
/
Games
/
barrels_of_monkey.swf
/
scripts
/
DefineSprite_76
/
frame_1
/
DoAction_2.as
next >
Wrap
Text File
|
2010-07-14
|
3KB
|
104 lines
function mainLoop()
{
if(!gameOver)
{
f++;
}
else if(crosshair._xscale < 1000)
{
crosshair._xscale = crosshair._yscale *= 1.2;
crosshair2._xscale = crosshair2._yscale *= 1.3;
}
else
{
crosshair2._visible = crosshair._visible = false;
}
if(f == totalFrames)
{
endGame();
}
else
{
counter++;
if(counter > alienFrequency)
{
popUpAlien();
}
if(shotsMissed > lastShotsMissed)
{
}
lastShotsMissed = shotsMissed;
}
}
function popUpAlien()
{
counter = 0;
do
{
selectedAlien = Math.ceil(Math.random() * 5);
}
while(this["alien" + selectedAlien].active);
totalAliens++;
this["alien" + selectedAlien].gotoAndPlay("alive");
this["alien" + selectedAlien].active = true;
}
function shotAlien()
{
if(!this.dead)
{
if(!gameOver)
{
this.dead = true;
master.playSound("yes");
this.anim.gotoAndPlay("dead");
updateScore(hitScore);
nextAlienFrequency = Math.ceil(alienStartFrequency - score);
if(nextAlienFrequency < minAlienFrequency)
{
nextAlienFrequency = minAlienFrequency;
}
alienFrequency = nextAlienFrequency;
shotsMissed--;
}
}
}
function updateScore(n)
{
score += n;
}
function endGame()
{
finalScore = 1;
if(!endGameOnce)
{
master.show();
gameOver = true;
finalScore = score / totalAliens;
finalScore = Math.floor(finalScore * 100);
trace("MISSED=" + shotsMissed + ", shotindex:" + shotIndex);
accuracy = 1 - shotsMissed / shotIndex;
trace("accuracy=" + accuracy * 100 + "%");
trace(score + "/" + totalAliens + "=" + finalScore);
finalScore *= (accuracy + 1) / 2;
finalScore = Math.floor(finalScore);
master.playSound("timeup");
finalScore = !isNaN(finalScore) ? finalScore : 1;
trace("FINAL SCORE=" + finalScore);
_parent.endGameBlackOut(finalScore,"timeup");
endGameOnce = true;
}
}
onMouseDown = function()
{
if(!gameOver)
{
shotIndex++;
duplicateMovieClip(this.shot,"shot" + shotIndex,16384 + this.getNextHighestDepth());
this["shot" + shotIndex]._x = crosshair._x;
this["shot" + shotIndex]._y = crosshair._y;
shotsMissed++;
}
};
controller.onEnterFrame = mainLoop;