home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 112
/
jogo-disk-112.iso
/
Games
/
jmonkey.swf
/
scripts
/
frame_1
/
DoAction.as
Wrap
Text File
|
2010-07-14
|
17KB
|
529 lines
if(!§§pop())
{
_global.setDelay = function()
{
var a = arguments;
var obj = a[0];
var fnc = a[1];
var delay = a[2];
if(typeof obj == "function" && typeof fnc == "number")
{
delay = fnc;
fnc = obj;
obj = null;
var cut = 2;
}
else
{
if(!(obj instanceof Object && typeof (fnc = obj[fnc]) == "function" && typeof delay == "number"))
{
trace("Warning : [setDelay] invalid parameter types.");
return false;
}
var cut = 3;
}
a.splice(0,cut);
var f = function(array)
{
fnc.apply(obj,array);
clearInterval(id);
};
var id = setInterval(f,delay,a);
return id;
};
_global.EF = {Old:{},OnEF:{},SetOnEF:{}};
_global.EF.traceTable = function(t)
{
var i = 0;
while(i <= t.length - 1)
{
trace(t[i].toString());
i++;
}
};
_global.EF.Old.oldrandom = _global.random;
_global.random = function(intval)
{
var a = Math.floor(Math.random());
return a;
};
ASSetPropFlags(_global,["setDelay","EF"],1);
SoundMaster = function(base, n)
{
this.base = base;
this.sound_array = [];
if(n > 0)
{
this.createAllSound(n);
}
};
sp = SoundMaster.prototype;
sp.createAllSound = function(n)
{
var i = 0;
while(i <= n - 1)
{
this.sound_array[i] = new Sound(createEmptyMovieClip("_soundmaster" + (this.base + i),this.base + i));
i++;
}
};
sp.attachAllSound = function()
{
var n = arguments.length - 1;
var i = 0;
while(i <= n)
{
this.sound_array[i].attachSound(arguments[i]);
i++;
}
};
sp.setAllVolume = function()
{
var n = arguments.length - 1;
var i = 0;
while(i <= n)
{
this.sound_array[i].setVolume(arguments[i]);
i++;
}
};
sp.setAllPan = function()
{
var n = arguments.length - 1;
var i = 0;
while(i <= n)
{
this.sound_array[i].setPan(arguments[i]);
i++;
}
};
sp.setVolume = function(n, vol)
{
var snd = this.sound_array[n];
if(vol != undefined)
{
snd.setVolume(vol);
}
};
sp.setPan = function(n, pan)
{
var snd = this.sound_array[n];
if(pan != undefined)
{
snd.setPan(pan);
}
};
sp.start = function(n, offset, loop, vol, pan)
{
var snd = this.sound_array[n];
if(vol > 0)
{
snd.setVolume(vol);
if(pan != undefined)
{
snd.setPan(pan);
}
}
snd.start(offset,loop);
};
sp.stop = function(n)
{
this.sound_array[n].stop();
};
sp.stopAllSounds = function()
{
var i = 0;
while(i <= this.sound_array.length - 1)
{
this.sound_array[i].stop();
i++;
}
};
delete sp;
stonePos = [4,4,5,5,4,4,5,5,4,6,6,4,3,4,6,6,6,6,5,2,6,5,6,4,4,7,5,5,2,4,3,4,5,5,4,4,5,5,5,4,5,5,5,5,5,4,4,5,7,2,3,5,4,3,5,5,5,6,6,2,5,6,7,4,5,5,4,5,5,3,7,5,6,6,3,6,7,6,5,6,5,5,5,4,4,8,7,7,5,6,7,6,4,6,3,5,3,6,2,5,6,5,6,5,7,4,5,3,8,7,2,6,4,6,5,2,3,4,4,4,5,4,3,7,7,4,5,7,6,4,6,7,4,4,6,4,2,4,3,4,6,8,4,7,2,3,6,3,6,5,4,5,4,6,3,4,5,4,7,4,5,5,6,7,4,6,5,6,7,6,7,3,4,3,5,7,2,3,5,6,2,3,3,2,4,4,8,7,4,6,7,6,3,7,5,6,3,5,6,6,8,4,5,7,5,4,5,7,5,5,5,6,4,5,6,4,5,6,7,7,5,7,5,3,2,7,6,4,5,2,3,4,5,8,5,5,5,6,7,3,8,8,7,2,3,3,5,5,5,5,5,7,4,5,5,7,6,5,6,5,3,5,4,5,7,3,3,3,4,6,4,5,2,4,7,4,5,6,2,4,8,5,2,4,3,4,4,4,7,5,3,5,3,3,6,7,6,5,5,4];
stoneSpd = [0,2,0,2,0,0,2,0,2,0,2,-2,0,-2,2,-2,0,-2,0,-2,0,-2,0,-2,0,-2,0,-2,2,0,2,-2,0,-2,0,-2,2,0,2,-2,2,0,2,0,2,-2,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,3,0,2,0,2,0,2,0,3,0,3,0,2,0,2,0,2,0,2,0,3,-2,0,-2,0,-2,2,-2,2,-2,3,0,3,-3,0,-2,2,0,2,0,3,-2,2,0,3,0,2,0,3,0,2,0,2,-2,0,-3,3,0,3,0,3,0,3,-3,0,-3,0,-3,4,0,4,0,4,0,4,-4,0,-4,0,-3,0,-4,4,0,3,0,4,0,3,0,3,-4,0,-4,3,0,4,0,4,0,3,0,4,0,3,0,3,0,3,0,4,0,4,-4,3,0,4,0,3,-4,0,-4,5,0,4,0,5,0,5,0,4,-5,0,-5,0,-5,0,-5,0,-5,0,-5,0,-5,4,0,5,0,4,-5,5,-4,0,-5,0,-5,5,-4,0,-5,0,-5,0,-4,0,-5,5,0,5,0,4,-4,5,-4,0,-4,0,-5,5,0,6,-6,0,-6,0,-5,0,-6,0,-6,0,-5,0,-5,0,-5,0,-5,0,-6,0,-6,5,0,5,0,5,-5,0,-5,0,-5,0,-5,6,0,5,0,6,-6,5,0,6,0,6,-5,6,0,5,0,5,0,6,0,5,0,5,0];
moveLim = [18,16,46,26,38,39,36,37,26,38,17,27,16,18,18,18,37,47,28,18,18,19,28,29,38,38,47,36,16,27,16,39,46,39,36,27,48,39,38,18,49,46,16,39,47,36,26,18,28,17,17,37,19,26,38,46,27,38,28,19,26,27,39,17,28,19,19,47,29,16,38,28,47,37,17,17,39,47,18,39,48,29,28,18,37,49,39,49,19,48,19,27,18,37,26,19,18,19,16,29,18,46,19,47,48,27,37,26,29,38,18,29,18,28,46,17,27,37,37,37,17,36,18,29,28,27,28,38,38,27,19,38,37,19,47,19,18,28,28,36,49,29,38,38,17,19,37,29,37,48,37,37,19,37,16,36,28,39,29,17,37,49,39,39,17,37,46,49,48,37,18,28,37,27,26,49,19,29,29,37,18,16,27,17,27,37,49,48,39,37,28,37,26,18,47,18,28,19,37,18,29,28,28,49,39,38,28,48,19,49,26,47,29,46,37,37,36,18,49,38,27,38,27,29,17,28,27,38,26,16,19,39,46,29,38,38,48,19,38,17,29,29,49,18,26,18,36,46,28,19,46,18,19,47,28,28,48,48,48,38,17,18,26,46,38,17,28,16,19,49,36,28,16,29,48,27,27,47,16,26,39,48,17,28,26,26,36,16,28,47,29,37,19,27,37,48,37,46,39,28];
_global.IV = {GAMEID:"MONKEYJUMP",CEIL:0,FLOOR:0,LEFT_SIDE:0,RIGHT_SIDE:0,STONE_POS_UNIT:0,STEP_HEIGHT:0,STEPS:3,JUMP_SPEED:33,ERROR_LIMIT:15,GRAVITY:3,MONKEYS_LIFE:5,SCORE_STEP:50,SCORE_LEVEL:150,SCORE_COMBO:150,COMBO_LIMIT:1200,LAND_TIME:600,COMBO_BONUS:6};
init = function()
{
ServerConnection.onGameStart();
with(IV)
{
CEIL = stone_guide._y;
FLOOR = stone_guide._y + stone_guide._height;
LEFT_SIDE = stone_guide._x;
RIGHT_SIDE = stone_guide._x + stone_guide._width;
STONE_POS_UNIT = stone_guide._width / 8;
STEP_HEIGHT = (FLOOR - CEIL) / STEPS;
}
_global.GAME = {score:0,level:0,step:0,combo:1,comboTimer:getTimer()};
GAME.sounds = new SoundMaster(1011,10);
GAME.sounds.attachAllSound("background","gameover","jump1","success","fail","jump2","jump3","jump4","lifeup","combo");
GAME.sounds.setVolume(0,50);
gameover_mc._visible = false;
gameover_mc.stop();
combo_mc._visible = false;
comboBonus_mc.bonus = 0;
comboBonus_mc.gotoAndStop(1);
makeLevel(0);
setLife(IV.MONKEYS_LIFE);
setScore(0);
setCombo(0);
setFloorNum(1);
GAME.sounds.start(0,0,1000);
stone_mc.startMove = function()
{
this.onEnterFrame = this._moveStones;
};
stone_mc.stopMove = function()
{
delete this.onEnterFrame;
};
stone_mc.getIndex = function(n)
{
return GAME.level * IV.STEPS + n;
};
stone_mc._moveLevel = function()
{
this._y += this.spd;
monkey_mc._y += this.spd;
tree_mc._y += this.spd * 0.5;
if(tree_mc._y >= 447)
{
tree_mc._y -= 447;
}
if(Math.abs(this._y) >= IV.STEPS * IV.STEP_HEIGHT)
{
this._y = 0;
var i = 0;
while(i <= IV.STEPS)
{
this["stone" + this.getIndex(i)]._y = IV.FLOOR - i * IV.STEP_HEIGHT;
i++;
}
var mc;
var idx;
var i = 0;
while(i <= IV.STEPS - 1)
{
idx = stone_mc.getIndex(i);
mc = stone_mc["stone" + (idx + IV.STEPS + 1)] = stone_mc["stone" + (idx - IV.STEPS)];
idx += IV.STEPS + 1;
mc._x = IV.LEFT_SIDE + (stonePos[idx] - 1) * IV.STONE_POS_UNIT;
mc._y = IV.FLOOR - (IV.STEPS + i + 1) * IV.STEP_HEIGHT;
mc.spd = stoneSpd[idx];
mc.leftLim = IV.LEFT_SIDE + (Number(String(moveLim[idx]).charAt(0)) - 1) * IV.STONE_POS_UNIT;
mc.rightLim = IV.LEFT_SIDE + (Number(String(moveLim[idx]).charAt(1)) - 1) * IV.STONE_POS_UNIT;
if(i > IV.STEPS)
{
mc._visible = false;
}
i++;
}
this.onEnterFrame = this._moveStones;
_quality = "HIGH";
snow_compo.onEnterFrame = snow_compo.letSnow_onef;
monkey_mc.enabled = true;
monkey_mc.land = true;
}
};
stone_mc._moveStones = function()
{
var mc;
var i = 0;
while(i <= IV.STEPS)
{
mc = this["stone" + this.getIndex(i)];
mc._x += mc.spd;
if(mc._x <= mc.leftLim || mc._x >= mc.rightLim)
{
mc.spd *= -1;
}
i++;
}
};
stone_mc.startMove();
monkey_mc.xpos = 0;
monkey_mc.ypos = 0;
monkey_mc._y = IV.FLOOR;
monkey_mc.land = true;
monkey_mc.enabled = true;
monkey_mc.gotoAndPlay("stand");
monkey_mc.onPress = function()
{
if(this.enabled)
{
this.ypos = this._y;
this.spd = IV.JUMP_SPEED;
this.enabled = false;
this.land = false;
this.xspd = stone_mc["stone" + (GAME.level * IV.STEPS + GAME.step)].spd;
this.gotoAndPlay("jump");
this.cryhead_mc._visible = false;
if(getTimer() - GAME.comboTimer <= IV.COMBO_LIMIT - IV.LAND_TIME)
{
GAME.sounds.start(GAME.combo + 4,0,1);
}
else
{
GAME.sounds.start(2,0,1);
}
monkey_mc.onEnterFrame = function()
{
this._x += this.xspd;
this._y -= this.spd -= IV.GRAVITY;
if(this.spd <= 0 && this._y >= this.ypos - IV.STEP_HEIGHT)
{
this.xspd = 0;
delete this.onEnterFrame;
this.onLand();
}
};
}
};
monkey_mc.onKeyDown = function()
{
if(Key.getCode() == 13 || Key.getCode() == 32)
{
this.onPress();
}
};
Key.addListener(monkey_mc);
monkey_mc.onLand = function()
{
GAME.step = GAME.step + 1;
var mc = stone_mc["stone" + (GAME.level * IV.STEPS + GAME.step)];
if(Math.abs(mc._x - this._x) <= IV.ERROR_LIMIT)
{
if(getTimer() - GAME.comboTimer <= IV.COMBO_LIMIT)
{
setCombo(1);
banana_mc._x = this._x + 15;
banana_mc._y = this._y;
banana_mc.onEnterFrame = banana_onEnterFrame;
}
else
{
GAME.combo = 1;
}
GAME.comboTimer = getTimer();
setFloorNum(GAME.level * IV.STEPS + GAME.step + 1);
GAME.sounds.start(3,0,1);
setScore(IV.SCORE_STEP);
this.gotoAndPlay("stand");
this._y = this.ypos - IV.STEP_HEIGHT;
this.xpos = this._x - mc._x;
this.enabled = true;
this.land = true;
mc.play();
}
else
{
GAME.sounds.stop(0);
GAME.sounds.start(4,0,1);
setLife(-1);
GAME.step--;
this.ypos = IV.FLOOR - GAME.step * IV.STEP_HEIGHT;
this.startDrop = function()
{
this.cryhead_mc._visible = true;
this.onEnterFrame = function()
{
this._y -= this.spd -= IV.GRAVITY;
if(this._y >= 550)
{
delete this.onEnterFrame;
if(GAME.life < 0)
{
onGameOver();
}
else
{
GAME.sounds.start(0,0,1000);
this._y = this.ypos;
this.enabled = true;
this.land = true;
this.gotoAndPlay("standup");
}
}
};
};
if(GAME.life < 0)
{
this.cryhead_mc._visible = false;
setDelay(this,"startDrop",800);
this.gotoAndPlay("fail");
}
else
{
this.startDrop();
}
}
};
onEnterFrame = function()
{
if(GAME.life >= 0 && monkey_mc.land)
{
monkey_mc._x = monkey_mc.xpos + stone_mc["stone" + (GAME.level * IV.STEPS + GAME.step)]._x;
}
if(Math.abs(monkey_mc.xpos) > 0)
{
monkey_mc.xpos *= 0.5;
}
if(GAME.step >= IV.STEPS && this._y < IV.STEP_HEIGHT * 4)
{
GAME.step = 0;
GAME.level = GAME.level + 1;
nextLevel();
}
};
};
makeLevel = function(n)
{
var mc;
var idx;
var i = 0;
while(i <= IV.STEPS * 2)
{
idx = n * IV.STEPS + i;
mc = stone_mc.attachMovie("stone_symbol","stone" + idx,idx);
mc._x = IV.LEFT_SIDE + (stonePos[idx] - 1) * IV.STONE_POS_UNIT;
mc._y = IV.FLOOR - i * IV.STEP_HEIGHT;
mc.spd = stoneSpd[idx];
mc.leftLim = IV.LEFT_SIDE + (Number(String(moveLim[idx]).charAt(0)) - 1) * IV.STONE_POS_UNIT;
mc.rightLim = IV.LEFT_SIDE + (Number(String(moveLim[idx]).charAt(1)) - 1) * IV.STONE_POS_UNIT;
if(i > IV.STEPS)
{
mc._visible = false;
}
i++;
}
};
nextLevel = function()
{
setScore(IV.SCORE_LEVEL);
var mc;
for(var i in stone_mc)
{
mc = stone_mc[i];
mc._visible = true;
}
monkey_mc.enabled = false;
monkey_mc.land = true;
stone_mc.spd = 20;
stone_mc.onEnterFrame = stone_mc._moveLevel;
_quality = "MEDIUM";
delete snow_compo.onEnterFrame;
};
setLife = function(n)
{
GAME.life += n;
raccoon_mc.gotoAndPlay("life");
};
setScore = function(n)
{
GAME.score += n;
score_mc.score_txt.text = GAME.score;
};
setCombo = function(n)
{
GAME.combo += n;
if(GAME.combo > 1)
{
setScore(IV.SCORE_COMBO);
comboBonus_mc.bonus += n;
if(comboBonus_mc.bonus >= IV.COMBO_BONUS)
{
comboBonus_mc.bonus -= IV.COMBO_BONUS;
setLife(1);
GAME.sounds.start(8,0,1);
}
else
{
GAME.sounds.start(9,0,1);
}
combo_mc._visible = true;
combo_mc.gotoAndPlay(1);
combo_mc.combo = GAME.combo;
}
else
{
comboBonus_mc.gotoAndStop(1);
}
};
setFloorNum = function(n)
{
var f3 = floor3_mc._currentframe - 1;
var f2 = floor2_mc._currentframe - 1;
var f1 = floor1_mc._currentframe - 1;
var n3 = Math.floor(n / 100);
var n2 = Math.floor((n - n3 * 100) / 10);
var n1 = n % 10;
if(f3 != n3)
{
floorBird3_mc.play();
}
if(f2 != n2)
{
floorBird2_mc.play();
}
if(f1 != n1)
{
floorBird1_mc.play();
}
floor3_mc.gotoAndStop(n3 + 1);
floor2_mc.gotoAndStop(n2 + 1);
floor1_mc.gotoAndStop(n1 + 1);
};
onGameOver = function()
{
GAME.sounds.start(1,0,1);
gameover_mc._visible = true;
gameover_mc.gotoAndPlay(1);
};
banana_onEnterFrame = function()
{
var xp = comboBonus_mc._x + (comboBonus_mc.bonus - 1) * 20;
this._x += (xp - this._x) * 0.3;
this._y += (comboBonus_mc._y - this._y) * 0.3;
if(Math.abs(xp - this._x) <= 1)
{
this._x = -100;
if(comboBonus_mc.bonus == 0)
{
comboBonus_mc.gotoAndPlay("life");
}
else
{
comboBonus_mc.gotoAndStop(comboBonus_mc.bonus + 1);
}
delete this.onEnterFrame;
}
};
help_mc._visible = false;
start_btn.onRelease = function()
{
gotoAndPlay(1);
};
help_btn.onRelease = function()
{
start_btn.enabled = false;
help_btn.enabled = false;
rank_btn.enabled = false;
help_mc._visible = true;
help_mc.start_btn.onRelease = start_btn.onRelease;
};
if(ServerConnection.getRankEnabled())
{
rank_btn.onRelease = function()
{
ServerConnection.onGameRankRequest();
};
}
else
{
rank_btn._visible = false;
}
stop();
}