Thursday, April 21, 2011

WHACK - A - CAPSULE ASC code

titleScreen.onRelease = function()
{
this._visible = false;
startgame();
}

startgame = function()
{
for (var i = 0; i < 9; i++)
{
var nm = "m" + i;

_root[nm].onPress = function()
{
if (this._currentframe == 10)
{
this.play();
whacks++;
scoreDisplay.whack_txt.text = whacks;
doWhackAt(_xmouse, _ymouse);
}
}

_root[nm].onEnterFrame = function()
{
if (this._currentframe == 1)
{
if ((Math.random() * 100) < 1)
{
this.play();
}
}
else if (this._currentframe == 10)
{
if ((Math.random() * 100) < 10)
{
this.play();
}
}
}
}

whacks = 0;
scoreDisplay.whack_txt.text = whacks;
endTime = getTimer() + 30000;

_root.onEnterFrame = function()
{
var etime = endTime - getTimer();

if (etime <= 0)
{
scoreDisplay.time_txt.text = "Time Up";

for (var i = 0; i < 9; i++)
{
var nm = "m" + i;
delete _root[nm].onPress;
delete _root[nm].onEnterFrame;
_root[nm].stop();
delete _root.onEnterFrame;
}
}
else
{
scoreDisplay.time_txt.text = Math.ceil(etime / 1000) + " sec";
}
}
}

wcnt = 0;
doWhackAt = function(x, y)
{
var nm = "wc" + wcnt;
_root.attachMovie("whackSign", nm, wcnt + 99);
_root[nm]._x = x;
_root[nm]._y = y;
_root[nm]._xscale = _root[nm]._yscale = 60;

_root[nm].onEnterFrame = function()
{
this._alpha -= 10;
if (this._alpha <= 10)
{
delete this.onEnterFrame;
this.removeMovieClip();
}
}

wcnt++;
wcnt %= 5;
}

No comments:

Post a Comment