Frame 1
button.onRelease = function () {
gotoAndPlay (3);
};
Frame 2
stop();
Frame 3
function attachMv(nm) {
var _local4 = "uniqueid" + uniqid;
uniqid++;
var _local3 = this.attachMovie(nm, _local4, _root.getNextHighestDepth());
level_specific.push(_local3);
return(_local3);
}
function clearMv() {
var _local1;
_local1 = 0;
while (_local1 < level_specific.length) {
level_specific[_local1].unloadMovie();
_local1++;
}
clear_array(level_specific);
}
function clear_array(a) {
while (a.length > 0) {
a.pop();
}
}
function randRange(min, max) {
var _local1 = Math.floor(Math.random() * ((max - min) + 1)) + min;
return(_local1);
}
function randPoint(maxa, maxb) {
var _local2 = Math.floor(Math.random() * (maxa + 1));
var _local1 = Math.floor(Math.random() * (maxa + 1));
if (!is_obstacle_point(_local2, _local1)) {
return({x:_local2, y:_local1});
}
randPoint(maxa, maxb);
}
function randomMove(min, max) {
var _local1 = randRange(min, max);
var _local2 = randRange(0, 1);
if (_local2 == 0) {
return(_local1);
}
return(_local1 * -1);
}
function add_scorebox(o) {
var _local2 = o.getBounds(this);
scoreboxes.push(new flash.geom.Rectangle(_local2.xMin, _local2.yMin, _local2.xMax - _local2.xMin, _local2.yMax - _local2.yMin));
}
function is_scorebox_point(a, b) {
var _local1;
_local1 = 0;
while (_local1 < scoreboxes.length) {
if (scoreboxes[_local1].contains(a, b)) {
return(true);
}
_local1++;
}
return(false);
}
function is_scorebox(s) {
return(s == "scorebox");
}
function clear_scorebox() {
clear_array(scoreboxes);
}
function init_scorebox() {
var _local2;
for (_local2 in _root) {
if (is_scorebox(_local2)) {
add_scorebox(_root[_local2]);
}
}
}
function add_ladder(o) {
var _local2 = o.getBounds(this);
ladders.push(new flash.geom.Rectangle(_local2.xMin, _local2.yMin, _local2.xMax - _local2.xMin, _local2.yMax - _local2.yMin));
}
function is_ladder_point(a, b) {
var _local1;
_local1 = 0;
while (_local1 < ladders.length) {
if (ladders[_local1].contains(a, b)) {
return(true);
}
_local1++;
}
return(false);
}
function is_num(s) {
if (s == "0") {
return(true);
}
if (s == "1") {
return(true);
}
if (s == "2") {
return(true);
}
if (s == "3") {
return(true);
}
if (s == "4") {
return(true);
}
if (s == "5") {
return(true);
}
if (s == "6") {
return(true);
}
if (s == "7") {
return(true);
}
if (s == "8") {
return(true);
}
if (s == "9") {
return(true);
}
return(false);
}
function is_ladder(s) {
var _local2 = s.substr(0, 6);
var _local1 = s.substr(6, 1);
return((_local2 == "ladder") && (is_num(_local1)));
}
function init_ladders() {
var _local2;
for (_local2 in _root) {
if (is_ladder(_local2)) {
add_ladder(_root[_local2]);
}
}
}
function clear_ladders() {
clear_array(ladders);
}
function add_obstacle(o) {
var _local2 = o.getBounds(this);
obstacles.push(new flash.geom.Rectangle(_local2.xMin, _local2.yMin, _local2.xMax - _local2.xMin, _local2.yMax - _local2.yMin));
}
function is_obstacle_point(a, b) {
var _local1;
_local1 = 0;
while (_local1 < obstacles.length) {
if (obstacles[_local1].contains(a, b)) {
return(true);
}
_local1++;
}
return(false);
}
function is_obstacle(s) {
var _local1 = new String();
_local1 = s.substr(0, 3);
var _local2 = s.substr(3, 1);
return((_local1 == "obs") && (is_num(_local2)));
}
function init_obstacles() {
var _local2;
for (_local2 in _root) {
if (is_obstacle(_local2)) {
add_obstacle(_root[_local2]);
}
}
}
function clear_obstacles() {
clear_array(obstacles);
}
function pstate(s) {
if ((s == "falling") && (p.lastmove != "falling")) {
p.gotoAndPlay(10);
p.lastmove = "falling";
p.lastdate = new Date();
} else if ((s == "ladder") && (p.lastmove != "ladder")) {
p.gotoAndPlay(12);
p.lastmove = "ladder";
p.lastdate = new Date();
} else if ((s == "standing") && (p.lastmove != "standing")) {
p.lastmove = "standing";
p.lastdate = new Date();
p.gotoAndPlay(9);
} else if ((s == "left") && (p.lastmove != "left")) {
p.gotoAndPlay(1);
p.lastmove = "left";
p.lastdate = new Date();
} else if ((s == "right") && (p.lastmove != "right")) {
p.gotoAndPlay(5);
p.lastmove = "right";
p.lastdate = new Date();
}
}
function player_update() {
if (is_ladder_point(p._x, p._y - 10)) {
pstate("ladder");
} else if ((!is_obstacle_point(p._x, p._y + 10)) && (!is_ladder_point(p._x, p._y + 10))) {
pstate("falling");
} else if ((((p.lastmove == "left") || (p.lastmove == "right")) || (p.lastmove == "ladder")) || (p.lastmove == "falling")) {
var _local1 = new Date().getTime() - p.lastdate.getTime();
if (_local1 > 500) {
pstate("standing");
}
}
}
function add_badguy() {
var _local1;
if (bgcount >= 2) {
_local1 = attachMv("badguy_nosound");
} else {
_local1 = attachMv("badguy");
}
bgcount++;
var _local2 = randPoint(1000, 700);
_local1._x = _local2.x;
_local1._y = _local2.y;
_local1.speed = randRange(10, 30);
badguys.push(_local1);
gravityguys.push(_local1);
}
function badguy_update() {
var _local1;
_local1 = 0;
while (_local1 < badguys.length) {
if (badguys[_local1]._y > 1000) {
var _local2 = badguys[_local1];
var _local5 = randPoint(1000, 700);
_local2._x = _local5.x;
_local2._y = _local5.y;
_local2.speed = randRange(10, 30);
rehab = true;
}
var _local3;
if (randRange(0, 1) == 1) {
_local3 = 0;
} else {
_local3 = randRange(0, badguys[_local1].speed);
}
var _local4;
var _local7 = badguys[_local1]._x - p._x;
if (_local7 < 0) {
_local4 = badguys[_local1]._x + _local3;
} else {
_local4 = badguys[_local1]._x - _local3;
}
var _local6 = badguys[_local1]._y;
if (!is_obstacle_point(_local4, _local6)) {
badguys[_local1]._x = _local4;
badguys[_local1]._y = _local6;
}
_local1++;
}
if (upcount == 0) {
if (rehab) {
rehab = false;
} else {
add_badguy();
}
}
upcount = (upcount + 1) % badguy_freq;
}
function score_update() {
if ((score <= 0) || (p._y > 1000)) {
clear_level();
gotoAndPlay (50);
}
if (is_scorebox_point(p._x, p._y)) {
clear_level();
if (level == 1) {
gotoAndPlay (30);
} else {
gotoAndPlay (5);
}
}
var _local1;
_local1 = 0;
while (_local1 < badguys.length) {
var _local3 = badguys[_local1]._x - p._x;
var _local2 = badguys[_local1]._y - p._y;
var _local4 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local4 < collision_threshold) {
score--;
scorebox.lives.text = score;
attachMv("ouch");
pstate("falling");
}
_local1++;
}
}
function ladder_update() {
var _local1;
_local1 = 0;
while (_local1 < gravityguys.length) {
if (is_ladder_point(gravityguys[_local1]._x, gravityguys[_local1]._y)) {
var _local3 = gravityguys[_local1]._x;
var _local2 = gravityguys[_local1]._y - gravityguys[_local1].speed;
gravityguys[_local1]._x = _local3;
gravityguys[_local1]._y = _local2;
if ((p == gravityguys[_local1]) && (is_ladder_point(_local3, _local2))) {
pstate("ladder");
}
}
_local1++;
}
}
function gravity_update() {
var _local1;
_local1 = 0;
while (_local1 < gravityguys.length) {
var _local3 = gravityguys[_local1]._x;
var _local2 = gravityguys[_local1]._y + gravity_weight;
if (!is_ladder_point(gravityguys[_local1]._x, gravityguys[_local1]._y)) {
if ((!is_obstacle_point(_local3, _local2)) && (!is_ladder_point(_local3, _local2))) {
if ((gravityguys[_local1] == p) && (!is_ladder_point(_local3, _local2 + 10))) {
pstate("falling");
}
gravityguys[_local1]._x = _local3;
gravityguys[_local1]._y = _local2;
}
}
_local1++;
}
}
function init_level(l) {
level = l;
level_specific = new Array();
gravityguys = new Array();
badguys = new Array();
obstacles = new Array();
ladders = new Array();
scoreboxes = new Array();
init_obstacles();
init_ladders();
init_scorebox();
p = attachMv("indy");
p.speed = player_speed;
pstate("falling");
gravityguys.push(p);
Key.addListener(keyboard_update);
interv1 = setInterval(badguy_update, 60);
interv2 = setInterval(gravity_update, 10);
interv3 = setInterval(score_update, 50);
interv4 = setInterval(player_update, 300);
interv5 = setInterval(ladder_update, 10);
collision_threshold = 10;
xdelta = 0;
jumpboost = 0;
upcount = 0;
bgcount = 0;
rehab = false;
scorebox.lives.text = score;
}
function clear_level() {
clear_obstacles();
clear_ladders();
clear_scorebox();
Key.removeListener(watchKeyBoard);
clearInterval(interv1);
clearInterval(interv2);
clearInterval(interv3);
clearInterval(interv4);
clearInterval(interv5);
clearMv();
clear_array(gravityguys);
clear_array(badguys);
}
var level = 1;
var badguy_freq;
var score;
var player_speed;
var gravity_weight;
var collision_threshold;
var uniqid = 0;
var jumpboost;
var level_specific;
var gravityguys;
var badguys;
var obstacles;
var ladders;
var scoreboxes;
var xdelta;
var upcount;
var bgcount;
var rehab;
var interv1;
var interv2;
var interv3;
var interv4;
var interv5;
var p;
keyboard_update = new Object();
keyboard_update.onKeyDown = function () {
if (Key.isDown(38)) {
if (is_obstacle_point(p._x, p._y + 10)) {
pstate("ladder");
var _local1 = 149;
while (_local1 > 0) {
if (!is_obstacle_point(p._x + xdelta, (p._y - _local1) - jumpboost)) {
p._y = (p._y - _local1) - jumpboost;
p._x = p._x + xdelta;
break;
}
_local1 = _local1 - 10;
}
xdelta = 0;
jumpboost = jumpboost + 120;
}
} else if (Key.isDown(37)) {
if (!is_obstacle_point(p._x - p.speed, p._y)) {
p._x = p._x - p.speed;
xdelta = -100;
jumpboost = 0;
if (is_obstacle_point(p._x, p._y + 10) || (is_ladder_point(p._x, p._y + 10))) {
pstate("left");
}
}
} else if (Key.isDown(39)) {
if (!is_obstacle_point(p._x + p.speed, p._y)) {
p._x = p._x + p.speed;
xdelta = 100;
jumpboost = 0;
if (is_obstacle_point(p._x, p._y + 10) || (is_ladder_point(p._x, p._y + 10))) {
pstate("right");
}
}
} else if (Key.isDown(40)) {
} else if (Key.isDown(45)) {
} else if (Key.isDown(13)) {
} else if (Key.getAscii() == 100) {
} else if (Key.getAscii() == 117) {
}
};
badguy_freq = 25;
player_speed = 10;
score = 10;
gravity_weight = 5;
init_level(1);
stop();
Frame 4
init_level(2);
stop();
Frame 29
stop();
Frame 49
gotoAndPlay (4);
Frame 74
stop();
Symbol 19 MovieClip [indy] Frame 4
gotoAndPlay (1);
Symbol 19 MovieClip [indy] Frame 7
gotoAndPlay (5);
Symbol 19 MovieClip [indy] Frame 9
gotoAndPlay (8);
Symbol 19 MovieClip [indy] Frame 11
gotoAndPlay (10);
Symbol 19 MovieClip [indy] Frame 16
gotoAndPlay (12);
Symbol 31 MovieClip [ouch] Frame 10
stop();
Symbol 35 MovieClip [score] Frame 1
stop();