Friday, November 6, 2009

Stage 1 - Backbone Research

Stage.showMenu = false;
System.useCodepage = true;
gameInit = function ()
{

_quality = "Medium";
movie_type = "b_type";
time_value = 120;
time = time_value;
set_timer();
g = 3;
score = 0;
life = 3;
m_value = 5;
x_min = 15;
x_max = 535;
y_array = 418;
jump_value = 18;
up_value = 3;
max_add_y = 20;
block_w = 35;
block_h = 35;
set_timer();
set_score();
stage_num = 0;
cha.swapDepths(100);
grid._visible = false;
cha_init_x = 500;
cha_init_y = 420;
next_stage();

};
game_restart = function ()
{
state = 1;
removeAllInterval();
time = time_value;
time_interval = setInterval(time_f, 1000);
var i = 0;
while (i <= 13) { this["s" + i] = new Array(); i++; } // end while (stage_num == 1) { s0 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; s1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; s2 = ["b", "b", "b", "b", "b", "b", "b", 0, "b", "b", "b", "E", "b", "b", "b", "b"]; s3 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "L", 0, 0, 0, 0]; s4 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "L", 0, 0, 0, 0]; s5 = ["b", "E", "b", 0, "b", "b", "b", "b", "b", "b", "b", "b", 0, "b", "b", 0]; s6 = [0, "L", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; s7 = [0, "L", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; s8 = ["b", "E", "b", "b", "b", "b", "b", 0, "b", "b", "b", "b", "b", "b", "E", "b"]; s9 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "L", 0]; s10 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "b", "b", "b", "b", "b"]; s11 = [0, 0, 0, 0, 0, 0, 0, 0, 0, "b", "E", 0, 0, 0, 0, 0]; s12 = ["b", "b", "b", "b", "b", "b", "b", "b", "s", "s", "L", 0, 0, 0, 0, 0]; s13 = ["b", "b", "b", "b", "b", "b", "b", "b", "b", "b", "b", "b", "b", "b", "b", "b"]; } // end if create_evil(); }; game_out = function (input) { if (ladderSound != undefined) { ladderSound.stop("ladder_up_sound"); delete ladderSound; } // end if success_check = input; if (success_check == "success") { snd_attach("stage_finish_sound"); (stage_num == 1) { game_over_interval = setInterval(game_over_f, 2000); } } else if (success_check == "fail") { life--; score_m.life_mc.gotoAndStop(4 - life); if (life <= 0) { game_over(); } else { time = time_value; set_timer(); } // end if score_m.life_mc.gotoAndStop(4 - life); } // end if }; game_over = function () { removeAllInterval(); state = 0; cha.gotoAndStop("die"); cha.alpha = 100; cha._alpha = 100; cha.onEnterFrame = function () { this.alpha = this.alpha - 3; if (this.alpha <= 0) { this.onEnterFrame = null; game_over_f(); } // end if }; }; game_over_f = function () { _quality = "High"; evil_control.removeMovieClip(); effect_control.removeMovieClip(); item_union.removeMovieClip(); fire_control.removeMovieClip(); cha.removeMovieClip(); if (success_check == "success") { gotoAndStop(245); stopAllSounds(); snd_attach("success_sound"); } else { stopAllSounds(); gotoAndStop(252); snd_attach("fail_sound"); } // end if removeAllInterval(); }; goto_scene = function () { gotoAndStop(204); }; next_stage = function () { removeAllInterval(); remove_evil(); state = 0; stage_num++; if (stage_num == 1) { cha_init_x = 500; cha_init_y = 420; } // end if cha._x = cha_init_x; cha._y = cha_init_y; cha._xscale = 100; cha.gotoAndStop("ready"); cha.mode = undefined; cha.attack_check = undefined; cha.attack_after = undefined; _root.gotoAndStop("stage" + stage_num); stage_message.stage_txt.gotoAndStop("stage" + stage_num); stage_message.gotoAndPlay(1); stopAllSounds(); snd_attach("bg" + stage_num + "_sound", "loop"); }; time_f = function () { time--; if (time <= 0) { time_over(); } // end if set_timer(); }; time_over = function () { state = 0; cha.gotoAndStop("time_over"); game_out("fail"); time_over_interval = setInterval(time_over_f, 2000); snd_attach("cha_die_sound"); }; time_over_f = function () { if (state == 0) { state = 1; } // end if clearInterval(time_over_interval); }; set_timer = function () { var time_ref = String(time); var i = 1; while (i <= 3) { score_m.timer_mc["timer" + i].gotoAndStop("blind"); i++; } // end while var i = 1; while (i <= time_ref.length) { var f_num = Number(time_ref.substr(i - 1, 1)); if (f_num == 0) { f_num = 10; } // end if score_m.timer_mc["timer" + i].gotoAndStop(f_num); i++; } // end while }; _global.snd_attach = function (name, loop) { mySound = new Sound(); mySound.attachSound(name); if (loop == undefined) { mySound.start(); } else { mySound.start(0, 999); } // end if }; removeAllInterval = function () { var imsi_interval = setInterval(function () { }, 1000); var i = 0; while (i <= imsi_interval) { clearInterval(i); i++; } // end while }; score_cul = function (item) { switch (item) { case "evil_die": { var add_score = 10; break; } case "evil_damage": { var add_score = 1; break; } case "get_item": { var add_score = 5; break; } case "damage_cha": { var add_score = -2; break; } default: { break; } } // End of switch score = score + add_score; score_disp._x = cha._x; score_disp._y = cha._y - 20; score_disp.gotoAndPlay("show"); if (add_score > 0)
{
score_disp.score_txt_m.score_txt.text = " +" + add_score;
}
else
{
score_disp.score_txt_m.score_txt.text = add_score;
} // end if
if (score < score =" 0;" set_score =" function" score_ref =" String(score);" i =" 1;" i =" 1;" f_num =" Number(score_ref.substr(i" f_num ="="" f_num =" 10;" return_pos =" function" onenterframe =" function" state ="="" imsi =" true;" mode = "slope" add_x =" undefined;" add_y =" undefined;" limit_y =" this._y" ref_y =" this._y" ref_y =" ref_y" mode ="=""> 0)
{
this._y = ref_y;
this.gotoAndStop("ready");
this.mode = "slope";
this.attack_after = undefined;
this.attack_check = undefined;
} // end if
}
else
{
this._y = ref_y;
} // end if
if (Key.isDown(37) && this.mode != "attack")
{
this._x = this._x + -0.838671 * m_value * 1.200000;
if (this._currentframe != 7)
{
this.gotoAndStop("walk");
} // end if
this._xscale = 100;
}
else if (Key.isDown(39) && this.mode != "attack")
{
this._x = this._x + 0.838671 * m_value * 1.200000;
if (this._currentframe != 7)
{
this.gotoAndStop("walk");
} // end if
this._xscale = -100;
} // end if
if (Key.isDown(32))
{
var ix = Math.floor(this._x / block_w);
var iy = Math.floor(this._y / block_h);
var t_pos = return_pos(ix, iy - 1);
if (t_pos != "b" && t_pos != "L" && t_pos != "E")
{
this.add_y = -jump_value;
this.mode = "jump";
this.gotoAndStop("jump");
if (Key.isDown(37))
{
this.add_x = -m_value;
}
else if (Key.isDown(39))
{
this.add_x = m_value;
} // end if
} // end if
} // end if
if (Key.isDown(88))
{
if (this.attack_check != true)
{
this.gotoAndStop("attack2");
this.mode = "attack";
this.attack_check = true;
attack_after();
} // end if
} // end if
}
else
{
if (this.mode == "slope")
{
this.mode = undefined;
} // end if
_root.imsi = false;
} // end if
if (this.mode != "up" && this.mode != "slope" && this.mode != "attack" && this.mode != "down")
{
this._x = this._x + this.add_x;
this._y = this._y + this.add_y;
if (this._x < _x =" x_min;"> x_max)
{
this._x = x_max;
} // end if
var ix = Math.floor(this._x / block_w);
var iy = Math.floor(this._y / block_h);
var c_pos = return_pos(ix, iy);
var b_pos = return_pos(ix, iy + 1);
if (this.add_y > 0)
{
if (b_pos == "b" || b_pos == "E" || b_pos == "s")
{
this._y = iy * block_h;
this.add_x = 0;
this.add_y = 0;
if (this.mode == "jump" || this.mode == "fall")
{
snd_attach("reach_sound");
} // end if
this.mode = undefined;
if (!Key.isDown(37) && !Key.isDown(39))
{
this.gotoAndStop("ready");
} // end if
}
else if (b_pos == "L" || b_pos == "S" || c_pos == "L")
{
if (this.mode != "damage")
{
this._x = ix * block_w + block_w / 2;
this.add_x = 0;
this.add_y = 0;
if (this.mode == "jump")
{
snd_attach("ladder_sound");
} // end if
this.mode = "up";
this.gotoAndStop("up");
this.m.stop();
} // end if
}
else if (this.mode != "jump" && this.mode != "damage")
{
this.gotoAndStop("jump");
this.mode = "fall";
if (this._x - ix * block_w < _x =" ix" _x =" (ix" mode ="="" _xscale ="="" _xscale =" 100;"> this._x - ix * block_w)
{
var l_pos = return_pos(ix - 1, iy);
if (l_pos == "b" || ix == 0)
{
}
else
{
this._x = this._x - m_value;
if (this._currentframe != 7)
{
this.gotoAndStop("walk");
} // end if
} // end if
}
else
{
this._x = this._x - m_value;
} // end if
}
else if (Key.isDown(39))
{
if (this._xscale == 100)
{
this._xscale = -100;
} // end if
if ((ix + 1) * block_w - this._x < r_pos =" return_pos(ix" r_pos ="="" ix ="="" _x =" this._x" _x =" this._x" ix =" Math.floor(this._x" iy =" Math.floor(this._y" t_pos =" return_pos(ix," c_pos =" return_pos(ix," add_y =" -jump_value;" mode = "jump" add_x =" -m_value;" add_x =" m_value;" c_pos ="="" c_pos ="="" mode = "up" _x =" ix" xscale =" this._xscale;" laddersound =" new" attack_nife =" random(3)" attack_nife ="="" attack_nife =" random(3)" attack_pre_nife =" this.attack_nife;" mode = "attack" attack_check =" true;" mode ="="" _y =" this._y" ix =" Math.floor(this._x" iy =" Math.floor(this._y" c_pos =" return_pos(ix," c_pos ="="" _y =" iy" mode =" undefined;" _xscale =" this.xscale;" laddersound ="="" laddersound =" new" _y =" this._y" ix =" Math.floor(this._x" iy =" Math.floor(this._y" b_pos =" return_pos(ix," b_pos ="="" _y =" iy" mode =" undefined;" _xscale =" this.xscale;" laddersound ="="" laddersound =" new" ix =" Math.floor(this._x" iy =" Math.floor(this._y" t_pos =" return_pos(ix," c_pos =" return_pos(ix," c_pos ="="" add_y =" -jump_value;" mode = "jump" add_x =" -m_value;" add_x =" m_value;" mode ="="" tmc =" evil_control[name];" attack_after =" true;" mode ="="" _x =" x_min;"> x_max)
{
this._x = x_max;
} // end if
var ix = Math.floor(this._x / block_w);
var iy = Math.floor(this._y / block_h);
var b_pos = return_pos(ix, iy + 1);
var c_pos = return_pos(ix, iy);
if (this.add_y > 0 && c_pos == 0 && (b_pos == "b" || b_pos == "E" || b_pos == "L") && this._y > this.ty)
{
this.mode = undefined;
this.gotoAndStop("ready");
this.add_x = 0;
this.add_y = 0;
this.ty = undefined;
this.attack_check = undefined;
this.attack_after = undefined;
} // end if
} // end if
if (this.add_y < add_y =" this.add_y" attack_after =" function" attack_interval =" setInterval(attack_interval_f," down_after =" function" mode =" undefined;" attack_after =" undefined;" attack_check =" undefined;" attack_interval_f =" function" mode ="="" mode =" undefined;" attack_after =" undefined;" attack_check =" undefined;" attack_check =" undefined;" create_evil =" function" num =" 0;" num =" 0;" num =" 0;" stage_num ="="" evil_pos =" [{x:" evil_type =" [" i =" 0;" ran =" random(evil_type.length);" evil_name =" evil_type[ran];" evil_name ="="" mc =" evil_control[" _x =" evil_pos[i].x;" _y =" evil_pos[i].y;" min_x =" evil_pos[i].min_x;" max_x =" evil_pos[i].max_x;" damage_num =" 0;" type ="="" add_x =" random(2)" add_x =" random(3)" direct = "right" _xscale =" -100;" direct = "left" add_x =" mc.add_x" evil_num =" evil_pos.length;" num =" 0;" _alpha =" 0;" onenterframe =" function" _alpha =" this._alpha">= 100)
{
this._alpha = 100;
this.onEnterFrame = null;
evil_control.onEnterFrame = function ()
{
this.num++;
if (this.num > 100)
{
this.num = 0;
} // end if
if (this.num % 3 == 0)
{
for (name in this)
{
if (typeof(this[name]) == "movieclip")
{
if (this[name].damage_check != true)
{
var mc = this[name];
if (random(10) == 0)
{
if (mc.type == "dal")
{
mc.add_x = random(4);
}
else
{
mc.add_x = random(5);
} // end if
if (mc.direct == "left")
{
mc.add_x = mc.add_x * -1;
} // end if
}
else if (random(20) == 0)
{
if (mc.type == "dal")
{
mc.add_x = random(6) + 1;
}
else
{
mc.add_x = random(6) + 2;
} // end if
if (mc.direct == "left")
{
mc.add_x = mc.add_x * -1;
} // end if
} // end if
if (mc.add_x == 0)
{
mc.gotoAndStop("ready");
}
else
{
mc.gotoAndStop("walk");
} // end if
if (mc._x + mc.add_x <= mc.min_x) { mc.direct = "right"; if (mc.add_x < add_x =" mc.add_x" _x =" mc.min_x;" _xscale =" -100;">= mc.max_x)
{
mc.direct = "left";
if (mc.add_x > 0)
{
mc.add_x = mc.add_x * -1;
} // end if
mc._x = mc.max_x;
mc._xscale = 100;
} // end if
mc._x = mc._x + mc.add_x;
if (mc.hit_m.hitTest(cha.hit_m))
{
if (cha.mode != "damage")
{
if (cha.damage_check != true && cha._y + 10 < create_item =" function" item_num =" random(4)" mc =" item_union[" _x =" evil_mc._x;" _y =" evil_mc._y" ty =" evil_mc._y;" add_y =" -jump_value;" onenterframe =" function" _y =" this._y" add_y =" this.add_y">= this.ty)
{
this.onEnterFrame = null;
this._y = this.ty;
snd_attach("reach_sound");
} // end if
};
};
get_item = function ()
{
for (name in item_union)
{
var imsi_mc = item_union[name];
if (typeof(imsi_mc) == "movieclip")
{
if (cha.hit_m.hitTest(imsi_mc))
{
imsi_mc.ty = imsi_mc._y - 60;
imsi_mc.gotoAndPlay(1);
imsi_mc.onEnterFrame = function ()
{
smoothMove(this, this._x, this.ty, 0.300000);
this._alpha = this._alpha - 2;
if (Math.abs(this.ty - this._y) < onenterframe =" null;" num =" 0;" add_y =" 0;" onenterframe =" function" add_y =" this.add_y" _y =" this._y">= 10)
{
this.onEnterFrame = null;
this.removeMovieClip();
} // end if
};
} // end if
};
score_cul("get_item");
snd_attach("get_item_sound");
} // end if
} // end if
} // end of for...in
};
damage_evil = function (mc)
{
mc.gotoAndStop("damage");
if (mc._x - cha._x > 0)
{
mc.tx = mc._x + 50;
mc.direct = "left";
mc._xscale = 100;
if (mc.add_x > 0)
{
mc.add_x = mc.add_x * -1;
} // end if
}
else
{
mc.tx = mc._x - 50;
mc.direct = "right";
mc._xscale = -100;
if (mc.add_x < add_x =" mc.add_x"> mc.max_x)
{
mc.tx = mc.max_x;
}
else if (mc.tx < tx =" mc.min_x;" damage_check =" true;" onenterframe =" function" onenterframe =" null;" damage_check =" undefined;" type ="="" type ="="" type ="="" type ="="" type ="="" emc =" effect_control[" _x =" mc._x;" _y =" mc._y" emc =" effect_control[" _x =" mc._x;" _y =" mc._y" fire_num =" random(6)" i =" 1;"> 50)
{
fire_control.num = 1;
} // end if
var fmc = fire_control.attachMovie("fire_m", "fire" + fire_control.num, fire_control.num);
fmc._x = mc._x;
fmc._y = mc._y;
fmc._xscale = fmc._yscale = random(80) + 20;
fmc.add_x = random(8) - 4;
fmc.add_y = -random(15) - 10;
fmc.ty = fmc._y + 20 + random(15);
fmc.onEnterFrame = function ()
{
this._x = this._x + this.add_x;
this._y = this._y + this.add_y;
this.add_y = this.add_y + _root.g;
if (this._y >= this.ty)
{
if (random(3) != 0)
{
this.onEnterFrame = null;
this.removeMovieClip();
}
else if (this.bound_check == undefined)
{
this.add_y = this.add_y * -0.700000;
this.bound_check = true;
this._xscale = this._yscale = this._yscale * 0.700000;
} // end if
} // end if
};
i++;
} // end while
};
damage_cha = function (evil_mc)
{
cha.mode = "damage";
cha.damage_check = true;
if (evil_mc._x - cha._x > 0)
{
cha.add_x = -m_value * 1.500000;
}
else
{
cha.add_x = m_value * 1.500000;
} // end if
cha.add_y = -jump_value + 5;
cha.ty = evil_mc._y;
cha.gotoAndStop("damage");
score_cul("damage_cha");
game_out("fail");
damage_cha_effect_interval = setInterval(damage_cha_effect_f, 80);
damage_cha_after_interval = setInterval(damage_cha_after_f, 3000);
snd_attach("hit_sound");
snd_attach("cha_die_sound");
};
damage_cha_after_f = function ()
{
cha.mode = undefined;
cha.damage_check = undefined;
cha.attack_after = undefined;
cha.attack_check = undefined;
cha._alpha = 100;
clearInterval(damage_cha_after_interval);
clearInterval(damage_cha_effect_interval);
};
damage_cha_effect_f = function ()
{
if (random(2) == 0)
{
cha._alpha = 80;
}
else
{
cha._alpha = 20;
} // end if
};
smoothMove = function (mc, tx, ty, sp)
{
var dx = tx - mc._x;
var dy = ty - mc._y;
mc._x = mc._x + dx * sp;
mc._y = mc._y + dy * sp;
};


alert = function (input)
{
getURL("javascript:alert (\"" + input + "\");", "");
};
myListen = new Object();
myListen.onKeyDown = function ()
{
if (Key.isDown(90))
{
get_item();
} // end if
};
myListen.onKeyUp = function ()
{
if (state == 1)
{
if (Key.getCode(37) || Key.getCode(39))
{
if (!Key.isDown(37) && !Key.isDown(39))
{
if (cha.mode != "jump" && cha.mode != "up" && cha.mode != "attack" && cha.mode != "down" && cha.mode != "damage")
{
cha.gotoAndStop("ready");
} // end if
} // end if
} // end if
if (Key.getCode(38) && cha.mode == "up")
{
cha.m.stop();
ladderSound.stop("ladder_up_sound");
delete ladderSound;
} // end if
} // end if
};
Key.addListener(myListen);
stop();
gameInit();

No comments:

Post a Comment