Frame 1
function bearing(a, b) {
var _local3 = b.x - a.x;
var _local2 = b.y - a.y;
var _local1 = Math.atan2(_local2, _local3);
_local1 = _local1 * 57.2957795130823;
_local1 = _local1 + 90;
return(_local1);
}
var frame_rate = 24;
var depth = 0;
var world_gravity = (new flash.geom.Point(0, 500));
var gmad_target = (new flash.geom.Point(0, 0));
var gmad_release = (new flash.geom.Point(0, 0));
var gmad_min_drag = 25;
var orb_speed = 400;
var ammo = 0;
var orb_trail = [];
var orb_trail_distance = 10;
var orb_trail_movement_factor = 0.2;
var firing = false;
var selected_anomaly = null;
var anomaly_radius = 100;
var anomaly_removed = false;
var levels = ["mc_level_1_1", "mc_level_1_2", "mc_level_1_3", "mc_level_1_4", "mc_level_1_5", "mc_level_1_6", "mc_level_1_7", "mc_level_1_8", "mc_level_1_9", "mc_level_1_10"];
var avatar = null;
var active_level = null;
var game_is_paused = true;
var r_already_triggered = false;
var is_prepared = false;
this.onEnterFrame = function () {
if (this.is_prepared == false) {
background_mc.set_random_colour();
Mouse.hide();
this.attachMovie("mc_cursor", "cursor_mc", 100000002);
this.attachMovie("mc_gravity_target", "gravity_target_mc", 100000001);
this.attachMovie("mc_target", "target_mc", 100000000);
this.gravity_target_mc._visible = false;
this.target_mc._visible = false;
Stage.showMenu = false;
this.is_prepared = true;
}
if (active_level) {
if (active_level.is_prepared == false) {
this.prepare_active_level();
}
}
this.update_surface_states();
this.handle_player_input();
if (this.game_is_paused == false) {
this.update_orbs();
avatar.update_gravitation(this.world_gravity, active_level.anomalies);
avatar.update_linear_velocity();
avatar.update_rotational_velocity();
avatar.update_position();
avatar.update_rotation();
this.update_orb_trail();
this.exit_detection();
this.killzone_detection();
avatar.collision_detection(active_level.surfaces);
}
};
this.onMouseDown = function () {
if (this.game_is_paused == false) {
this.firing = true;
this.gmad_target.x = active_level._xmouse;
this.gmad_target.y = active_level._ymouse;
target_mc._x = this._xmouse;
target_mc._y = this._ymouse;
target_mc._visible = true;
gravity_target_mc._x = this._xmouse;
gravity_target_mc._y = this._ymouse;
}
};
this.onMouseUp = function () {
if (this.game_is_paused == false) {
this.firing = false;
target_mc._visible = false;
gravity_target_mc._visible = false;
this.gmad_release.x = active_level._xmouse;
this.gmad_release.y = active_level._ymouse;
this.gmad_fire();
}
};
this.onMouseMove = function () {
this.update_anomaly_selection();
cursor_mc._x = this._xmouse;
cursor_mc._y = this._ymouse;
if (firing) {
var _local2 = new flash.geom.Point(active_level._xmouse, active_level._ymouse);
gravity_target_mc._rotation = bearing(this.gmad_target, _local2);
if (flash.geom.Point.distance(_local2, gmad_target) >= gmad_min_drag) {
gravity_target_mc._visible = true;
} else {
gravity_target_mc._visible = false;
}
}
updateAfterEvent();
};
this.handle_player_input = function () {
if (this.game_is_paused == false) {
if (Key.isDown(27)) {
this.pause_game();
}
if (avatar.is_upright()) {
if (Key.isDown(37) || (Key.isDown(65))) {
avatar.walk_left();
} else {
avatar.is_walking_left = false;
}
if (Key.isDown(39) || (Key.isDown(68))) {
avatar.walk_right();
} else {
avatar.is_walking_right = false;
}
} else {
if (Key.isDown(37) || (Key.isDown(65))) {
avatar.walk_right();
} else {
avatar.is_walking_right = false;
}
if (Key.isDown(39) || (Key.isDown(68))) {
avatar.walk_left();
} else {
avatar.is_walking_left = false;
}
}
if ((((Key.isDown(37) || (Key.isDown(39))) || (Key.isDown(65))) || (Key.isDown(68))) == false) {
avatar.stop_walking();
}
if (Key.isDown(38) || (Key.isDown(87))) {
avatar.jump();
}
if (Key.isDown(32)) {
this.retrieve_anomaly();
} else {
this.anomaly_removed = false;
}
if (Key.isDown(82)) {
if (this.r_already_triggered) {
} else {
this.reload_active_level();
this.r_already_triggered = true;
}
} else {
this.r_already_triggered = false;
}
}
};
this.update_surface_states = function () {
avatar_pos = new flash.geom.Point(avatar._x, avatar._y);
var _local1 = 0;
while (_local1 < active_level.surfaces.length) {
active_level.surfaces[_local1].facing_avatar_in_prev_frame = active_level.surfaces[_local1].is_facing(avatar_pos);
_local1++;
}
};
this.update_orbs = function () {
var _local3 = 0;
while (_local3 < active_level.orbs.length) {
active_level.orbs[_local3]._x = active_level.orbs[_local3]._x + (active_level.orbs[_local3].velocity.x / frame_rate);
active_level.orbs[_local3]._y = active_level.orbs[_local3]._y + (active_level.orbs[_local3].velocity.y / frame_rate);
var _local7 = active_level.orbs[_local3]._x;
var _local6 = active_level.orbs[_local3]._y;
_local7 = _local7 + active_level._x;
_local6 = _local6 + active_level._y;
if ((((_local7 < -50) || (_local7 > (Stage.width + 50))) || (_local6 < -50)) || (_local6 > (Stage.height + 50))) {
active_level.orbs[_local3].removeMovieClip();
active_level.orbs.splice(_local3, 1);
this.increment_orb_trail();
}
var _local4 = 0;
while (_local4 < active_level.surfaces.length) {
if (active_level.surfaces[_local4].hitTest(_local7, _local6, true)) {
var _local2 = active_level.attachMovie("mc_anomaly", ("anomaly" + depth) + "_mc", depth);
depth++;
_local2._x = active_level.orbs[_local3]._x;
_local2._y = active_level.orbs[_local3]._y;
_local2.gravitation = active_level.orbs[_local3].gravitation.clone();
_local2._rotation = (Math.atan2(_local2.gravitation.y, _local2.gravitation.x) * 180) / Math.PI;
_local2._rotation = _local2._rotation + 90;
_local2.radius = this.anomaly_radius;
var _local9 = new mx.transitions.Tween(_local2, "_xscale", mx.transitions.easing.Back.easeOut, 1, 100, 0.5, true);
var _local8 = new mx.transitions.Tween(_local2, "_yscale", mx.transitions.easing.Back.easeOut, 1, 100, 0.5, true);
active_level.anomalies.push(_local2);
var _local5 = new Sound();
_local5.attachSound("snd_anomaly_up");
_local5.start();
active_level.orbs[_local3].removeMovieClip();
active_level.orbs.splice(_local3, 1);
break;
}
_local4++;
}
_local3++;
}
};
this.update_anomaly_selection = function () {
selected_anomaly.gotoAndStop("unselected");
selected_anomaly = null;
var _local4;
var _local2 = 0;
while (_local2 < active_level.anomalies.length) {
var _local6 = new flash.geom.Point(active_level._xmouse, active_level._ymouse);
var _local5 = new flash.geom.Point(active_level.anomalies[_local2]._x, active_level.anomalies[_local2]._y);
var _local3 = flash.geom.Point.distance(_local6, _local5);
if (_local2 == 0) {
_local4 = _local3;
if (_local3 <= this.anomaly_radius) {
selected_anomaly = active_level.anomalies[_local2];
selected_anomaly.gotoAndStop("selected");
}
}
if (_local3 <= this.anomaly_radius) {
if (_local3 < _local4) {
_local4 = _local3;
selected_anomaly.gotoAndStop("unselected");
selected_anomaly = active_level.anomalies[_local2];
selected_anomaly.gotoAndStop("selected");
}
}
_local2++;
}
};
this.gmad_fire = function () {
var _local5 = flash.geom.Point.distance(gmad_target, gmad_release);
if (_local5 > gmad_min_drag) {
if (this.orb_trail.length > 0) {
var _local2 = active_level.attachMovie("mc_orb", ("orb" + depth) + "_mc", depth);
depth++;
var _local3 = avatar.get_centre();
_local2._x = _local3.x;
_local2._y = _local3.y;
_local2.gravitation = gmad_release.subtract(gmad_target);
_local2.gravitation.normalize(world_gravity.length);
_local2.velocity = gmad_target.subtract(_local3);
_local2.velocity.normalize(this.orb_speed);
active_level.orbs.push(_local2);
this.decrement_orb_trail();
var _local4 = new Sound();
_local4.attachSound("snd_fire");
_local4.start();
} else {
var _local4 = new Sound();
_local4.attachSound("snd_no_ammo");
_local4.start();
}
}
};
this.retrieve_anomaly = function () {
if (this.anomaly_removed == false) {
if (selected_anomaly) {
var _local2 = 0;
while (_local2 < active_level.anomalies.length) {
if (selected_anomaly == active_level.anomalies[_local2]) {
active_level.anomalies.splice(_local2, 1);
break;
}
_local2++;
}
this.removed_anomaly = selected_anomaly;
var _local5 = new mx.transitions.Tween(this.removed_anomaly, "_xscale", mx.transitions.easing.Back.easeIn, 100, 0, 0.5, true);
var _local4 = new mx.transitions.Tween(this.removed_anomaly, "_yscale", mx.transitions.easing.Back.easeIn, 100, 0, 0.5, true);
_local4.onMotionFinished = function () {
this.removed_anomaly._visible = false;
this.removed_anomaly.removeMovieClip();
};
selected_anomaly = null;
this.increment_orb_trail();
var _local3 = new Sound();
_local3.attachSound("snd_anomaly_down");
_local3.start();
}
this.anomaly.removed = true;
}
};
this.increment_orb_trail = function () {
var _local2 = active_level.attachMovie("mc_orb", ("orb" + depth) + "_mc", depth);
depth++;
if (this.orb_trail.length == 0) {
_local2._x = avatar._x - orb_trail_distance;
_local2._y = avatar._y;
} else {
var _local3 = this.orb_trail[this.orb_trail.length - 1];
_local2._x = _local3._x - orb_trail_distance;
_local2._y = avatar._y;
}
this.orb_trail.push(_local2);
};
this.decrement_orb_trail = function () {
this.orb_trail[this.orb_trail.length - 1].removeMovieClip();
this.orb_trail.pop();
};
this.update_orb_trail = function () {
var _local3 = 0;
while (_local3 < this.orb_trail.length) {
var _local4 = this.orb_trail[_local3];
var _local6 = new flash.geom.Point(_local4._x, _local4._y);
var _local2 = new flash.geom.Point(0, 0);
if (_local3) {
_local2.x = this.orb_trail[_local3 - 1]._x;
_local2.y = this.orb_trail[_local3 - 1]._y;
} else {
_local2.x = avatar._x;
_local2.y = avatar._y;
}
var _local7 = flash.geom.Point.distance(_local6, _local2);
if (_local7 > orb_trail_distance) {
var _local5 = _local2.subtract(_local6);
_local5.normalize(orb_trail_movement_factor * _local7);
_local4._x = _local4._x + _local5.x;
_local4._y = _local4._y + _local5.y;
}
_local3++;
}
};
this.load_level = function (level) {
this.active_level = this.attachMovie(level, "level_mc", depth);
depth++;
this.active_level._visible = true;
active_level._x = Stage.width / 2;
active_level._y = Stage.height * 1.5;
var _local2 = Stage.height / 2;
var _local4 = new mx.transitions.Tween(active_level, "_y", mx.transitions.easing.Regular.easeInOut, active_level._y, _local2, 1, true);
active_level.is_prepared = false;
background_mc.shift_to_random_colour();
};
this.unload_active_level = function () {
var old_level = active_level;
active_level = null;
avatar = null;
while (this.orb_trail.length > 0) {
this.decrement_orb_trail();
}
var _local3 = Stage.height / -2;
var _local2 = new mx.transitions.Tween(old_level, "_y", mx.transitions.easing.Regular.easeInOut, old_level._y, _local3, 1, true);
_local2.onMotionFinished = function () {
old_level.removeMovieClip();
};
};
this.reload_active_level = function () {
if (this.active_level) {
this.unload_active_level();
this.load_level(levels[active_level_index]);
}
};
this.prepare_active_level = function () {
avatar = active_level.avatar_mc;
if (avatar == false) {
}
var _local2 = 0;
while (_local2 < active_level.anomalies.length) {
var _local3 = (active_level.anomalies[_local2]._rotation * Math.PI) / 180;
active_level.anomalies[_local2].gravitation = new flash.geom.Point(Math.sin(_local3), Math.cos(_local3) * -1);
active_level.anomalies[_local2].gravitation.normalize(world_gravity.length);
active_level.anomalies[_local2].radius = this.anomaly_radius;
_local2++;
}
while (this.orb_trail.length < active_level.starting_ammo) {
this.increment_orb_trail();
}
active_level.is_prepared = true;
};
this.start_game = function () {
this.load_level(levels[0]);
this.active_level_index = 0;
this.game_is_paused = false;
};
this.pause_game = function () {
this.game_is_paused = true;
active_level._visible = false;
main_menu_mc.open_paused();
};
this.unpause_game = function () {
this.game_is_paused = false;
active_level._visible = true;
};
this.exit_detection = function () {
var _local2 = avatar.get_centre();
_local2.x = _local2.x + active_level._x;
_local2.y = _local2.y + active_level._y;
if (active_level.exit_mc.hitTest(_local2.x, _local2.y, true)) {
if ((active_level_index + 1) < levels.length) {
this.unload_active_level();
this.load_level(levels[++active_level_index]);
} else {
unload_active_level();
this.game_is_paused = true;
main_menu_mc.open();
}
}
};
this.killzone_detection = function () {
var _local4 = avatar.get_centre();
_local4.x = _local4.x + active_level._x;
_local4.y = _local4.y + active_level._y;
var _local2 = 0;
while (_local2 < active_level.killzones.length) {
if (active_level.killzones[_local2].hitTest(_local4.x, _local4.y, true)) {
var _local3 = new Sound();
_local3.attachSound("snd_squish");
_local3.start();
this.reload_active_level();
}
_local2++;
}
var _local5 = Stage.width / 2;
if (Math.abs(avatar._x) > _local5) {
this.reload_active_level();
}
var _local6 = Stage.height / 2;
if (avatar._y > _local6) {
this.reload_active_level();
}
};
Symbol 15 MovieClip Frame 1
this._visible = false;
Symbol 126 MovieClip Frame 22
this._parent.set_graphic(_parent.avatar_fall_mc);
Symbol 176 MovieClip Frame 1
var frame_rate = _parent._parent.frame_rate;
var original_height = 50;
var gravitation = (new flash.geom.Point(0, 0));
var target_rotation = 0;
var linear_velocity = (new flash.geom.Point(0, 0));
var jump_velocity = 250;
var max_walk_velocity = 160;
var collision_death_speed = 600;
var walk_acceleration = 1200;
var air_walk_acceleration = 120;
var max_walk_inclination = 45;
var rotational_velocity = 360;
var is_airborne = true;
var contact_surface = null;
var is_walking_left = false;
var is_walking_right = false;
var surface_buffer = 0.5;
this.avatar_idle_mc._visible = true;
this.avatar_jump_mc._visible = false;
this.avatar_walk_mc._visible = false;
this.avatar_fall_mc._visible = false;
update_gravitation = function (world_gravity, anomalies) {
this.gravitation.x = 0;
this.gravitation.y = 0;
var _local7 = false;
var _local2 = 0;
while (_local2 < anomalies.length) {
var _local5 = this.get_centre();
var _local6 = new flash.geom.Point(anomalies[_local2]._x, anomalies[_local2]._y);
var _local4 = flash.geom.Point.distance(_local5, _local6);
if (_local4 <= anomalies[_local2].radius) {
this.gravitation.offset(anomalies[_local2].gravitation.x, anomalies[_local2].gravitation.y);
_local7 = true;
}
_local2++;
}
if (_local7 == false) {
this.gravitation = world_gravity.clone();
}
if (_local7) {
var _local11 = new flash.filters.BlurFilter(4, 4, 3);
this.filters = [_local11];
} else {
this.filters = [];
}
this.target_rotation = (Math.atan2(this.gravitation.y, this.gravitation.x) * 180) / Math.PI;
this.target_rotation = this.target_rotation - 90;
if (this.target_rotation < -180) {
this.target_rotation = this.target_rotation + 360;
}
if (this.is_airborne == false) {
var _local8 = this.get_up();
var _local9 = contact_surface.normal();
var _local12 = (_local8.x * _local9.x) + (_local8.y * _local9.y);
var _local10 = Math.acos(_local12 / (_local8.length * _local9.length));
_local10 = _local10 * 57.2957795130823;
if (_local10 > (90 - max_walk_inclination)) {
this.is_airborne = true;
this.contact_surface = null;
}
}
};
update_linear_velocity = function () {
if (this.is_airborne) {
this.linear_velocity.offset(this.gravitation.x / frame_rate, this.gravitation.y / frame_rate);
}
};
update_rotational_velocity = function () {
if (this.is_airborne) {
}
};
update_position = function () {
this._x = this._x + (this.linear_velocity.x / frame_rate);
this._y = this._y + (this.linear_velocity.y / frame_rate);
if ((this.is_airborne == false) && (this.linear_velocity.length > 0)) {
this.align_to_surface(contact_surface);
}
};
update_rotation = function () {
if (this.is_airborne) {
if (Math.abs(this.target_rotation - this._rotation) < (rotational_velocity / frame_rate)) {
this.set_rotation_about_centre(this.target_rotation);
} else {
theta = this.target_rotation - this._rotation;
if (((theta > 0) && (theta < 180)) || (theta < -180)) {
this.rotate_about_centre(rotational_velocity / frame_rate);
} else {
this.rotate_about_centre((-rotational_velocity) / frame_rate);
}
}
}
};
collision_detection = function (surfaces) {
if (this.is_airborne) {
var _local2 = 0;
while (_local2 < surfaces.length) {
this.airborne_collision_with_surface(surfaces[_local2]);
_local2++;
}
} else {
var _local2 = 0;
while (_local2 < surfaces.length) {
if (surfaces[_local2] == this.contact_surface) {
} else {
this.grounded_collision_with_surface(surfaces[_local2]);
}
_local2++;
}
if (this.is_over_surface(this.contact_surface) == false) {
this.is_airborne = true;
this.contact_surface = null;
}
}
};
airborne_collision_with_surface = function (surface) {
if (this.is_over_surface(surface)) {
var _local9 = new flash.geom.Point(this._x, this._y);
var _local4 = this.get_target_rotation_mapping_matrix();
var _local12 = _local4.transformPoint(_local9);
var _local5 = _local4.transformPoint(surface.left_endpoint());
var _local8 = _local4.transformPoint(surface.right_endpoint());
var _local14 = Math.abs(_local5.x - _local12.x) / Math.abs(_local5.x - _local8.x);
var _local15 = flash.geom.Point.interpolate(_local8, _local5, _local14);
if ((surface.is_facing(_local9) == false) && (surface.facing_avatar_in_prev_frame)) {
if (this.linear_velocity.length > this.collision_death_speed) {
var _local11 = new Sound();
_local11.attachSound("snd_squish");
_local11.start();
_parent._parent.reload_active_level();
return(undefined);
}
this.align_to_surface(surface);
var _local6 = this.get_up();
var _local7 = surface.normal();
var _local13 = (_local6.x * _local7.x) + (_local6.y * _local7.y);
var _local10 = Math.acos(_local13 / (_local6.length * _local7.length));
_local10 = _local10 * 57.2957795130823;
if (_local10 <= (90 - max_walk_inclination)) {
this.land_on_surface(surface);
} else {
this.deflect_from_surface(surface);
}
}
}
};
grounded_collision_with_surface = function (surface) {
if (this.is_over_surface(surface)) {
avatar_pos = new flash.geom.Point(this._x, this._y);
rot_matrix = this.get_target_rotation_mapping_matrix();
rot_avatar_pos = rot_matrix.transformPoint(avatar_pos);
rot_left_endpoint = rot_matrix.transformPoint(surface.left_endpoint());
rot_right_endpoint = rot_matrix.transformPoint(surface.right_endpoint());
f = Math.abs(rot_left_endpoint.x - rot_avatar_pos.x) / Math.abs(rot_left_endpoint.x - rot_right_endpoint.x);
intersect = flash.geom.Point.interpolate(rot_right_endpoint, rot_left_endpoint, f);
if ((surface.is_facing(avatar_pos) == false) && (surface.facing_avatar_in_prev_frame)) {
up = this.get_up();
normal = surface.normal();
dp = (up.x * normal.x) + (up.y * normal.y);
normal_angle_from_vertical = Math.acos(dp / (up.length * normal.length));
normal_angle_from_vertical = normal_angle_from_vertical * 57.2957795130823;
if (normal_angle_from_vertical <= (90 - max_walk_inclination)) {
this.align_to_surface(surface);
this.land_on_surface(surface);
} else {
this.deflect_from_surface(surface);
}
}
}
};
land_on_surface = function (surface) {
this.is_airborne = false;
this.contact_surface = surface;
this._rotation = surface._rotation;
this.apply_surface_buffer(surface);
surface_left = this.contact_surface.left_vector();
surface_right = this.contact_surface.right_vector();
if (((linear_velocity.x * surface_left.x) + (linear_velocity.y * surface_left.y)) > 0) {
dp = (linear_velocity.x * surface_left.x) + (linear_velocity.y * surface_left.y);
momentum = dp / surface_left.length;
surface_left.normalize(momentum);
this.linear_velocity.x = surface_left.x;
this.linear_velocity.y = surface_left.y;
} else {
dp = (linear_velocity.x * surface_right.x) + (linear_velocity.y * surface_right.y);
momentum = dp / surface_right.length;
surface_right.normalize(momentum);
this.linear_velocity.x = surface_right.x;
this.linear_velocity.y = surface_right.y;
}
this.set_graphic(this.avatar_idle_mc);
};
deflect_from_surface = function (surface) {
if (this.is_airborne) {
surface_left = surface.left_vector();
surface_right = surface.right_vector();
if (((linear_velocity.x * surface_left.x) + (linear_velocity.y * surface_left.y)) > 0) {
dp = (linear_velocity.x * surface_left.x) + (linear_velocity.y * surface_left.y);
momentum = dp / surface_left.length;
surface_left.normalize(momentum);
this.linear_velocity.x = surface_left.x;
this.linear_velocity.y = surface_left.y;
} else {
dp = (linear_velocity.x * surface_right.x) + (linear_velocity.y * surface_right.y);
momentum = dp / surface_right.length;
surface_right.normalize(momentum);
this.linear_velocity.x = surface_right.x;
this.linear_velocity.y = surface_right.y;
}
this.apply_surface_buffer(surface);
} else {
rot_matrix = new flash.geom.Matrix();
rot_matrix.rotate((((contact_surface._rotation + 90) * -1) * Math.PI) / 180);
avatar_pos = new flash.geom.Point(this._x, this._y);
rot_avatar_pos = rot_matrix.transformPoint(avatar_pos);
rot_left_endpoint = rot_matrix.transformPoint(surface.left_endpoint());
rot_right_endpoint = rot_matrix.transformPoint(surface.right_endpoint());
f = Math.abs(rot_left_endpoint.x - rot_avatar_pos.x) / Math.abs(rot_left_endpoint.x - rot_right_endpoint.x);
intersect = flash.geom.Point.interpolate(rot_right_endpoint, rot_left_endpoint, f);
overlap = Math.abs(rot_avatar_pos.y - intersect.y);
correction = new flash.geom.Point(linear_velocity.x * -1, linear_velocity.y * -1);
correction.normalize(overlap + surface_buffer);
this._x = this._x + correction.x;
this._y = this._y + correction.y;
this.linear_velocity.x = 0;
this.linear_velocity.y = 0;
}
};
align_to_surface = function (surface) {
left_endpoint = surface.left_endpoint();
right_endpoint = surface.right_endpoint();
avatar_pos = new flash.geom.Point(this._x, this._y);
contact_pos = new flash.geom.Point(0, 0);
dist_to_left = flash.geom.Point.distance(avatar_pos, left_endpoint);
dist_to_right = flash.geom.Point.distance(avatar_pos, right_endpoint);
surface_length = flash.geom.Point.distance(left_endpoint, right_endpoint);
if (dist_to_left < dist_to_right) {
f = dist_to_right / surface_length;
contact_pos = flash.geom.Point.interpolate(left_endpoint, right_endpoint, f);
} else {
f = dist_to_left / surface_length;
contact_pos = flash.geom.Point.interpolate(right_endpoint, left_endpoint, f);
}
this._x = contact_pos.x;
this._y = contact_pos.y;
};
apply_surface_buffer = function (surface) {
var _local2 = surface.normal();
_local2.normalize(this.surface_buffer);
this._x = this._x + _local2.x;
this._y = this._y + _local2.y;
};
get_up = function () {
up = new flash.geom.Point(this.gravitation.x * -1, this.gravitation.y * -1);
return(up);
};
is_upright = function () {
if (contact_surface) {
return(contact_surface.normal().y < 0);
}
return(this.gravitation.y > 0);
};
get_left = function () {
left = new flash.geom.Point(this.gravitation.y * -1, this.gravitation.x);
return(left);
};
get_right = function () {
right = new flash.geom.Point(this.gravitation.y, this.gravitation.x * -1);
return(right);
};
is_over_surface = function (surface) {
var _local5 = new flash.geom.Point(this._x, this._y);
var _local8 = new flash.geom.Point(surface._x, surface._y);
var _local2 = surface.get_rotation_mapping_matrix();
var _local6 = _local2.transformPoint(_local5);
var _local9 = _local2.transformPoint(_local8);
var _local4 = Math.abs(_local6.x - _local9.x);
var _local7 = surface._xscale;
return(_local4 <= (_local7 / 2));
};
is_touching_surface = function (surface) {
avatar_pos = new flash.geom.Point(this._x, this._y);
surface_pos = new flash.geom.Point(surface._x, surface._y);
rot_matrix = this.get_target_rotation_mapping_matrix();
rot_avatar_pos = rot_matrix.transformPoint(avatar_pos);
rot_surface_pos = rot_matrix.transformPoint(surface_pos);
rot_left_endpoint = rot_matrix.transformPoint(surface.left_endpoint());
rot_right_endpoint = rot_matrix.transformPoint(surface.right_endpoint());
feet_y = rot_avatar_pos.y + (this.original_height / 2);
f = Math.abs(rot_left_endpoint.x - rot_avatar_pos.x) / Math.abs(rot_left_endpoint.x - rot_right_endpoint.x);
intersect = flash.geom.Point.interpolate(rot_right_endpoint, rot_left_endpoint, f);
return((feet_y >= intersect.y) && (rot_avatar_pos.y < intersect.y));
};
get_target_rotation_mapping_matrix = function () {
var _local2 = new flash.geom.Matrix();
_local2.rotate(((this.target_rotation * -1) * Math.PI) / 180);
return(_local2);
};
get_centre = function () {
var _local2 = new flash.geom.Point(0, this.original_height / -2);
r = new flash.geom.Matrix();
r.rotate((this._rotation * Math.PI) / 180);
_local2 = r.transformPoint(_local2);
_local2.offset(this._x, this._y);
return(_local2);
};
rotate_about_centre = function (delta_angle) {
prev_centre = this.get_centre();
this._rotation = this._rotation + delta_angle;
correction = prev_centre.subtract(this.get_centre());
this._x = this._x + correction.x;
this._y = this._y + correction.y;
};
set_rotation_about_centre = function (angle) {
prev_centre = this.get_centre();
this._rotation = angle;
correction = prev_centre.subtract(this.get_centre());
this._x = this._x + correction.x;
this._y = this._y + correction.y;
};
walk_left = function () {
if (this.is_walking_right == false) {
this.is_walking_left = true;
if (this.is_airborne) {
left = this.get_left();
left.normalize(this.air_walk_acceleration / frame_rate);
this.linear_velocity.offset(left.x, left.y);
} else {
left = contact_surface.left_vector();
left.normalize(this.walk_acceleration / frame_rate);
this.linear_velocity.offset(left.x, left.y);
if (this.linear_velocity.length > max_walk_velocity) {
this.linear_velocity.normalize(max_walk_velocity);
}
this.set_graphic(this.avatar_walk_mc);
}
this._xscale = -100;
}
};
walk_right = function () {
if (this.is_walking_left == false) {
this.is_walking_right = true;
if (this.is_airborne) {
right = this.get_right();
right.normalize(this.air_walk_acceleration / frame_rate);
this.linear_velocity.offset(right.x, right.y);
} else {
right = contact_surface.right_vector();
right.normalize(this.walk_acceleration / frame_rate);
this.linear_velocity.offset(right.x, right.y);
if (this.linear_velocity.length > max_walk_velocity) {
this.linear_velocity.normalize(max_walk_velocity);
}
this.set_graphic(this.avatar_walk_mc);
}
this._xscale = 100;
}
};
stop_walking = function () {
if (this.is_airborne == false) {
deceleration = walk_acceleration / frame_rate;
if (this.linear_velocity.length < deceleration) {
this.linear_velocity.x = 0;
this.linear_velocity.y = 0;
} else {
this.linear_velocity.normalize(this.linear_velocity.length - deceleration);
}
this.set_graphic(this.avatar_idle_mc);
}
};
jump = function () {
if (this.is_airborne == false) {
if (this.linear_velocity.y > 0) {
this.linear_velocity.y = 0;
}
u = this.get_up();
u.normalize(jump_velocity);
this.linear_velocity.offset(u.x, u.y);
this.is_airborne = true;
this.contact_surface = null;
this.set_graphic(this.avatar_jump_mc);
}
};
set_graphic = function (graphic) {
if (graphic._visible == false) {
graphic.gotoAndPlay(1);
}
this.avatar_idle_mc._visible = false;
this.avatar_jump_mc._visible = false;
this.avatar_walk_mc._visible = false;
this.avatar_fall_mc._visible = false;
graphic._visible = true;
};
Symbol 180 MovieClip Frame 1
this.surface_graphic_mc.gotoAndStop("game");
facing_avatar_in_prev_frame = false;
normal = function () {
n = new flash.geom.Point(0, -1);
r = new flash.geom.Matrix();
r.rotate((this._rotation * Math.PI) / 180);
n = r.transformPoint(n);
return(n);
};
is_facing = function (point) {
n = this.normal();
offset = point.clone();
offset.x = offset.x - this._x;
offset.y = offset.y - this._y;
return(((n.x * offset.x) + (n.y * offset.y)) > 0);
};
is_facing_up = function (up) {
n = this.normal();
return(((n.x * up.x) + (n.y * up.y)) > 0);
};
left_vector = function () {
p = new flash.geom.Point(this._xscale / -2, 0);
r = new flash.geom.Matrix();
r.rotate((this._rotation * Math.PI) / 180);
p = r.transformPoint(p);
return(p);
};
right_vector = function () {
p = new flash.geom.Point(this._xscale / 2, 0);
r = new flash.geom.Matrix();
r.rotate((this._rotation * Math.PI) / 180);
p = r.transformPoint(p);
return(p);
};
left_endpoint = function () {
p = this.left_vector();
p.offset(this._x, this._y);
return(p);
};
right_endpoint = function () {
p = this.right_vector();
p.offset(this._x, this._y);
return(p);
};
get_rotation_mapping_matrix = function () {
var _local2 = new flash.geom.Matrix();
_local2.rotate(((this._rotation * -1) * Math.PI) / 180);
return(_local2);
};
Symbol 181 MovieClip [mc_level_1_9] Frame 1
var surfaces = [this.surface1_mc, this.surface2_mc, this.surface3_mc, this.surface4_mc, this.surface5_mc];
var killzones = [];
var anomalies = [];
var orbs = [];
var starting_ammo = 2;
Symbol 189 MovieClip [mc_anomaly] Frame 1
stop();
Symbol 193 MovieClip [mc_level_1_1] Frame 1
var surfaces = [this.surface1_mc, this.surface2_mc, this.surface3_mc, this.surface4_mc];
var killzones = [];
var anomalies = [pre_anomaly_mc];
var orbs = [];
var starting_ammo = 0;
Symbol 198 MovieClip [mc_level_1_2] Frame 1
var surfaces = [this.surface1_mc, this.surface2_mc, this.surface3_mc, this.surface4_mc, this.surface5_mc, this.surface6_mc];
var killzones = [];
var anomalies = [];
var orbs = [];
var starting_ammo = 1;
Symbol 205 MovieClip Frame 1
this._visible = false;
Symbol 206 MovieClip [mc_level_1_7] Frame 1
var surfaces = [this.surface1_mc, this.surface2_mc, this.surface3_mc, this.surface4_mc];
var killzones = [this.killzone1_mc, this.killzone2_mc, this.killzone3_mc, this.killzone4_mc];
var anomalies = [];
var orbs = [];
var starting_ammo = 1;
Symbol 212 MovieClip [mc_level_1_6] Frame 1
var surfaces = [this.surface1_mc, this.surface2_mc, this.surface3_mc, this.surface4_mc, this.surface5_mc, this.surface6_mc, this.surface7_mc, this.surface8_mc, this.surface9_mc];
var killzones = [this.killzone1_mc];
var anomalies = [];
var orbs = [];
var starting_ammo = 1;
Symbol 214 MovieClip [mc_level_1_5] Frame 1
var surfaces = [this.surface1_mc, this.surface2_mc, this.surface3_mc, this.surface4_mc, this.surface5_mc, this.surface6_mc, this.surface7_mc, this.surface8_mc];
var killzones = [];
var anomalies = [];
var orbs = [];
var starting_ammo = 1;
Symbol 216 MovieClip [mc_level_1_10] Frame 1
var surfaces = [this.surface1_mc, this.surface2_mc, this.surface3_mc, this.surface4_mc, this.surface5_mc, this.surface6_mc];
var killzones = [this.killzone1_mc];
var anomalies = [];
var orbs = [];
var starting_ammo = 2;
Symbol 217 MovieClip [mc_level_1_8] Frame 1
var surfaces = [this.surface1_mc, this.surface2_mc, this.surface3_mc, this.surface4_mc, this.surface5_mc, this.surface6_mc];
var killzones = [];
var anomalies = [this.pre_anomaly_mc];
var orbs = [];
var starting_ammo = 1;
Symbol 219 MovieClip [mc_level_1_3] Frame 1
var surfaces = [this.surface1_mc, this.surface2_mc, this.surface3_mc, this.surface4_mc, this.surface5_mc, this.surface6_mc, this.surface7_mc, this.surface8_mc];
var killzones = [this.killzone1_mc];
var anomalies = [];
var orbs = [];
var starting_ammo = 1;
Symbol 221 MovieClip [mc_level_1_4] Frame 1
var surfaces = [this.surface1_mc, this.surface2_mc, this.surface3_mc, this.surface4_mc, this.surface5_mc, this.surface6_mc, this.surface7_mc, this.surface8_mc];
var killzones = [this.killzone1_mc];
var anomalies = [];
var orbs = [];
var starting_ammo = 1;
Symbol 227 MovieClip [mc_flake] Frame 1
var frame_rate = _root.frame_rate;
var gravitation = (new flash.geom.Point(0, 0));
var linear_velocity = (new flash.geom.Point(0, 0));
var max_velocity = 25;
update_gravitation = function (world_gravity, anomalies) {
this.gravitation.x = 0;
this.gravitation.y = 0;
var _local8 = false;
var _local3 = 0;
while (_local3 < anomalies.length) {
var _local7 = new flash.geom.Point(this._x, this._y);
var _local5 = new flash.geom.Point(anomalies[_local3]._x, anomalies[_local3]._y);
_local5.offset(Stage.width / 2, Stage.height / 2);
var _local6 = flash.geom.Point.distance(_local7, _local5);
if (_local6 <= _root.anomaly_radius) {
this.gravitation.offset(anomalies[_local3].gravitation.x, anomalies[_local3].gravitation.y);
_local8 = true;
}
_local3++;
}
if (_local8 == false) {
this.gravitation = world_gravity.clone();
}
};
update_linear_velocity = function () {
this.linear_velocity.offset(this.gravitation.x / frame_rate, this.gravitation.y / frame_rate);
if (this.linear_velocity.length > this.max_velocity) {
this.linear_velocity.normalize(this.max_velocity);
}
};
update_position = function () {
this._y = this._y + (this.max_velocity / frame_rate);
};
Symbol 233 MovieClip Frame 1
var flakes = [];
var max_flakes = 30;
var depth = 0;
var original_width = this._width;
var original_height = this._height;
var colour_shift_duration = 1;
this.onEnterFrame = function () {
this.update_flakes();
};
this.update_flakes = function () {
this.create_flakes();
if (_parent.active_level.is_prepared || (_parent.active_level == null)) {
var _local3 = this.flakes.length - 1;
while (_local3 >= 0) {
flakes[_local3].update_position();
if (flakes[_local3]._y > this.original_height) {
flakes[_local3].removeMovieClip();
flakes.splice(_local3, 1);
}
_local3--;
}
}
};
this.create_flakes = function () {
var _local4 = false;
if (flakes.length == 0) {
_local4 = true;
}
var _local5 = this.max_flakes - this.flakes.length;
var _local3 = 0;
while (_local3 < _local5) {
var _local2 = this.attachMovie("mc_flake", ("flake" + this.depth) + "_mc", this.depth);
this.depth++;
_local2._y = 0;
_local2._x = Math.random() * this.original_width;
if (_local4) {
_local2._y = Math.random() * this.original_height;
} else {
_local2._y = 0;
}
new_flake_mc.blendMode = "screen";
this.flakes.push(_local2);
_local3++;
}
};
this.update_colour = function () {
var _local3 = [1, 0, 0, 0, this.red, 0, 1, 0, 0, this.green, 0, 0, 1, 0, this.blue, 0, 0, 0, 1, 0];
var _local2 = new flash.filters.ColorMatrixFilter(_local3);
this.filters = [_local2];
};
this.set_random_colour = function () {
this.red = (Math.random() * 96) - 64;
this.green = (Math.random() * 96) - 64;
this.blue = (Math.random() * 96) - 64;
this.update_colour();
};
this.shift_to_random_colour = function () {
var _local3 = (Math.random() * 96) - 64;
var _local5 = (Math.random() * 96) - 64;
var _local4 = (Math.random() * 96) - 64;
var _local8 = new mx.transitions.Tween(this, "red", mx.transitions.easing.Regular.easeInOut, this.red, _local3, colour_shift_duration, true);
var _local7 = new mx.transitions.Tween(this, "green", mx.transitions.easing.Regular.easeInOut, this.green, _local5, colour_shift_duration, true);
var _local6 = new mx.transitions.Tween(this, "blue", mx.transitions.easing.Regular.easeInOut, this.blue, _local4, colour_shift_duration, true);
_local6.onMotionChanged = function () {
_parent.background_mc.update_colour();
};
};
Symbol 243 MovieClip Frame 1
stop();
Symbol 246 MovieClip Frame 1
function open() {
play_button_mc.gotoAndStop("play");
this._visible = true;
}
function open_paused() {
play_button_mc.gotoAndStop("return");
this._visible = true;
}
function close() {
this._visible = false;
}
play_button_mc.onRelease = function () {
if (this._parent._parent.active_level) {
this._parent._parent.unpause_game();
} else {
this._parent._parent.start_game();
}
this._parent.close();
};
Symbol 247 MovieClip [__Packages.mx.transitions.OnEnterFrameBeacon] Frame 0
class mx.transitions.OnEnterFrameBeacon
{
function OnEnterFrameBeacon () {
}
static function init() {
var _local4 = _global.MovieClip;
if (!_root.__OnEnterFrameBeacon) {
mx.transitions.BroadcasterMX.initialize(_local4);
var _local3 = _root.createEmptyMovieClip("__OnEnterFrameBeacon", 9876);
_local3.onEnterFrame = function () {
_global.MovieClip.broadcastMessage("onEnterFrame");
};
}
}
static var version = "1.1.0.52";
}
Symbol 248 MovieClip [__Packages.mx.transitions.BroadcasterMX] Frame 0
class mx.transitions.BroadcasterMX
{
var _listeners;
function BroadcasterMX () {
}
static function initialize(o, dontCreateArray) {
if (o.broadcastMessage != undefined) {
delete o.broadcastMessage;
}
o.addListener = mx.transitions.BroadcasterMX.prototype.addListener;
o.removeListener = mx.transitions.BroadcasterMX.prototype.removeListener;
if (!dontCreateArray) {
o._listeners = new Array();
}
}
function addListener(o) {
removeListener(o);
if (broadcastMessage == undefined) {
broadcastMessage = mx.transitions.BroadcasterMX.prototype.broadcastMessage;
}
return(_listeners.push(o));
}
function removeListener(o) {
var _local2 = _listeners;
var _local3 = _local2.length;
while (_local3--) {
if (_local2[_local3] == o) {
_local2.splice(_local3, 1);
if (!_local2.length) {
broadcastMessage = undefined;
}
return(true);
}
}
return(false);
}
function broadcastMessage() {
var _local5 = String(arguments.shift());
var _local4 = _listeners.concat();
var _local6 = _local4.length;
var _local3 = 0;
while (_local3 < _local6) {
_local4[_local3][_local5].apply(_local4[_local3], arguments);
_local3++;
}
}
static var version = "1.1.0.52";
}
Symbol 249 MovieClip [__Packages.mx.transitions.Tween] Frame 0
class mx.transitions.Tween
{
var obj, prop, begin, useSeconds, _listeners, addListener, prevTime, _time, looping, _duration, broadcastMessage, isPlaying, _fps, prevPos, _pos, change, _intervalID, _startTime;
function Tween (obj, prop, func, begin, finish, duration, useSeconds) {
mx.transitions.OnEnterFrameBeacon.init();
if (!arguments.length) {
return;
}
this.obj = obj;
this.prop = prop;
this.begin = begin;
position = (begin);
this.duration = (duration);
this.useSeconds = useSeconds;
if (func) {
this.func = func;
}
this.finish = (finish);
_listeners = [];
addListener(this);
start();
}
function set time(t) {
prevTime = _time;
if (t > duration) {
if (looping) {
rewind(t - _duration);
update();
broadcastMessage("onMotionLooped", this);
} else {
if (useSeconds) {
_time = _duration;
update();
}
stop();
broadcastMessage("onMotionFinished", this);
}
} else if (t < 0) {
rewind();
update();
} else {
_time = t;
update();
}
//return(time);
}
function get time() {
return(_time);
}
function set duration(d) {
_duration = (((d == null) || (d <= 0)) ? (_global.Infinity) : (d));
//return(duration);
}
function get duration() {
return(_duration);
}
function set FPS(fps) {
var _local2 = isPlaying;
stopEnterFrame();
_fps = fps;
if (_local2) {
startEnterFrame();
}
//return(FPS);
}
function get FPS() {
return(_fps);
}
function set position(p) {
setPosition(p);
//return(position);
}
function setPosition(p) {
prevPos = _pos;
obj[prop] = (_pos = p);
broadcastMessage("onMotionChanged", this, _pos);
updateAfterEvent();
}
function get position() {
return(getPosition());
}
function getPosition(t) {
if (t == undefined) {
t = _time;
}
return(func(t, begin, change, _duration));
}
function set finish(f) {
change = f - begin;
//return(finish);
}
function get finish() {
return(begin + change);
}
function continueTo(finish, duration) {
begin = position;
this.finish = (finish);
if (duration != undefined) {
this.duration = (duration);
}
start();
}
function yoyo() {
continueTo(begin, time);
}
function startEnterFrame() {
if (_fps == undefined) {
_global.MovieClip.addListener(this);
} else {
_intervalID = setInterval(this, "onEnterFrame", 1000 / _fps);
}
isPlaying = true;
}
function stopEnterFrame() {
if (_fps == undefined) {
_global.MovieClip.removeListener(this);
} else {
clearInterval(_intervalID);
}
isPlaying = false;
}
function start() {
rewind();
startEnterFrame();
broadcastMessage("onMotionStarted", this);
}
function stop() {
stopEnterFrame();
broadcastMessage("onMotionStopped", this);
}
function resume() {
fixTime();
startEnterFrame();
broadcastMessage("onMotionResumed", this);
}
function rewind(t) {
_time = ((t == undefined) ? 0 : (t));
fixTime();
update();
}
function fforward() {
time = (_duration);
fixTime();
}
function nextFrame() {
if (useSeconds) {
time = ((getTimer() - _startTime) / 1000);
} else {
time = (_time + 1);
}
}
function onEnterFrame() {
nextFrame();
}
function prevFrame() {
if (!useSeconds) {
time = (_time - 1);
}
}
function toString() {
return("[Tween]");
}
function fixTime() {
if (useSeconds) {
_startTime = getTimer() - (_time * 1000);
}
}
function update() {
position = (getPosition(_time));
}
static var version = "1.1.0.52";
static var __initBeacon = mx.transitions.OnEnterFrameBeacon.init();
static var __initBroadcaster = mx.transitions.BroadcasterMX.initialize(mx.transitions.Tween.prototype, true);
function func(t, b, c, d) {
return(((c * t) / d) + b);
}
}
Symbol 250 MovieClip [__Packages.mx.transitions.easing.Back] Frame 0
class mx.transitions.easing.Back
{
function Back () {
}
static function easeIn(t, b, c, d, s) {
if (s == undefined) {
s = 1.70158;
}
t = t / d;
return((((c * t) * t) * (((s + 1) * t) - s)) + b);
}
static function easeOut(t, b, c, d, s) {
if (s == undefined) {
s = 1.70158;
}
t = (t / d) - 1;
return((c * (((t * t) * (((s + 1) * t) + s)) + 1)) + b);
}
static function easeInOut(t, b, c, d, s) {
if (s == undefined) {
s = 1.70158;
}
t = t / (d / 2);
if (t < 1) {
s = s * 1.525;
return(((c / 2) * ((t * t) * (((s + 1) * t) - s))) + b);
}
t = t - 2;
s = s * 1.525;
return(((c / 2) * (((t * t) * (((s + 1) * t) + s)) + 2)) + b);
}
static var version = "1.1.0.52";
}
Symbol 251 MovieClip [__Packages.mx.transitions.easing.Regular] Frame 0
class mx.transitions.easing.Regular
{
function Regular () {
}
static function easeIn(t, b, c, d) {
t = t / d;
return(((c * t) * t) + b);
}
static function easeOut(t, b, c, d) {
t = t / d;
return((((-c) * t) * (t - 2)) + b);
}
static function easeInOut(t, b, c, d) {
t = t / (d / 2);
if (t < 1) {
return((((c / 2) * t) * t) + b);
}
t--;
return((((-c) / 2) * ((t * (t - 2)) - 1)) + b);
}
static var version = "1.1.0.52";
}