Frame 1
function Vector(x, y) {
this.x = x;
this.y = y;
}
function Line(orig_x, orig_y, m_x, m_y) {
if (Math.abs(m_x) == Number.POSITIVE_INFINITY) {
m_x = 1;
m_y = 0;
} else if (Math.abs(m_y) == Number.POSITIVE_INFINITY) {
m_x = 0;
m_y = 1;
}
this._origin = new Vector(orig_x, orig_y);
this._slope = new Vector(m_x, m_y);
}
function ShowDemoNotice() {
clearInterval(demoIntervalID);
demo_notice._visible = true;
}
function StartGame() {
arrow.swapDepths(3);
ball.swapDepths(4);
drop_ball.swapDepths(5);
golfer.swapDepths(6);
dot1.swapDepths(7);
dot2.swapDepths(8);
dot3.swapDepths(9);
dot4.swapDepths(10);
stage_cover.swapDepths(11);
scorecard.swapDepths(12);
instructions.swapDepths(13);
green_info.swapDepths(14);
demo_notice.swapDepths(15);
game_id = Number(game_id);
current_green = Number(in_current_green);
strokes = in_strokes.split(",");
pars = in_pars.split(",");
var i = 0;
while (i < strokes.length) {
strokes[i] = Number(strokes[i]);
pars[i] = Number(pars[i]);
i++;
}
var i = 1;
while (i <= 18) {
scorecard["par_" + i] = pars[i - 1];
scorecard["strokes_" + i] = strokes[i - 1];
if (i <= (current_green + 1)) {
scorecard["score_" + i] = score(pars[i - 1], strokes[i - 1]);
stroke_total = stroke_total + strokes[i - 1];
par_total = par_total + pars[i - 1];
} else {
scorecard["score_" + i] = "";
}
i++;
}
scorecard.score_total = score(par_total, stroke_total);
scorecard.par_total = par_total;
scorecard.strokes_total = stroke_total;
game_obj = new Object();
game_obj.current_green = -1;
golfer.onMouseDown = function () {
if ((instructions._visible || (!golfer.can_move)) || (ball.can_be_placed)) {
return(undefined);
}
if (golfer.ignore_1_mousedown) {
golfer.ignore_1_mousedown = false;
} else if (!ball.ball_in_motion) {
golfer.gotoAndPlay("begin_put");
}
};
scorecard.onEnterFrame = function () {
if (scorecard.show) {
if (scorecard.delay <= 0) {
scorecard._visible = true;
} else {
scorecard.delay--;
}
}
};
stage_cover.onEnterFrame = function () {
if (stage_cover._visible) {
if (stage_cover._alpha <= 15) {
stage_cover._alpha = stage_cover._alpha + 3;
}
}
};
if (game_obj.current_green > current_green) {
ResumeGreen();
} else {
ball.ball_in_motion = false;
golfer.can_move = false;
stage_cover._visible = false;
if (current_green > -1) {
scorecard.show = true;
scorecard.delay = 0;
if (current_green == (greens.length - 1)) {
scorecard.next_hole._visible = false;
}
} else {
NextGreen();
}
}
}
function SendVarsToServer() {
return(undefined);
}
function NextGreen() {
current_green++;
current_green_depth = ((current_green_depth == 1) ? 2 : 1);
attachMovie(greens[current_green], "green" + current_green, current_green_depth);
green = _root["green" + current_green];
stage_cover._visible = false;
scorecard._visible = false;
current_strokes = 0;
green_left = (stage_width / 2) - (green._width / 2);
green_top = ((stage_height / 2) - (green._height / 2)) + 10;
green_top = Math.max(green_top, 40);
green._x = green_left + stage_width;
green._y = green_top;
green.move_into_place = true;
green.load_green_info = true;
green.easing = new Object();
green.easing.time = 0;
green.easing.offset = green_left;
green.easing.range = green._x - green_left;
green.easing.divisions = 60;
ball._x = green._x + green.tee._x;
ball._y = green._y + green.tee._y;
ball.can_be_placed = true;
ball._alpha = 100;
drop_ball._visible = true;
green.onEnterFrame = function () {
if (green.load_green_info) {
pars[current_green] = green.par;
par_total = par_total + green.par;
green_info.name = green.name;
green_info.par = green.par;
green_info.strokes = 0;
green_info.number = current_green + 1;
green.load_green_info = false;
}
if (green.move_into_place) {
var xpos = 0;
with (green.easing) {
time++;
xpos = easeInOut(divisions - time, offset, range, divisions);
}
var xdiff = (green._x - xpos);
green._x = xpos;
if (current_green > 0) {
var prev_green = _root["green" + (current_green - 1)];
prev_green._x = prev_green._x - xdiff;
}
if (Math.abs(green._x - green_left) < 0.3) {
green._x = green_left;
green.move_into_place = false;
if (current_green > 0) {
var prev_green = _root["green" + (current_green - 1)];
prev_green.removeMovieClip();
}
}
UpdateAfterEvent();
}
};
green.tee.onEnterFrame = function () {
if (ball.can_be_placed) {
var bbox = green.tee.getBounds(_root);
var tmpx = _xmouse;
var tmpy = _ymouse;
var border = (ball._width / 2);
if (tmpx < (bbox.xMin + border)) {
tmpx = bbox.xMin + border;
} else if (tmpx > (bbox.xMax - border)) {
tmpx = bbox.xMax - border;
}
if (tmpy < (bbox.yMin + border)) {
tmpy = bbox.yMin + border;
} else if (tmpy > (bbox.yMax - border)) {
tmpy = bbox.yMax - border;
}
ball._x = tmpx;
ball._y = tmpy;
drop_ball._x = tmpx;
drop_ball._y = tmpy - 20;
UpdateAfterEvent();
}
};
green.tee.onMouseDown = function () {
if (!green.hitTest(_root._xmouse, _root._ymouse, false)) {
return(undefined);
}
if (((!green.move_into_place) && (ball.can_be_placed)) && (!instructions._visible)) {
ball.can_be_placed = false;
drop_ball._visible = false;
golfer.ignore_1_mousedown = true;
golfer._visible = true;
arrow._visible = true;
golfer.SetGolfer();
golfer.can_move = true;
green.tee.tee_button._visible = false;
}
};
}
function ResumeGreen() {
current_green = game_obj.current_green;
current_strokes = game_obj.current_strokes;
attachMovie(greens[current_green], "green" + current_green, current_green_depth);
green = _root["green" + current_green];
splash_page._visible = false;
stage_cover._visible = false;
scorecard._visible = false;
green_left = (stage_width / 2) - (green._width / 2);
green_top = ((stage_height / 2) - (green._height / 2)) + 10;
green_top = Math.max(green_top, 40);
green._x = green_left;
green._y = green_top;
green.load_green_info = true;
ball._x = game_obj.ball_x;
ball._y = game_obj.ball_y;
ball.can_be_placed = false;
ball.ball_in_motion = false;
ball._alpha = 100;
drop_ball._visible = false;
golfer._visible = true;
arrow._visible = true;
golfer.SetGolfer();
golfer.can_move = true;
green.tee.tee_button._visible = false;
green.onEnterFrame = function () {
if (green.load_green_info) {
pars[current_green] = green.par;
par_total = par_total + green.par;
green_info.name = green.name;
green_info.par = green.par;
green_info.strokes = current_strokes;
green_info.number = current_green + 1;
green.load_green_info = false;
}
};
}
function MoveBall() {
var time = (1 / frames_per_sec);
var contact_lost_distance = 0;
var net_acc = NetAcceleration(time);
var dx = ((x_component(ball.velocity, ball.dir) * time) + (((0.5 * net_acc.x) * time) * time));
var dy = ((y_component(ball.velocity, ball.dir) * time) + (((0.5 * net_acc.y) * time) * time));
var d = Math.sqrt((dx * dx) + (dy * dy));
var rad = Math.atan2(dy, dx);
var expected_x = (ball._x + dx);
var expected_y = (ball._y - dy);
var collision = false;
ball.velocity = ((2 * d) / time) - ball.velocity;
ball.dir = (rad * 180) / Math.PI;
var num_iter = int((d + 3) / 3);
if (num_iter == 0) {
num_iter = 1;
}
var ddx = (dx / num_iter);
var ddy = (dy / num_iter);
var i = 0;
while (i < num_iter) {
ball._x = ball._x + ddx;
ball._y = ball._y - ddy;
var prev_wall = ((ball.prev_hit.length == 1) ? (ball.prev_hit[0]) : null);
var collisions = CheckForCollisions();
if (collisions.length || (UpdateBallForPegCollisions())) {
UpdateBallDir(collisions);
ball.velocity = ball.velocity * 0.9;
if (Math.abs(ball.velocity) < 5) {
var acc_dir = Math.atan2(-net_acc.y, net_acc.x);
var min_dir = Math.min(pos_angle(acc_dir), pos_angle(ball.dir));
var max_dir = Math.max(pos_angle(acc_dir), pos_angle(ball.dir));
if (((max_dir - min_dir) > 90) && ((max_dir - min_dir) < 270)) {
net_acc.x = 0;
net_acc.y = 0;
ball.velocity = 0;
break;
}
}
time = time - ((time * i) / num_iter);
net_acc = NetAcceleration(time);
dx = (x_component(ball.velocity, ball.dir) * time) + (((0.5 * net_acc.x) * time) * time);
dy = (y_component(ball.velocity, ball.dir) * time) + (((0.5 * net_acc.y) * time) * time);
ddx = dx / num_iter;
ddy = dy / num_iter;
collision = true;
}
i++;
}
if (!collision) {
ball._x = expected_x;
ball._y = expected_y;
}
UpdateGolferOpacity();
if (BallIsInCup() || (current_strokes >= 15)) {
ball.ball_in_motion = false;
ball._x = green._x + green.cup._x;
ball._y = (green._y + green.cup._y) + 1;
ball._alpha = 70;
golfer._alpha = 100;
golfer._visible = false;
golfer.can_move = false;
arrow._visible = false;
strokes[current_green] = current_strokes;
stroke_total = stroke_total + current_strokes;
scorecard["strokes_" + (current_green + 1)] = current_strokes;
scorecard["score_" + (current_green + 1)] = score(green.par, current_strokes);
scorecard["par_" + (current_green + 1)] = pars[current_green];
scorecard.score_total = score(par_total, stroke_total);
scorecard.par_total = par_total;
scorecard.strokes_total = stroke_total;
stage_cover._visible = true;
stage_cover._alpha = 0;
scorecard.show = true;
scorecard.delay = 7;
if (current_green == (greens.length - 1)) {
scorecard.next_hole._visible = false;
demoIntervalID = setInterval(ShowDemoNotice, 2000);
}
SendVarsToServer();
return(undefined);
}
if (((Math.abs(ball.velocity) < 1) && (Math.abs(net_acc.x) < 1)) && (Math.abs(net_acc.y) < 1)) {
ball.ball_in_motion = false;
golfer.can_move = true;
golfer.SetGolfer();
}
}
function BallIsInCup() {
var xdiff = (ball._x - (green._x + green.cup._x));
var ydiff = (ball._y - (green._y + green.cup._y));
var diff = Math.sqrt((xdiff * xdiff) + (ydiff * ydiff));
if (diff <= (green.cup._width / 2)) {
return((++times_over_cup) >= 5);
}
times_over_cup = 0;
}
function CheckForCollisions() {
var touching_sides = new Array();
var ball_wall_angle = 0;
var bdir = pos_angle(ball.dir);
var i = 0;
while (i < green.sides.length) {
if (!green.sides[i].hitTest(ball)) {
} else if (green.sides[i].hitTest(ball._x + ball.radius, ball._y, true)) {
touching_sides[touching_sides.length] = i;
} else if (green.sides[i].hitTest(ball._x - ball.radius, ball._y, true)) {
touching_sides[touching_sides.length] = i;
} else if (green.sides[i].hitTest(ball._x, ball._y - ball.radius, true)) {
touching_sides[touching_sides.length] = i;
} else if (green.sides[i].hitTest(ball._x, ball._y + ball.radius, true)) {
touching_sides[touching_sides.length] = i;
} else if (green.sides[i].hitTest(ball._x + ball.xy_dist_45, ball._y - ball.xy_dist_45, true)) {
touching_sides[touching_sides.length] = i;
} else if (green.sides[i].hitTest(ball._x - ball.xy_dist_45, ball._y + ball.xy_dist_45, true)) {
touching_sides[touching_sides.length] = i;
} else if (green.sides[i].hitTest(ball._x - ball.xy_dist_45, ball._y - ball.xy_dist_45, true)) {
touching_sides[touching_sides.length] = i;
} else if (green.sides[i].hitTest(ball._x + ball.xy_dist_45, ball._y + ball.xy_dist_45, true)) {
touching_sides[touching_sides.length] = i;
}
i++;
}
var new_collisions = new Array();
var new_collision = false;
var i = 0;
while (i < touching_sides.length) {
var side = green.sides[touching_sides[i]];
ComputeSidePoints(side);
var point = BallIsCloseToEndPoint(side);
if (point || (side.shape == "circle")) {
new_collision = true;
var j = 0;
while (j < ball.prev_hit.length) {
if (ball.prev_hit[j] == touching_sides[i]) {
new_collision = false;
break;
}
j++;
}
if (new_collision) {
new_collisions[new_collisions.length] = touching_sides[i];
}
} else {
var line = CreateLineFromSide(side, ball);
var pt = {x:ball._x - green._x, y:ball._y - green._y};
var d = DistanceFromLine(line, pt);
var collision_normal = line.Normal();
if (d < 0) {
collision_normal.Reverse();
}
var ball_velocity = new Vector(x_component(1, ball.dir), -y_component(1, ball.dir));
var v_velocity_normal = ball_velocity.DotProduct(collision_normal);
if (v_velocity_normal < 0) {
new_collisions[new_collisions.length] = touching_sides[i];
}
}
i++;
}
ball.prev_hit = new Array();
var i = 0;
while (i < touching_sides.length) {
ball.prev_hit[i] = touching_sides[i];
i++;
}
return(new_collisions);
}
function UpdateBallForPegCollisions() {
if (!green.pegs.length) {
return(false);
}
var start_row;
var end_row;
var start_col;
var end_col;
var pt = {x:ball._x, y:ball._y};
green.globalToLocal(pt);
var mid_row = int(green.peg_rows.length / 2);
if (pt.y < ((green.peg_rows[mid_row] - green.peg_radius) - ball.radius)) {
start_row = 0;
end_row = mid_row;
} else {
start_row = mid_row;
end_row = green.peg_rows.length;
}
var i = start_row;
while (i < end_row) {
if (Math.abs(pt.y - green.peg_rows[i]) < (ball.radius + green.peg_radius)) {
var j = 0;
while (j < green.peg_cols.length) {
if (Math.abs(pt.x - green.peg_cols[j]) < (ball.radius + green.peg_radius)) {
var peg = green.pegs[i][j];
var bubble = (ball.radius + green.peg_radius);
var d = DistanceBetweenPoints(pt.x, pt.y, peg._x, peg._y);
if (d < bubble) {
while (d < bubble) {
pt.x = pt.x - x_component(0.7, -ball.dir);
pt.y = pt.y - y_component(0.7, -ball.dir);
d = DistanceBetweenPoints(pt.x, pt.y, peg._x, peg._y);
}
green.localToGlobal(pt);
ball._x = pt.x;
ball._y = pt.y;
var tmp_side = {shape:"circle", h:peg._x, k:peg._y};
HandleLineCollision(tmp_side);
return(true);
}
}
j++;
}
break;
}
i++;
}
return(false);
}
function ComputeSidePoints(side) {
if (side.shape == "line") {
side.ll = new Object();
side.ur = new Object();
var a = pos_angle(side.angle);
side.ll.y = side._y + ((side._height - side.line_width) / 2);
side.ur.y = side._y - ((side._height - side.line_width) / 2);
if (a <= 90) {
side.ll.x = side._x - ((side._width - side.line_width) / 2);
side.ur.x = side._x + ((side._width - side.line_width) / 2);
} else {
side.ll.x = side._x + ((side._width - side.line_width) / 2);
side.ur.x = side._x - ((side._width - side.line_width) / 2);
}
side.slope = Math.abs((side.ur.y - side.ll.y) / (side.ur.x - side.ll.x));
if (a < 90) {
side.slope = -side.slope;
}
trace((((("+++++++++ " + side._name) + " angle:") + a) + " slope:") + side.slope);
} else if (side.shape == "circle") {
}
}
function UpdateBallDir(collisions) {
var contact_lost_distance = 0;
if (collisions.length == 0) {
} else if (collisions.length == 1) {
var side = green.sides[collisions[0]];
var d;
var dx;
var dy;
var d1;
var d2;
var abs_angle;
var ball_side_angle;
var point = null;
var contact_dist = (ball.radius + (side.line_width / 2));
if (side.shape == "circle") {
HandleLineCollision(side);
return(0);
}
var lines_1_2_slope = new Vector(x_component(1, side.angle), -y_component(1, side.angle));
var lines_3_4_slope = new Vector(x_component(1, side.angle - 90), -y_component(1, side.angle - 90));
var lw2 = (side.line_width / 2);
var pt = {x:ball._x, y:ball._y};
green.globalToLocal(pt);
line1 = new Line(side._x + x_component(-lw2, side.angle - 90), side._y - y_component(-lw2, side.angle - 90), lines_1_2_slope.x, lines_1_2_slope.y);
line2 = new Line(side._x + x_component(lw2, side.angle - 90), side._y - y_component(lw2, side.angle - 90), lines_1_2_slope.x, lines_1_2_slope.y);
line3 = new Line(side.ur.x, side.ur.y, lines_3_4_slope.x, lines_3_4_slope.y);
line4 = new Line(side.ll.x, side.ll.y, lines_3_4_slope.x, lines_3_4_slope.y);
var distances = new Array(null, DistanceFromLine(line1, pt), DistanceFromLine(line2, pt), DistanceFromLine(line3, pt), DistanceFromLine(line4, pt));
if ((distances[3] * distances[4]) <= 0) {
HandleLineCollision(side);
} else if ((distances[1] * distances[2]) <= 0) {
var tmp_side = {angle:side.angle + 90, shape:"line"};
HandleLineCollision(tmp_side);
} else {
var intersection;
if (Math.abs(distances[1]) < Math.abs(distances[2])) {
if (Math.abs(distances[3]) < Math.abs(distances[4])) {
intersection = line1.Intersection(line3);
} else {
intersection = line1.Intersection(line4);
}
} else if (Math.abs(distances[3]) < Math.abs(distances[4])) {
intersection = line2.Intersection(line3);
} else {
intersection = line2.Intersection(line4);
}
green.localToGlobal(intersection);
HandleEndPointCollision(intersection);
}
} else {
contact_lost_distance = green.HandleMultipleCollisions(collisions);
}
return(contact_lost_distance);
}
function ComputeCommonPoint(s1, s2) {
var cx;
var cy;
var dx;
var dy;
var actual_x;
var actual_y;
var rad;
var tangent;
var line1 = CreateLineFromSide(s1, ball);
var line2 = CreateLineFromSide(s2, ball);
return(line1.Intersection(line2));
}
function DistanceBetweenPoints(x1, y1, x2, y2) {
return(Math.sqrt(((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1))));
}
function BackBallUpFromPoint(x, y) {
var bubble = (ball.radius + 3.5);
var d = DistanceBetweenPoints(ball._x, ball._y, x, y);
while (d < bubble) {
ball._x = ball._x - x_component(0.7, -ball.dir);
ball._y = ball._y - y_component(0.7, -ball.dir);
d = DistanceBetweenPoints(ball._x, ball._y, x, y);
}
}
function BallIsCloseToEndPoint(side) {
var contact_dist = (ball.radius + side.line_width);
var point = null;
if (side.shape == "circle") {
return(null);
}
var d = DistanceBetweenPoints(ball._x, ball._y, green._x + side.ll.x, green._y + side.ll.y);
if (d <= contact_dist) {
point = side.ll;
} else {
d = DistanceBetweenPoints(ball._x, ball._y, green._x + side.ur.x, green._y + side.ur.y);
if (d <= contact_dist) {
point = side.ur;
}
}
return(point);
}
function DistanceFromLine(line, pt) {
var d = (-line.Normal().DotProduct(line.Origin()));
var distance1 = (line.Normal().DotProduct(pt) + d);
return(distance1);
}
function CreateLineFromSide(side, ball) {
if (side.shape == "line") {
return(new Line(side._x, side._y, x_component(1, side.angle), -y_component(1, side.angle)));
}
if (side.shape == "circle") {
var cx = (green._x + side.h);
var cy = (green._y + side.k);
var rad = Math.atan2(cy - ball._y, ball._x - cx);
var dx = x_component(side.radius, rad2deg(rad));
var dy = y_component(side.radius, rad2deg(rad));
var actual_x = ((cx + dx) - green._x);
var actual_y = ((cy - dy) - green._y);
var tangent = (rad + deg2rad(90));
var m1 = Math.tan(tangent);
var angle = rad2deg(tangent);
side.angle = angle;
return(new Line(actual_x, actual_y, x_component(1, angle), -y_component(1, angle)));
}
trace("CreateLineFromSide: unknown side shape:" + side.shape);
}
function HandleLineCollision(side) {
ball.dir = CollisionReboundAngle(side);
}
function HandleEndPointCollision(point) {
trace("HandleEndPointCollision()");
trace(((" ball._x:" + ball._x) + " ball._y:") + ball._y);
trace(((" point.x:" + point.x) + " point.y:") + point.y);
var dx = (ball._x - point.x);
var dy = (-(ball._y - point.y));
trace(((" dx:" + dx) + " dy:") + dy);
var abs_angle = ((Math.atan2(dy, dx) * 180) / Math.PI);
var ball_side_angle = (pos_angle(abs_angle + 90) % 360);
trace(" abs_angle:" + abs_angle);
trace(" ball_side_angle:" + ball_side_angle);
ball.dir = (ball_side_angle * 2) - ball.dir;
}
function HandleInnerInnerCollision(side1, side2) {
trace("HandleInnerInnerCollision()");
var cra1 = CollisionReboundAngle(side1);
var cra2 = CollisionReboundAngle(side2);
trace(((" cra1:" + cra1) + " cra2:") + cra2);
var v1 = new Vector(x_component(1, cra1), y_component(1, cra1));
var v2 = new Vector(x_component(1, cra2), y_component(1, cra2));
var v3 = v1.Add(v2);
trace(((((" v1 " + v1.toString()) + " v2 ") + v2.toString()) + " v3 ") + v3.toString());
if ((Math.abs(v3.x) < 0.05) && (Math.abs(v3.y) < 0.05)) {
ball.dir = 180 + ball.dir;
} else {
ball.dir = rad2deg(Math.atan2(v3.y, v3.x));
}
}
function CollisionReboundAngle(side) {
if (side.shape == "line") {
return((side.angle * 2) - ball.dir);
}
if (side.shape == "circle") {
var tangent = ComputeCircleTangentAtPoint(side, ball._x - green._x, ball._y - green._y);
return((tangent * 2) - ball.dir);
}
trace("CollisionReboundAngle(): unknown side shape: " + side.shape);
}
function ComputeCircleTangentAtPoint(side, x, y) {
var rad = Math.atan2(side.k - y, x - side.h);
var tangent = (rad + deg2rad(90));
return(rad2deg(tangent));
}
function NetAcceleration(time) {
var bridge_i = -1;
var on_bridge = false;
var net_acc = {x:0, y:0};
var drag_i = 0;
var apply_drag = true;
var i = 0;
while (i < green.acc.length) {
if (green.acc[i].type == "bridge") {
bridge_i = i;
}
if (green.acc[i].type == "drag") {
drag_i = i;
} else if (ball.hitTest(green.acc[i].mc)) {
if (green.acc[i].mc.hitTest(ball._x, ball._y, true)) {
if (ball.on_bridge) {
if (green.acc[i].type == "bridge") {
net_acc.x = net_acc.x + x_component(green.acc[i].val, ball.dir);
net_acc.y = net_acc.y + y_component(green.acc[i].val, ball.dir);
on_bridge = true;
}
} else if (((green.acc[i].type == "sand") || (green.acc[i].type == "pit_floor")) || (green.acc[i].type == "ice")) {
var stop_acc = (ball.velocity / time);
var drag_acc = Math.min(stop_acc, green.acc[i].val);
green.acc[i].dir = ball.dir + 180;
net_acc.x = net_acc.x + x_component(drag_acc, green.acc[i].dir);
net_acc.y = net_acc.y + y_component(drag_acc, green.acc[i].dir);
if (drag_acc >= stop_acc) {
apply_drag = false;
}
} else if (green.acc[i].type == "ramp") {
net_acc.x = net_acc.x + x_component(green.acc[i].val, green.acc[i].dir);
net_acc.y = net_acc.y + y_component(green.acc[i].val, green.acc[i].dir);
} else if (green.acc[i].type == "trough") {
var midline = new Line(green.acc[i].mc._x, green.acc[i].mc._y, x_component(1, green.acc[i].dir), y_component(1, green.acc[i].dir));
var d = DistanceFromLine(midline, {x:ball._x - green._x, y:ball._y - green._y});
if (Math.abs(d) > 3) {
var dir = (green.acc[i].dir + ((d < 0) ? 90 : -90));
var val = (green.acc[i].val * ((Math.abs(d) > 6) ? 1 : 0.5));
net_acc.x = net_acc.x + x_component(val, dir);
net_acc.y = net_acc.y + y_component(val, dir);
}
} else if (green.acc[i].type == "cone") {
var tmpx = (ball._x - (green._x + green.acc[i].mc._x));
var tmpy = (ball._y - (green._y + green.acc[i].mc._y));
var rad = Math.atan2(tmpy, tmpx);
var dir = (360 - ((rad * 180) / Math.PI));
net_acc.x = net_acc.x + x_component(green.acc[i].val, dir);
net_acc.y = net_acc.y + y_component(green.acc[i].val, dir);
} else if (green.acc[i].type == "pit_wall") {
var tmpx = (ball._x - (green._x + green.acc[i].mc._parent._x));
var tmpy = (ball._y - (green._y + green.acc[i].mc._parent._y));
var rad = Math.atan2(tmpy, tmpx);
var dir = (360 - ((rad * 180) / Math.PI));
net_acc.x = net_acc.x + x_component(green.acc[i].val, dir);
net_acc.y = net_acc.y + y_component(green.acc[i].val, dir);
} else if (green.acc[i].type == "blackhole") {
var tmpx = (ball._x - (green._x + green.acc[i].mc._x));
var tmpy = (ball._y - (green._y + green.acc[i].mc._y));
var tmpz = Math.sqrt((tmpx * tmpx) + (tmpy * tmpy));
if (tmpz < ((green.acc[i].mc._width / 2) * 0.6)) {
if (green.acc[i].mc.replace_ball) {
green.acc[i].mc.replace_ball();
} else {
ball._x = green._x + green.tee._x;
ball._y = green._y + green.tee._y;
}
ball.velocity = 0;
ball.ball_in_motion = false;
golfer.can_move = true;
golfer.SetGolfer();
} else {
var rad = Math.atan2(tmpy, tmpx);
var dir = (360 - ((rad * 180) / Math.PI));
net_acc.x = net_acc.x + x_component(green.acc[i].val, dir);
net_acc.y = net_acc.y + y_component(green.acc[i].val, dir);
}
} else if (green.acc[i].type == "bridge") {
on_bridge = true;
} else if (green.acc[i].type == "bridge_entrance") {
ball.on_bridge = true;
on_bridge = true;
} else if (green.acc[i].type == "cup_out") {
ball.dir = green.acc[i].dir;
} else if (green.acc[i].type == "cup_in") {
if (ball.velocity < 90) {
ball._x = green._x + green.acc[i].val._x;
ball._y = green._y + green.acc[i].val._y;
green.disappearing_cup1 = green.acc[i].mc;
green.disappearing_cup2 = green.acc[i].val;
green.acc[i].mc.onEnterFrame = function () {
if (green.disappearing_cup1._alpha > 0) {
green.disappearing_cup1._alpha = green.disappearing_cup1._alpha - 8;
} else {
green.disappearing_cup1.onEnterFrame = null;
}
};
green.acc[i].val.onEnterFrame = function () {
if (green.disappearing_cup2._alpha > 0) {
green.disappearing_cup2._alpha = green.disappearing_cup2._alpha - 8;
} else {
green.disappearing_cup2.onEnterFrame = null;
}
};
}
}
}
}
i++;
}
if (apply_drag) {
var dx = ((x_component(ball.velocity, ball.dir) * time) + (((0.5 * net_acc.x) * time) * time));
var dy = ((y_component(ball.velocity, ball.dir) * time) + (((0.5 * net_acc.y) * time) * time));
var d = Math.sqrt((dx * dx) + (dy * dy));
var rad = Math.atan2(dy, dx);
var new_velocity = (((2 * d) / time) - ball.velocity);
var stop_acc = (new_velocity / time);
var drag_acc = Math.min(stop_acc, green.acc[drag_i].val);
green.acc[drag_i].dir = rad2deg(rad) + 180;
net_acc.x = net_acc.x + x_component(drag_acc, green.acc[drag_i].dir);
net_acc.y = net_acc.y + y_component(drag_acc, green.acc[drag_i].dir);
}
if ((!on_bridge) && (ball.on_bridge == true)) {
ball.on_bridge = false;
}
if (on_bridge && (!ball.on_bridge)) {
green.acc[bridge_i].mc._alpha = 10;
} else {
green.acc[bridge_i].mc._alpha = 100;
}
return(net_acc);
}
function UpdateGolferOpacity() {
var pt = {x:ball._x, y:ball._y};
var lines = new Array(golfer.backline, golfer.rightline, golfer.frontline, golfer.leftline);
var distances = new Array(DistanceFromLine(golfer.backline, pt), DistanceFromLine(golfer.rightline, pt), DistanceFromLine(golfer.frontline, pt), DistanceFromLine(golfer.leftline, pt));
if (((distances[0] * distances[2]) < 0) && ((distances[1] * distances[3]) < 0)) {
golfer._alpha = 20;
} else {
golfer._alpha = 100;
}
}
function coords(obj) {
if ((obj.x != null) || (obj.y != null)) {
return(((("(" + obj.x) + ", ") + obj.y) + ")");
}
return(((("(" + obj._x) + ", ") + obj._y) + ")");
}
function x_component(z, dir) {
return(z * Math.cos((Math.PI/180) * dir));
}
function y_component(z, dir) {
return(z * Math.sin((Math.PI/180) * dir));
}
function rad2deg(rad) {
return((rad * 180) / Math.PI);
}
function deg2rad(deg) {
return((deg * Math.PI) / 180);
}
function pos_angle(a) {
if (a > 360) {
a = a % 360;
} else {
while (a < 0) {
a = a + 360;
}
}
return(a);
}
function easeInOut(t, b, c, d) {
if (((t = t / (d / 2))) < 1) {
return((((((c / 2) * t) * t) * t) * t) + b);
}
return((((-c) / 2) * ((((((t = t - 2)) * t) * t) * t) - 2)) + b);
}
function score(par, strokes) {
if (strokes == par) {
return("e");
}
if (strokes < par) {
return("-" + (par - strokes));
}
return("+" + (strokes - par));
}
Vector.prototype.Add = function (v) {
return(new Vector(this.x + v.x, this.y + v.y));
};
Vector.prototype.Reverse = function () {
this.x = -this.x;
this.y = -this.y;
};
Vector.prototype.DotProduct = function (v) {
return((this.x * v.x) + (this.y * v.y));
};
Vector.prototype.Normalize = function () {
var total = Math.sqrt((this.x * this.x) + (this.y * this.y));
this.x = this.x / total;
this.y = this.y / total;
};
Vector.prototype.toString = function () {
return(((("<" + this.x) + ", ") + this.y) + ">");
};
Line.prototype.Origin = function () {
return(this._origin);
};
Line.prototype.Slope = function () {
return(this._slope);
};
Line.prototype.Slope2 = function () {
if (!this._slope2) {
this._slope2 = this._slope.y / this._slope.x;
}
return(this._slope2);
};
Line.prototype.YIntercept = function () {
if (!this._yintercept) {
this._yintercept = this._origin.y - (this._origin.x * (this._slope.y / this._slope.x));
}
return(this._yintercept);
};
Line.prototype.Intersection = function (line2) {
if (this.Slope2() == line2.Slope2()) {
return(null);
}
if ((this.Slope2() == Number.POSITIVE_INFINITY) || (this.Slope2() == Number.NEGATIVE_INFINITY)) {
return(new Vector(this.Origin().x, (line2.Slope2() * this.Origin().x) + line2.YIntercept()));
}
if ((line2.Slope2() == Number.POSITIVE_INFINITY) || (line2.Slope2() == Number.NEGATIVE_INFINITY)) {
return(new Vector(line2.Origin().x, (this.Slope2() * line2.Origin().x) + this.YIntercept()));
}
var x = ((line2.YIntercept() - this.YIntercept()) / (this.Slope2() - line2.Slope2()));
var y = ((this.Slope2() * x) + this.YIntercept());
return(new Vector(x, y));
};
Line.prototype.Normal = function () {
if (!this._normal) {
this._normal = new Vector(-this.Slope().y, this.Slope().x);
this._normal.Normalize();
if ((this._normal.x < 0) && (this._normal.y < 0)) {
this._normal.x = -this._normal.x;
this._normal.y = -this._normal.y;
}
}
return(this._normal);
};
Line.prototype.toString = function () {
var s = (((("Origin (" + this.Origin().x) + ", ") + this.Origin().y) + ") ");
s = s + (((("Slope (" + this.Slope().x) + ", ") + this.Slope().y) + ") ");
s = s + (((("Normal (" + this.Normal().x) + ", ") + this.Normal().y) + ")");
return(s);
};
in_current_green = -1;
game_id = 0;
in_strokes = "";
in_pars = "3,4,3,3,2,3";
var greens = new Array("green_crash_test", "green_serpentine", "green_in_and_out", "green_craters", "green_sawtooths", "green_guessing_game");
var current_green = -1;
var current_strokes = 0;
var stage_width = Stage.width;
var stage_height = Stage.height;
var default_drag = 40;
var frames_per_sec = 20;
var strokes = new Array();
var pars = new Array();
var current_green_depth = 1;
var par_total = 0;
var stroke_total = 0;
var so;
var game_obj;
scorecard._visible = false;
instructions._visible = false;
open_instructions.onPress = function () {
instructions._visible = true;
};
if (Number(in_current_green) != -1) {
splash_page._visible = false;
StartGame();
}
MovieClip.prototype.addAcc = function (obj) {
if (!this.acc) {
this.acc = new Array();
}
this.acc[this.acc.length] = obj;
};
Instance of Symbol 259 MovieClip "golfer" in Frame 1
onClipEvent (mouseMove) {
if ((!_root.ball.ball_in_motion) && (!_root.ball.can_be_placed)) {
var xdiff = (_root._xmouse - _root.ball._x);
var ydiff = (-(_root._ymouse - _root.ball._y));
var rad = Math.atan2(ydiff, xdiff);
SetPosition(_root.ball._x, _root.ball._y, (rad * 180) / Math.PI);
SetArrow(_root.ball._x, _root.ball._y, _root._xmouse, _root._ymouse, (rad * 180) / Math.PI);
UpdateAfterEvent();
}
}
Instance of Symbol 273 MovieClip "ball" in Frame 1
onClipEvent (enterFrame) {
if (ball_in_motion) {
_root.MoveBall();
UpdateAfterEvent();
}
}
Symbol 1 MovieClip [FUIComponentSymbol] Frame 1
#initclip 1
function FUIComponentClass() {
this.init();
}
FUIComponentClass.prototype = new MovieClip();
FUIComponentClass.prototype.init = function () {
this.enable = true;
this.focused = false;
this.useHandCursor = false;
this._accImpl = new Object();
this._accImpl.stub = true;
this.styleTable = new Array();
if (_global.globalStyleFormat == undefined) {
_global.globalStyleFormat = new FStyleFormat();
globalStyleFormat.isGlobal = true;
_global._focusControl = new Object();
_global._focusControl.onSetFocus = function (oldFocus, newFocus) {
oldFocus.myOnKillFocus();
newFocus.myOnSetFocus();
};
Selection.addListener(_global._focusControl);
}
if (this._name != undefined) {
this._focusrect = false;
this.tabEnabled = true;
this.focusEnabled = true;
this.tabChildren = false;
this.tabFocused = true;
if (this.hostStyle == undefined) {
globalStyleFormat.addListener(this);
} else {
this.styleTable = this.hostStyle;
}
this.deadPreview._visible = false;
this.deadPreview._width = (this.deadPreview._height = 1);
this.methodTable = new Object();
this.keyListener = new Object();
this.keyListener.controller = this;
this.keyListener.onKeyDown = function () {
this.controller.myOnKeyDown();
};
this.keyListener.onKeyUp = function () {
this.controller.myOnKeyUp();
};
for (var i in this.styleFormat_prm) {
this.setStyleProperty(i, this.styleFormat_prm[i]);
}
}
};
FUIComponentClass.prototype.setEnabled = function (enabledFlag) {
this.enable = ((arguments.length > 0) ? (enabledFlag) : true);
this.tabEnabled = (this.focusEnabled = enabledFlag);
if ((!this.enable) && (this.focused)) {
Selection.setFocus(undefined);
}
};
FUIComponentClass.prototype.getEnabled = function () {
return(this.enable);
};
FUIComponentClass.prototype.setSize = function (w, h) {
this.width = w;
this.height = h;
this.focusRect.removeMovieClip();
};
FUIComponentClass.prototype.setChangeHandler = function (chng, obj) {
this.handlerObj = ((obj == undefined) ? (this._parent) : (obj));
this.changeHandler = chng;
};
FUIComponentClass.prototype.invalidate = function (methodName) {
this.methodTable[methodName] = true;
this.onEnterFrame = this.cleanUI;
};
FUIComponentClass.prototype.cleanUI = function () {
if (this.methodTable.setSize) {
this.setSize(this.width, this.height);
} else {
this.cleanUINotSize();
}
this.methodTable = new Object();
delete this.onEnterFrame;
};
FUIComponentClass.prototype.cleanUINotSize = function () {
for (var funct in this.methodTable) {
this[funct]();
}
};
FUIComponentClass.prototype.drawRect = function (x, y, w, h) {
var inner = this.styleTable.focusRectInner.value;
var outer = this.styleTable.focusRectOuter.value;
if (inner == undefined) {
inner = 16777215 /* 0xFFFFFF */;
}
if (outer == undefined) {
outer = 0;
}
this.createEmptyMovieClip("focusRect", 1000);
this.focusRect.controller = this;
this.focusRect.lineStyle(1, outer);
this.focusRect.moveTo(x, y);
this.focusRect.lineTo(x + w, y);
this.focusRect.lineTo(x + w, y + h);
this.focusRect.lineTo(x, y + h);
this.focusRect.lineTo(x, y);
this.focusRect.lineStyle(1, inner);
this.focusRect.moveTo(x + 1, y + 1);
this.focusRect.lineTo((x + w) - 1, y + 1);
this.focusRect.lineTo((x + w) - 1, (y + h) - 1);
this.focusRect.lineTo(x + 1, (y + h) - 1);
this.focusRect.lineTo(x + 1, y + 1);
};
FUIComponentClass.prototype.pressFocus = function () {
this.tabFocused = false;
this.focusRect.removeMovieClip();
Selection.setFocus(this);
};
FUIComponentClass.prototype.drawFocusRect = function () {
this.drawRect(-2, -2, this.width + 4, this.height + 4);
};
FUIComponentClass.prototype.myOnSetFocus = function () {
this.focused = true;
Key.addListener(this.keyListener);
if (this.tabFocused) {
this.drawFocusRect();
}
};
FUIComponentClass.prototype.myOnKillFocus = function () {
this.tabFocused = true;
this.focused = false;
this.focusRect.removeMovieClip();
Key.removeListener(this.keyListener);
};
FUIComponentClass.prototype.executeCallBack = function () {
this.handlerObj[this.changeHandler](this);
};
FUIComponentClass.prototype.updateStyleProperty = function (styleFormat, propName) {
this.setStyleProperty(propName, styleFormat[propName], styleFormat.isGlobal);
};
FUIComponentClass.prototype.setStyleProperty = function (propName, value, isGlobal) {
if (value == "") {
return(undefined);
}
var tmpValue = parseInt(value);
if (!isNaN(tmpValue)) {
value = tmpValue;
}
var global = ((arguments.length > 2) ? (isGlobal) : false);
if (this.styleTable[propName] == undefined) {
this.styleTable[propName] = new Object();
this.styleTable[propName].useGlobal = true;
}
if (this.styleTable[propName].useGlobal || (!global)) {
this.styleTable[propName].value = value;
if (this.setCustomStyleProperty(propName, value)) {
} else if (propName == "embedFonts") {
this.invalidate("setSize");
} else if (propName.subString(0, 4) == "text") {
if (this.textStyle == undefined) {
this.textStyle = new TextFormat();
}
var textProp = propName.subString(4, propName.length);
this.textStyle[textProp] = value;
this.invalidate("setSize");
} else {
for (var j in this.styleTable[propName].coloredMCs) {
var myColor = new Color(this.styleTable[propName].coloredMCs[j]);
if (this.styleTable[propName].value == undefined) {
var myTObj = {ra:"100", rb:"0", ga:"100", gb:"0", ba:"100", bb:"0", aa:"100", ab:"0"};
myColor.setTransform(myTObj);
} else {
myColor.setRGB(value);
}
}
}
this.styleTable[propName].useGlobal = global;
}
};
FUIComponentClass.prototype.registerSkinElement = function (skinMCRef, propName) {
if (this.styleTable[propName] == undefined) {
this.styleTable[propName] = new Object();
this.styleTable[propName].useGlobal = true;
}
if (this.styleTable[propName].coloredMCs == undefined) {
this.styleTable[propName].coloredMCs = new Object();
}
this.styleTable[propName].coloredMCs[skinMCRef] = skinMCRef;
if (this.styleTable[propName].value != undefined) {
var myColor = new Color(skinMCRef);
myColor.setRGB(this.styleTable[propName].value);
}
};
_global.FStyleFormat = function () {
this.nonStyles = {listeners:true, isGlobal:true, isAStyle:true, addListener:true, removeListener:true, nonStyles:true, applyChanges:true};
this.listeners = new Object();
this.isGlobal = false;
if (arguments.length > 0) {
for (var i in arguments[0]) {
this[i] = arguments[0][i];
}
}
};
_global.FStyleFormat.prototype = new Object();
FStyleFormat.prototype.addListener = function () {
var arg = 0;
while (arg < arguments.length) {
var mcRef = arguments[arg];
this.listeners[arguments[arg]] = mcRef;
for (var i in this) {
if (this.isAStyle(i)) {
mcRef.updateStyleProperty(this, i.toString());
}
}
arg++;
}
};
FStyleFormat.prototype.removeListener = function (component) {
this.listeners[component] = undefined;
for (var prop in this) {
if (this.isAStyle(prop)) {
if (component.styleTable[prop].useGlobal == this.isGlobal) {
component.styleTable[prop].useGlobal = true;
var value = (this.isGlobal ? undefined : (globalStyleFormat[prop]));
component.setStyleProperty(prop, value, true);
}
}
}
};
FStyleFormat.prototype.applyChanges = function () {
var count = 0;
for (var i in this.listeners) {
var component = this.listeners[i];
if (arguments.length > 0) {
var j = 0;
while (j < arguments.length) {
if (this.isAStyle(arguments[j])) {
component.updateStyleProperty(this, arguments[j]);
}
j++;
}
} else {
for (var j in this) {
if (this.isAStyle(j)) {
component.updateStyleProperty(this, j.toString());
}
}
}
}
};
FStyleFormat.prototype.isAStyle = function (name) {
return((this.nonStyles[name] ? false : true));
};
#endinitclip
Symbol 14 MovieClip Frame 1
var component = _parent._parent;
component.registerSkinElement(arrow_mc, "arrow");
component.registerSkinElement(face_mc, "face");
component.registerSkinElement(shadow_mc, "shadow");
component.registerSkinElement(darkshadow_mc, "darkshadow");
component.registerSkinElement(highlight_mc, "highlight");
component.registerSkinElement(highlight3D_mc, "highlight3D");
Symbol 24 MovieClip Frame 1
var component = _parent._parent;
component.registerSkinElement(arrow_mc, "arrow");
component.registerSkinElement(face_mc, "face");
component.registerSkinElement(shadow_mc, "shadow");
component.registerSkinElement(darkshadow_mc, "darkshadow");
component.registerSkinElement(highlight_mc, "highlight");
component.registerSkinElement(highlight3D_mc, "highlight3D");
Symbol 33 MovieClip Frame 1
var component = _parent._parent;
component.registerSkinElement(arrow_mc, "foregroundDisabled");
component.registerSkinElement(face_mc, "face");
component.registerSkinElement(shadow_mc, "shadow");
component.registerSkinElement(darkshadow_mc, "darkshadow");
component.registerSkinElement(highlight_mc, "highlight");
component.registerSkinElement(highlight3D_mc, "highlight3D");
Symbol 34 MovieClip [UpArrow] Frame 1
stop();
Symbol 34 MovieClip [UpArrow] Frame 2
stop();
Symbol 34 MovieClip [UpArrow] Frame 3
stop();
Symbol 41 MovieClip Frame 1
var component = _parent._parent;
component.registerSkinElement(shadow_mc, "shadow");
component.registerSkinElement(darkshadow_mc, "darkshadow");
component.registerSkinElement(highlight_mc, "highlight");
component.registerSkinElement(highlight3D_mc, "highlight3D");
Symbol 48 MovieClip Frame 1
var component = _parent._parent;
component.registerSkinElement(face_mc, "face");
component.registerSkinElement(shadow_mc, "shadow");
component.registerSkinElement(darkshadow_mc, "darkshadow");
component.registerSkinElement(highlight_mc, "highlight");
component.registerSkinElement(highlight3D_mc, "highlight3D");
Symbol 53 MovieClip Frame 1
var component = _parent._parent;
component.registerSkinElement(highlight3D_mc, "highlight3D");
component.registerSkinElement(shadow_mc, "shadow");
component.registerSkinElement(darkshadow_mc, "darkshadow");
component.registerSkinElement(highlight_mc, "highlight");
Symbol 54 MovieClip [ScrollThumb] Frame 1
stop();
Symbol 62 MovieClip Frame 1
var component = _parent._parent;
component.registerSkinElement(arrow_mc, "arrow");
component.registerSkinElement(face_mc, "face");
component.registerSkinElement(shadow_mc, "shadow");
component.registerSkinElement(darkshadow_mc, "darkshadow");
component.registerSkinElement(highlight_mc, "highlight");
component.registerSkinElement(highlight3D_mc, "highlight3D");
Symbol 70 MovieClip Frame 1
var component = _parent._parent;
component.registerSkinElement(arrow_mc, "arrow");
component.registerSkinElement(face_mc, "face");
component.registerSkinElement(shadow_mc, "shadow");
component.registerSkinElement(darkshadow_mc, "darkshadow");
component.registerSkinElement(highlight_mc, "highlight");
component.registerSkinElement(highlight3D_mc, "highlight3D");
Symbol 78 MovieClip Frame 1
var component = _parent._parent;
component.registerSkinElement(arrow_mc, "foregroundDisabled");
component.registerSkinElement(face_mc, "face");
component.registerSkinElement(shadow_mc, "shadow");
component.registerSkinElement(darkshadow_mc, "darkshadow");
component.registerSkinElement(highlight_mc, "highlight");
component.registerSkinElement(highlight3D_mc, "highlight3D");
Symbol 79 MovieClip [DownArrow] Frame 1
stop();
Symbol 79 MovieClip [DownArrow] Frame 2
stop();
Symbol 79 MovieClip [DownArrow] Frame 3
stop();
Symbol 87 MovieClip [green_test] Frame 1
function Vector(x, y) {
this.x = x;
this.y = y;
}
function Line(orig_x, orig_y, m_x, m_y) {
if (Math.abs(m_x) == Number.POSITIVE_INFINITY) {
m_x = 1;
m_y = 0;
} else if (Math.abs(m_y) == Number.POSITIVE_INFINITY) {
m_x = 0;
m_y = 1;
}
this._origin = new Vector(orig_x, orig_y);
this._slope = new Vector(m_x, m_y);
}
function HandleMultipleCollisions(collisions) {
var s1 = sides[collisions[0]];
var s2 = sides[collisions[1]];
var side5 = null;
var side6 = null;
var side8 = null;
var i = 0;
while (i <= 1) {
switch (sides[collisions[i]]._name) {
case "side5" :
side5 = sides[collisions[i]];
break;
case "side6" :
side6 = sides[collisions[i]];
break;
case "side8" :
side8 = sides[collisions[i]];
break;
}
i++;
}
if (side6) {
if (side5) {
var point = _root.ComputeCommonPoint(side5, side6);
var abs_point = {x:_x + point.x, y:_y + point.y};
_root.BackBallUpFromPoint(abs_point);
var line1 = (new _root.Line(side6._x, side6._y, 1, side6.slope));
var line2 = (new _root.Line(side5._x, side5._y, 1, side5.slope));
var pt = {x:_root.ball._x - _root.green._x, y:_root.ball._y - _root.green._y};
var d1 = _root.DistanceFromLine(line1, pt);
var d2 = _root.DistanceFromLine(line2, pt);
trace(((" d1:" + d1) + " d2:") + d2);
if (d1 > 0) {
if (d2 < 0) {
trace(" --> end point");
_root.HandleEndPointCollision(abs_point);
} else {
trace(" --> line collision side6");
_root.HandleLineCollision(side6);
}
} else if (d2 < 0) {
trace(" --> line collision side5");
_root.HandleLineCollision(side5);
} else {
trace(" --> inner collision");
_root.HandleInnerInnerCollision(side6, side5);
}
} else {
trace("--------------------");
var point = _root.ComputeCommonPoint(side6, side8);
var abs_point = {x:_x + point.x, y:_y + point.y};
_root.BackBallUpFromPoint(abs_point);
var line1 = new Line(side6._x, side6._y, 1, side6.slope);
var line2 = new Line(side8._x, side8._y, 1, side8.slope);
var endline = new Line(side8.ll.x, side8.ll.y, line2.Normal().x, line2.Normal().y);
var pt = {x:_root.ball._x - _root.green._x, y:_root.ball._y - _root.green._y};
var d1 = _root.DistanceFromLine(line1, pt);
var d2 = _root.DistanceFromLine(line2, pt);
var d3 = _root.DistanceFromLine(endline, pt);
trace(((((((" common point:" + point.x) + ", ") + point.y) + " ball (pt):") + pt.x) + ", ") + pt.y);
trace(" line1:" + line1.toString());
trace(" line2:" + line2.toString());
trace(" endline:" + endline.toString());
trace(((((" d1:" + d1) + " d2:") + d2) + " d3:") + d3);
if (d1 < 0) {
if (_root.ball._y <= (_root.green._y + side6.ll.y)) {
trace((((((" ball._y (" + _root.ball._y) + ") <= green._y+side6.ll.y (") + _root.green._y) + "+") + side6.ll.y) + ")");
trace(" --> line collision side6");
_root.HandleLineCollision(side6);
} else {
trace(" --> end point side6");
_root.HandleEndPointCollision(abs_point);
}
} else if (d2 <= 0) {
trace(" --> inner collision");
_root.HandleInnerInnerCollision(side6, side8);
} else if (d3 <= 0) {
trace(" --> line collision side8");
_root.HandleLineCollision(side8);
} else {
trace(" --> end point side8");
_root.HandleEndPointCollision(abs_point);
}
}
} else {
_root.HandleInnerInnerCollision(s1, s2);
}
}
Vector.prototype.Add = function (v) {
return(new Vector(this.x + v.x, this.y + v.y));
};
Vector.prototype.Reverse = function () {
this.x = -this.x;
this.y = -this.y;
};
Vector.prototype.DotProduct = function (v) {
return((this.x * v.x) + (this.y * v.y));
};
Vector.prototype.Normalize = function () {
var total = Math.sqrt((this.x * this.x) + (this.y * this.y));
this.x = this.x / total;
this.y = this.y / total;
};
Vector.prototype.toString = function () {
return(((("<" + this.x) + ", ") + this.y) + ">");
};
Line.prototype.Origin = function () {
return(this._origin);
};
Line.prototype.Slope = function () {
return(this._slope);
};
Line.prototype.Slope2 = function () {
if (!this._slope2) {
this._slope2 = this._slope.y / this._slope.x;
}
return(this._slope2);
};
Line.prototype.YIntercept = function () {
if (!this._yintercept) {
this._yintercept = this._origin.y - (this._origin.x * (this._slope.y / this._slope.x));
}
return(this._yintercept);
};
Line.prototype.Intersection = function (line2) {
if (this.Slope2() == line2.Slope2()) {
return(null);
}
if ((this.Slope2() == Number.POSITIVE_INFINITY) || (this.Slope2() == Number.NEGATIVE_INFINITY)) {
return(new Vector(this.Origin().x, (line2.Slope2() * this.Origin().x) + line2.YIntercept()));
}
if ((line2.Slope2() == Number.POSITIVE_INFINITY) || (line2.Slope2() == Number.NEGATIVE_INFINITY)) {
return(new Vector(line2.Origin().x, (this.Slope2() * line2.Origin().x) + this.YIntercept()));
}
var x = ((line2.YIntercept() - this.YIntercept()) / (this.Slope2() - line2.Slope2()));
var y = ((this.Slope2() * x) + this.YIntercept());
return(new Vector(x, y));
};
Line.prototype.Normal = function () {
if (!this._normal) {
this._normal = new Vector(-this.Slope().y, this.Slope().x);
this._normal.Normalize();
if ((this._normal.x < 0) && (this._normal.y < 0)) {
this._normal.x = -this._normal.x;
this._normal.y = -this._normal.y;
}
}
return(this._normal);
};
Line.prototype.toString = function () {
var s = (((("Origin (" + this.Origin().x) + ", ") + this.Origin().y) + ") ");
s = s + (((("Slope (" + this.Slope().x) + ", ") + this.Slope().y) + ") ");
s = s + (((("Normal (" + this.Normal().x) + ", ") + this.Normal().y) + ")");
return(s);
};
var name = "Tester";
var ball_x = 20;
var ball_y = 20;
var par = 2;
var sides = new Array(side1, side2, side4, side5, side6, side7, side8);
var i = 0;
while (i < sides.length) {
sides[i].line_width = 3;
i++;
}
side1.shape = "line";
side1.angle = 0;
side2.shape = "line";
side2.angle = 90;
side4.shape = "line";
side4.angle = 90;
side5.shape = "line";
side5.angle = 0;
side6.shape = "line";
side6.angle = 90;
side7.shape = "circle";
side7.angle = 0;
side7.h = side7._x;
side7.k = side7._y - (side7._height / 2);
side7.radius = (side7._width - 3) / 2;
side8.shape = "line";
side8.angle = 135;
var acc = new Array();
acc[0] = new Object();
acc[0].type = "drag";
acc[0].val = _root.default_drag;
acc[0].dir = 0;
acc[0].mc = null;
Symbol 116 MovieClip Frame 1
this.onEnterFrame = function () {
if ((speed > 0) && (((_y + (_height / 2)) + speed) > bottom)) {
_y = (bottom - (_height / 2));
speed = -speed;
} else if ((speed < 0) && (((_y - (_height / 2)) + speed) < top)) {
_y = (top + (_height / 2));
speed = -speed;
} else {
_y = (_y + speed);
}
};
Symbol 122 MovieClip Frame 1
this.onEnterFrame = function () {
if (shimmer > 0) {
_alpha = (_alpha + shimmer);
if (_alpha >= 100) {
shimmer = -shimmer;
}
} else if (shimmer < 0) {
_alpha = (_alpha + shimmer);
if (_alpha <= 0) {
shimmer = 0;
}
} else {
var _0to1 = Math.random();
if (_0to1 >= 0.99) {
if (_0to1 == 1) {
shimmer = 5;
} else if (_0to1 >= 0.996) {
shimmer = 7;
} else if (_0to1 >= 0.993) {
shimmer = 9;
} else {
shimmer = 11;
}
}
_alpha = 0;
}
};
Symbol 125 MovieClip [green_crash_test] Frame 1
function Vector(x, y) {
this.x = x;
this.y = y;
}
function Line(orig_x, orig_y, m_x, m_y) {
if (Math.abs(m_x) == Number.POSITIVE_INFINITY) {
m_x = 1;
m_y = 0;
} else if (Math.abs(m_y) == Number.POSITIVE_INFINITY) {
m_x = 0;
m_y = 1;
}
this._origin = new Vector(orig_x, orig_y);
this._slope = new Vector(m_x, m_y);
}
function HandleMultipleCollisions(collisions) {
var s1 = sides[collisions[0]];
var s2 = sides[collisions[1]];
_root.HandleInnerInnerCollision(s1, s2);
}
Vector.prototype.Add = function (v) {
return(new Vector(this.x + v.x, this.y + v.y));
};
Vector.prototype.Reverse = function () {
this.x = -this.x;
this.y = -this.y;
};
Vector.prototype.DotProduct = function (v) {
return((this.x * v.x) + (this.y * v.y));
};
Vector.prototype.Normalize = function () {
var total = Math.sqrt((this.x * this.x) + (this.y * this.y));
this.x = this.x / total;
this.y = this.y / total;
};
Vector.prototype.toString = function () {
return(((("<" + this.x) + ", ") + this.y) + ">");
};
Line.prototype.Origin = function () {
return(this._origin);
};
Line.prototype.Slope = function () {
return(this._slope);
};
Line.prototype.Slope2 = function () {
if (!this._slope2) {
this._slope2 = this._slope.y / this._slope.x;
}
return(this._slope2);
};
Line.prototype.YIntercept = function () {
if (!this._yintercept) {
this._yintercept = this._origin.y - (this._origin.x * (this._slope.y / this._slope.x));
}
return(this._yintercept);
};
Line.prototype.Intersection = function (line2) {
if (this.Slope2() == line2.Slope2()) {
return(null);
}
if ((this.Slope2() == Number.POSITIVE_INFINITY) || (this.Slope2() == Number.NEGATIVE_INFINITY)) {
return(new Vector(this.Origin().x, (line2.Slope2() * this.Origin().x) + line2.YIntercept()));
}
if ((line2.Slope2() == Number.POSITIVE_INFINITY) || (line2.Slope2() == Number.NEGATIVE_INFINITY)) {
return(new Vector(line2.Origin().x, (this.Slope2() * line2.Origin().x) + this.YIntercept()));
}
var x = ((line2.YIntercept() - this.YIntercept()) / (this.Slope2() - line2.Slope2()));
var y = ((this.Slope2() * x) + this.YIntercept());
return(new Vector(x, y));
};
Line.prototype.Normal = function () {
if (!this._normal) {
this._normal = new Vector(-this.Slope().y, this.Slope().x);
this._normal.Normalize();
if ((this._normal.x < 0) && (this._normal.y < 0)) {
this._normal.x = -this._normal.x;
this._normal.y = -this._normal.y;
}
}
return(this._normal);
};
Line.prototype.toString = function () {
var s = (((("Origin (" + this.Origin().x) + ", ") + this.Origin().y) + ") ");
s = s + (((("Slope (" + this.Slope().x) + ", ") + this.Slope().y) + ") ");
s = s + (((("Normal (" + this.Normal().x) + ", ") + this.Normal().y) + ")");
return(s);
};
var name = "Crash Test";
var par = 3;
var sides = new Array(side1, side2, side3, side4, side5, side6, side7, side8);
var i = 0;
while (i < sides.length) {
sides[i].line_width = 7;
sides[i].shape = "line";
i++;
}
side1.angle = 0;
side2.angle = 90;
side3.angle = 0;
side4.angle = 90;
side5.angle = 76;
side6.angle = 76;
side7.angle = 101;
side8.angle = 0;
side8.line_width = 9;
addAcc({type:"drag", val:_root.default_drag, dir:0, mc:null});
addAcc({type:"ramp", val:158, dir:90, mc:ramp});
addAcc({type:"sand", val:200, dir:0, mc:sand1});
addAcc({type:"ice", val:-31, dir:0, mc:ice});
Symbol 157 MovieClip [green_guessing_game] Frame 1
function Vector(x, y) {
this.x = x;
this.y = y;
}
function Line(orig_x, orig_y, m_x, m_y) {
if (Math.abs(m_x) == Number.POSITIVE_INFINITY) {
m_x = 1;
m_y = 0;
} else if (Math.abs(m_y) == Number.POSITIVE_INFINITY) {
m_x = 0;
m_y = 1;
}
this._origin = new Vector(orig_x, orig_y);
this._slope = new Vector(m_x, m_y);
}
function HandleMultipleCollisions(collisions) {
var s1 = sides[collisions[0]];
var s2 = sides[collisions[1]];
_root.HandleInnerInnerCollision(s1, s2);
}
Vector.prototype.Add = function (v) {
return(new Vector(this.x + v.x, this.y + v.y));
};
Vector.prototype.Reverse = function () {
this.x = -this.x;
this.y = -this.y;
};
Vector.prototype.DotProduct = function (v) {
return((this.x * v.x) + (this.y * v.y));
};
Vector.prototype.Normalize = function () {
var total = Math.sqrt((this.x * this.x) + (this.y * this.y));
this.x = this.x / total;
this.y = this.y / total;
};
Vector.prototype.toString = function () {
return(((("<" + this.x) + ", ") + this.y) + ">");
};
Line.prototype.Origin = function () {
return(this._origin);
};
Line.prototype.Slope = function () {
return(this._slope);
};
Line.prototype.Slope2 = function () {
if (!this._slope2) {
this._slope2 = this._slope.y / this._slope.x;
}
return(this._slope2);
};
Line.prototype.YIntercept = function () {
if (!this._yintercept) {
this._yintercept = this._origin.y - (this._origin.x * (this._slope.y / this._slope.x));
}
return(this._yintercept);
};
Line.prototype.Intersection = function (line2) {
if (this.Slope2() == line2.Slope2()) {
return(null);
}
if ((this.Slope2() == Number.POSITIVE_INFINITY) || (this.Slope2() == Number.NEGATIVE_INFINITY)) {
return(new Vector(this.Origin().x, (line2.Slope2() * this.Origin().x) + line2.YIntercept()));
}
if ((line2.Slope2() == Number.POSITIVE_INFINITY) || (line2.Slope2() == Number.NEGATIVE_INFINITY)) {
return(new Vector(line2.Origin().x, (this.Slope2() * line2.Origin().x) + this.YIntercept()));
}
var x = ((line2.YIntercept() - this.YIntercept()) / (this.Slope2() - line2.Slope2()));
var y = ((this.Slope2() * x) + this.YIntercept());
return(new Vector(x, y));
};
Line.prototype.Normal = function () {
if (!this._normal) {
this._normal = new Vector(-this.Slope().y, this.Slope().x);
this._normal.Normalize();
if ((this._normal.x < 0) && (this._normal.y < 0)) {
this._normal.x = -this._normal.x;
this._normal.y = -this._normal.y;
}
}
return(this._normal);
};
Line.prototype.toString = function () {
var s = (((("Origin (" + this.Origin().x) + ", ") + this.Origin().y) + ") ");
s = s + (((("Slope (" + this.Slope().x) + ", ") + this.Slope().y) + ") ");
s = s + (((("Normal (" + this.Normal().x) + ", ") + this.Normal().y) + ")");
return(s);
};
var name = "Guessing Game";
var par = 3;
var sides = new Array(side1, side2, side3, side4, side5, side6, side7, side8);
var i = 0;
while (i < sides.length) {
sides[i].line_width = 7;
sides[i].shape = "line";
sides[i].angle = 0;
i++;
}
side2.angle = 90;
side4.angle = 90;
side6.angle = 90;
side8.angle = 90;
addAcc({type:"drag", val:_root.default_drag, dir:0, mc:null});
addAcc({type:"pit_wall", val:-510, dir:0, mc:pit.wall});
addAcc({type:"pit_floor", val:130, dir:0, mc:pit.floor});
addAcc({type:"sand", val:200, dir:0, mc:sand});
var a = (Math.round(Math.random() * 2) + 1);
var b = a;
var c = 0;
while (b == a) {
b = Math.round(Math.random() * 2) + 1;
}
c = 6 - (a + b);
addAcc({type:"cup_in", val:this["cup_out" + a], dir:0, mc:cup_in1});
addAcc({type:"cup_in", val:this["cup_out" + b], dir:0, mc:cup_in2});
addAcc({type:"cup_in", val:this["cup_out" + c], dir:0, mc:cup_in3});
addAcc({type:"cup_out", val:0, dir:-45, mc:cup_out1});
addAcc({type:"cup_out", val:0, dir:0, mc:cup_out2});
addAcc({type:"cup_out", val:0, dir:40, mc:cup_out3});
Symbol 161 MovieClip Frame 1
this.onEnterFrame = function () {
_rotation = (_rotation + 4);
};
Symbol 194 MovieClip [green_in_and_out] Frame 1
function Vector(x, y) {
this.x = x;
this.y = y;
}
function Line(orig_x, orig_y, m_x, m_y) {
if (Math.abs(m_x) == Number.POSITIVE_INFINITY) {
m_x = 1;
m_y = 0;
} else if (Math.abs(m_y) == Number.POSITIVE_INFINITY) {
m_x = 0;
m_y = 1;
}
this._origin = new Vector(orig_x, orig_y);
this._slope = new Vector(m_x, m_y);
}
function HandleMultipleCollisions(collisions) {
var s1 = sides[collisions[0]];
var s2 = sides[collisions[1]];
_root.HandleInnerInnerCollision(s1, s2);
}
Vector.prototype.Add = function (v) {
return(new Vector(this.x + v.x, this.y + v.y));
};
Vector.prototype.Reverse = function () {
this.x = -this.x;
this.y = -this.y;
};
Vector.prototype.DotProduct = function (v) {
return((this.x * v.x) + (this.y * v.y));
};
Vector.prototype.Normalize = function () {
var total = Math.sqrt((this.x * this.x) + (this.y * this.y));
this.x = this.x / total;
this.y = this.y / total;
};
Vector.prototype.toString = function () {
return(((("<" + this.x) + ", ") + this.y) + ">");
};
Line.prototype.Origin = function () {
return(this._origin);
};
Line.prototype.Slope = function () {
return(this._slope);
};
Line.prototype.Slope2 = function () {
if (!this._slope2) {
this._slope2 = this._slope.y / this._slope.x;
}
return(this._slope2);
};
Line.prototype.YIntercept = function () {
if (!this._yintercept) {
this._yintercept = this._origin.y - (this._origin.x * (this._slope.y / this._slope.x));
}
return(this._yintercept);
};
Line.prototype.Intersection = function (line2) {
if (this.Slope2() == line2.Slope2()) {
return(null);
}
if ((this.Slope2() == Number.POSITIVE_INFINITY) || (this.Slope2() == Number.NEGATIVE_INFINITY)) {
return(new Vector(this.Origin().x, (line2.Slope2() * this.Origin().x) + line2.YIntercept()));
}
if ((line2.Slope2() == Number.POSITIVE_INFINITY) || (line2.Slope2() == Number.NEGATIVE_INFINITY)) {
return(new Vector(line2.Origin().x, (this.Slope2() * line2.Origin().x) + this.YIntercept()));
}
var x = ((line2.YIntercept() - this.YIntercept()) / (this.Slope2() - line2.Slope2()));
var y = ((this.Slope2() * x) + this.YIntercept());
return(new Vector(x, y));
};
Line.prototype.Normal = function () {
if (!this._normal) {
this._normal = new Vector(-this.Slope().y, this.Slope().x);
this._normal.Normalize();
if ((this._normal.x < 0) && (this._normal.y < 0)) {
this._normal.x = -this._normal.x;
this._normal.y = -this._normal.y;
}
}
return(this._normal);
};
Line.prototype.toString = function () {
var s = (((("Origin (" + this.Origin().x) + ", ") + this.Origin().y) + ") ");
s = s + (((("Slope (" + this.Slope().x) + ", ") + this.Slope().y) + ") ");
s = s + (((("Normal (" + this.Normal().x) + ", ") + this.Normal().y) + ")");
return(s);
};
var name = "In and Out";
var par = 3;
var sides = new Array(side1, side2, side3, side4, side5, side6, side7, side8, side9, side10, side11, side12);
var i = 0;
while (i < sides.length) {
sides[i].line_width = 7;
sides[i].shape = "line";
sides[i].angle = 0;
i++;
}
side2.angle = 90;
side4.angle = 90;
side6.angle = 90;
side8.angle = 90;
side10.angle = 90;
side12.angle = 90;
addAcc({type:"drag", val:_root.default_drag, dir:0, mc:null});
addAcc({type:"sand", val:200, dir:0, mc:sand});
addAcc({type:"ramp", val:60, dir:180, mc:ramp});
addAcc({type:"blackhole", val:-1000, dir:0, mc:blackhole});
addAcc({type:"cup_in", val:cup_out, dir:0, mc:cup_in});
addAcc({type:"cup_out", val:0, dir:-27, mc:cup_out});
Symbol 208 MovieClip [green_sawtooths] Frame 1
function Vector(x, y) {
this.x = x;
this.y = y;
}
function Line(orig_x, orig_y, m_x, m_y) {
if (Math.abs(m_x) == Number.POSITIVE_INFINITY) {
m_x = 1;
m_y = 0;
} else if (Math.abs(m_y) == Number.POSITIVE_INFINITY) {
m_x = 0;
m_y = 1;
}
this._origin = new Vector(orig_x, orig_y);
this._slope = new Vector(m_x, m_y);
}
function HandleMultipleCollisions(collisions) {
var s1 = sides[collisions[0]];
var s2 = sides[collisions[1]];
_root.HandleInnerInnerCollision(s1, s2);
}
Vector.prototype.Add = function (v) {
return(new Vector(this.x + v.x, this.y + v.y));
};
Vector.prototype.Reverse = function () {
this.x = -this.x;
this.y = -this.y;
};
Vector.prototype.DotProduct = function (v) {
return((this.x * v.x) + (this.y * v.y));
};
Vector.prototype.Normalize = function () {
var total = Math.sqrt((this.x * this.x) + (this.y * this.y));
this.x = this.x / total;
this.y = this.y / total;
};
Vector.prototype.toString = function () {
return(((("<" + this.x) + ", ") + this.y) + ">");
};
Line.prototype.Origin = function () {
return(this._origin);
};
Line.prototype.Slope = function () {
return(this._slope);
};
Line.prototype.Slope2 = function () {
if (!this._slope2) {
this._slope2 = this._slope.y / this._slope.x;
}
return(this._slope2);
};
Line.prototype.YIntercept = function () {
if (!this._yintercept) {
this._yintercept = this._origin.y - (this._origin.x * (this._slope.y / this._slope.x));
}
return(this._yintercept);
};
Line.prototype.Intersection = function (line2) {
if (this.Slope2() == line2.Slope2()) {
return(null);
}
if ((this.Slope2() == Number.POSITIVE_INFINITY) || (this.Slope2() == Number.NEGATIVE_INFINITY)) {
return(new Vector(this.Origin().x, (line2.Slope2() * this.Origin().x) + line2.YIntercept()));
}
if ((line2.Slope2() == Number.POSITIVE_INFINITY) || (line2.Slope2() == Number.NEGATIVE_INFINITY)) {
return(new Vector(line2.Origin().x, (this.Slope2() * line2.Origin().x) + this.YIntercept()));
}
var x = ((line2.YIntercept() - this.YIntercept()) / (this.Slope2() - line2.Slope2()));
var y = ((this.Slope2() * x) + this.YIntercept());
return(new Vector(x, y));
};
Line.prototype.Normal = function () {
if (!this._normal) {
this._normal = new Vector(-this.Slope().y, this.Slope().x);
this._normal.Normalize();
if ((this._normal.x < 0) && (this._normal.y < 0)) {
this._normal.x = -this._normal.x;
this._normal.y = -this._normal.y;
}
}
return(this._normal);
};
Line.prototype.toString = function () {
var s = (((("Origin (" + this.Origin().x) + ", ") + this.Origin().y) + ") ");
s = s + (((("Slope (" + this.Slope().x) + ", ") + this.Slope().y) + ") ");
s = s + (((("Normal (" + this.Normal().x) + ", ") + this.Normal().y) + ")");
return(s);
};
var name = "Sawtooths";
var par = 2;
var sides = new Array(side1, side2, side3, side4);
var i = 0;
while (i < sides.length) {
sides[i].line_width = 7;
i++;
}
side1.shape = "line";
side1.angle = 0;
side2.shape = "line";
side2.angle = 90;
side3.shape = "line";
side3.angle = 0;
side4.shape = "line";
side4.angle = 90;
var acc = new Array();
acc[0] = new Object();
acc[0].type = "drag";
acc[0].val = _root.default_drag;
acc[0].dir = 0;
acc[0].mc = null;
acc[1] = new Object();
acc[1].type = "cone";
acc[1].val = 150;
acc[1].dir = 0;
acc[1].mc = cone1;
acc[2] = new Object();
acc[2].type = "cone";
acc[2].val = 250;
acc[2].dir = 0;
acc[2].mc = cone2;
acc[3] = new Object();
acc[3].type = "cone";
acc[3].val = 200;
acc[3].dir = 0;
acc[3].mc = cone3;
acc[4] = new Object();
acc[4].type = "cone";
acc[4].val = 250;
acc[4].dir = 0;
acc[4].mc = cone4;
acc[5] = new Object();
acc[5].type = "cone";
acc[5].val = 200;
acc[5].dir = 0;
acc[5].mc = cone5;
acc[6] = new Object();
acc[6].type = "cone";
acc[6].val = 150;
acc[6].dir = 0;
acc[6].mc = cone6;
acc[7] = new Object();
acc[7].type = "cone";
acc[7].val = 150;
acc[7].dir = 0;
acc[7].mc = cone7;
Symbol 219 MovieClip [green_craters] Frame 1
function Vector(x, y) {
this.x = x;
this.y = y;
}
function Line(orig_x, orig_y, m_x, m_y) {
if (Math.abs(m_x) == Number.POSITIVE_INFINITY) {
m_x = 1;
m_y = 0;
} else if (Math.abs(m_y) == Number.POSITIVE_INFINITY) {
m_x = 0;
m_y = 1;
}
this._origin = new Vector(orig_x, orig_y);
this._slope = new Vector(m_x, m_y);
}
function HandleMultipleCollisions(collisions) {
var s1 = sides[collisions[0]];
var s2 = sides[collisions[1]];
_root.HandleInnerInnerCollision(s1, s2);
}
Vector.prototype.Add = function (v) {
return(new Vector(this.x + v.x, this.y + v.y));
};
Vector.prototype.Reverse = function () {
this.x = -this.x;
this.y = -this.y;
};
Vector.prototype.DotProduct = function (v) {
return((this.x * v.x) + (this.y * v.y));
};
Vector.prototype.Normalize = function () {
var total = Math.sqrt((this.x * this.x) + (this.y * this.y));
this.x = this.x / total;
this.y = this.y / total;
};
Vector.prototype.toString = function () {
return(((("<" + this.x) + ", ") + this.y) + ">");
};
Line.prototype.Origin = function () {
return(this._origin);
};
Line.prototype.Slope = function () {
return(this._slope);
};
Line.prototype.Slope2 = function () {
if (!this._slope2) {
this._slope2 = this._slope.y / this._slope.x;
}
return(this._slope2);
};
Line.prototype.YIntercept = function () {
if (!this._yintercept) {
this._yintercept = this._origin.y - (this._origin.x * (this._slope.y / this._slope.x));
}
return(this._yintercept);
};
Line.prototype.Intersection = function (line2) {
if (this.Slope2() == line2.Slope2()) {
return(null);
}
if ((this.Slope2() == Number.POSITIVE_INFINITY) || (this.Slope2() == Number.NEGATIVE_INFINITY)) {
return(new Vector(this.Origin().x, (line2.Slope2() * this.Origin().x) + line2.YIntercept()));
}
if ((line2.Slope2() == Number.POSITIVE_INFINITY) || (line2.Slope2() == Number.NEGATIVE_INFINITY)) {
return(new Vector(line2.Origin().x, (this.Slope2() * line2.Origin().x) + this.YIntercept()));
}
var x = ((line2.YIntercept() - this.YIntercept()) / (this.Slope2() - line2.Slope2()));
var y = ((this.Slope2() * x) + this.YIntercept());
return(new Vector(x, y));
};
Line.prototype.Normal = function () {
if (!this._normal) {
this._normal = new Vector(-this.Slope().y, this.Slope().x);
this._normal.Normalize();
if ((this._normal.x < 0) && (this._normal.y < 0)) {
this._normal.x = -this._normal.x;
this._normal.y = -this._normal.y;
}
}
return(this._normal);
};
Line.prototype.toString = function () {
var s = (((("Origin (" + this.Origin().x) + ", ") + this.Origin().y) + ") ");
s = s + (((("Slope (" + this.Slope().x) + ", ") + this.Slope().y) + ") ");
s = s + (((("Normal (" + this.Normal().x) + ", ") + this.Normal().y) + ")");
return(s);
};
var name = "Craters of the Green";
var par = 3;
var sides = new Array(side1, side2, side3, side4);
var i = 0;
while (i < sides.length) {
sides[i].line_width = 7;
sides[i].shape = "line";
sides[i].angle = 0;
i++;
}
side2.angle = 90;
side4.angle = 90;
addAcc({type:"drag", val:_root.default_drag, dir:0, mc:null});
addAcc({type:"pit_wall", val:-420, dir:0, mc:pit1.wall});
addAcc({type:"pit_wall", val:-430, dir:0, mc:pit2.wall});
addAcc({type:"pit_wall", val:-510, dir:0, mc:pit3.wall});
addAcc({type:"pit_wall", val:-400, dir:0, mc:pit4.wall});
addAcc({type:"pit_wall", val:-510, dir:0, mc:pit5.wall});
addAcc({type:"pit_wall", val:-430, dir:0, mc:pit6.wall});
addAcc({type:"pit_wall", val:-420, dir:0, mc:pit7.wall});
addAcc({type:"pit_wall", val:-400, dir:0, mc:pit8.wall});
addAcc({type:"pit_floor", val:130, dir:0, mc:pit1.floor});
addAcc({type:"pit_floor", val:130, dir:0, mc:pit2.floor});
addAcc({type:"pit_floor", val:130, dir:0, mc:pit3.floor});
addAcc({type:"pit_floor", val:130, dir:0, mc:pit4.floor});
addAcc({type:"pit_floor", val:130, dir:0, mc:pit5.floor});
addAcc({type:"pit_floor", val:130, dir:0, mc:pit6.floor});
addAcc({type:"pit_floor", val:130, dir:0, mc:pit7.floor});
addAcc({type:"pit_floor", val:130, dir:0, mc:pit8.floor});
Symbol 247 MovieClip [green_serpentine] Frame 1
function Vector(x, y) {
this.x = x;
this.y = y;
}
function Line(orig_x, orig_y, m_x, m_y) {
if (Math.abs(m_x) == Number.POSITIVE_INFINITY) {
m_x = 1;
m_y = 0;
} else if (Math.abs(m_y) == Number.POSITIVE_INFINITY) {
m_x = 0;
m_y = 1;
}
this._origin = new Vector(orig_x, orig_y);
this._slope = new Vector(m_x, m_y);
}
function HandleMultipleCollisions(collisions) {
var s1 = sides[collisions[0]];
var s2 = sides[collisions[1]];
_root.HandleInnerInnerCollision(s1, s2);
}
Vector.prototype.Add = function (v) {
return(new Vector(this.x + v.x, this.y + v.y));
};
Vector.prototype.Reverse = function () {
this.x = -this.x;
this.y = -this.y;
};
Vector.prototype.DotProduct = function (v) {
return((this.x * v.x) + (this.y * v.y));
};
Vector.prototype.Normalize = function () {
var total = Math.sqrt((this.x * this.x) + (this.y * this.y));
this.x = this.x / total;
this.y = this.y / total;
};
Vector.prototype.toString = function () {
return(((("<" + this.x) + ", ") + this.y) + ">");
};
Line.prototype.Origin = function () {
return(this._origin);
};
Line.prototype.Slope = function () {
return(this._slope);
};
Line.prototype.Slope2 = function () {
if (!this._slope2) {
this._slope2 = this._slope.y / this._slope.x;
}
return(this._slope2);
};
Line.prototype.YIntercept = function () {
if (!this._yintercept) {
this._yintercept = this._origin.y - (this._origin.x * (this._slope.y / this._slope.x));
}
return(this._yintercept);
};
Line.prototype.Intersection = function (line2) {
if (this.Slope2() == line2.Slope2()) {
return(null);
}
if ((this.Slope2() == Number.POSITIVE_INFINITY) || (this.Slope2() == Number.NEGATIVE_INFINITY)) {
return(new Vector(this.Origin().x, (line2.Slope2() * this.Origin().x) + line2.YIntercept()));
}
if ((line2.Slope2() == Number.POSITIVE_INFINITY) || (line2.Slope2() == Number.NEGATIVE_INFINITY)) {
return(new Vector(line2.Origin().x, (this.Slope2() * line2.Origin().x) + this.YIntercept()));
}
var x = ((line2.YIntercept() - this.YIntercept()) / (this.Slope2() - line2.Slope2()));
var y = ((this.Slope2() * x) + this.YIntercept());
return(new Vector(x, y));
};
Line.prototype.Normal = function () {
if (!this._normal) {
this._normal = new Vector(-this.Slope().y, this.Slope().x);
this._normal.Normalize();
if ((this._normal.x < 0) && (this._normal.y < 0)) {
this._normal.x = -this._normal.x;
this._normal.y = -this._normal.y;
}
}
return(this._normal);
};
Line.prototype.toString = function () {
var s = (((("Origin (" + this.Origin().x) + ", ") + this.Origin().y) + ") ");
s = s + (((("Slope (" + this.Slope().x) + ", ") + this.Slope().y) + ") ");
s = s + (((("Normal (" + this.Normal().x) + ", ") + this.Normal().y) + ")");
return(s);
};
var name = "Serpentine";
var par = 3;
var sides = new Array(side1, side2, side3, side4, side5, side6, side7, side8, side9, side10);
var i = 0;
while (i < sides.length) {
sides[i].line_width = 7;
sides[i].shape = "line";
sides[i].angle = 0;
i++;
}
side2.shape = "circle";
side2.h = side2._x - (side2._width / 2);
side2.k = side2._y + (side2._height / 2);
side2.radius = side2._width;
side8.shape = "circle";
side8.h = side8._x + (side8._width / 2);
side8.k = side8._y - (side8._height / 2);
side8.radius = side8._width;
side3.angle = 90;
side5.angle = 90;
side7.angle = 90;
side10.angle = 90;
addAcc({type:"drag", val:_root.default_drag, dir:0, mc:null});
addAcc({type:"pit_wall", val:-510, dir:0, mc:pit1.wall});
addAcc({type:"pit_floor", val:130, dir:0, mc:pit1.floor});
addAcc({type:"pit_wall", val:-430, dir:0, mc:pit2.wall});
addAcc({type:"pit_floor", val:130, dir:0, mc:pit2.floor});
addAcc({type:"blackhole", val:-1000, dir:0, mc:blackhole});
addAcc({type:"sand", val:100, dir:0, mc:sand1});
addAcc({type:"sand", val:100, dir:0, mc:sand2});
Symbol 250 MovieClip Frame 1
var component = _parent;
component.registerSkinElement(track_mc, "scrollTrack");
Symbol 251 MovieClip [FScrollBarSymbol] Frame 1
#initclip 2
FScrollBarClass = function () {
if (this._height == 4) {
return(undefined);
}
this.init();
this.minPos = (this.maxPos = (this.pageSize = (this.largeScroll = 0)));
this.smallScroll = 1;
this.width = (this.horizontal ? (this._width) : (this._height));
this._xscale = (this._yscale = 100);
this.setScrollPosition(0);
this.tabEnabled = false;
if (this._targetInstanceName.length > 0) {
this.setScrollTarget(this._parent[this._targetInstanceName]);
}
this.tabChildren = false;
this.setSize(this.width);
};
FScrollBarClass.prototype = new FUIComponentClass();
FScrollBarClass.prototype.setHorizontal = function (flag) {
if (this.horizontal && (!flag)) {
this._xscale = 100;
this._rotation = 0;
} else if (flag && (!this.horizontal)) {
this._xscale = -100;
this._rotation = -90;
}
this.horizontal = flag;
};
FScrollBarClass.prototype.setScrollProperties = function (pSize, mnPos, mxPos) {
if (!this.enable) {
return(undefined);
}
this.pageSize = pSize;
this.minPos = Math.max(mnPos, 0);
this.maxPos = Math.max(mxPos, 0);
this.scrollPosition = Math.max(this.minPos, this.scrollPosition);
this.scrollPosition = Math.min(this.maxPos, this.scrollPosition);
if ((this.maxPos - this.minPos) <= 0) {
this.scrollThumb_mc.removeMovieClip();
this.upArrow_mc.gotoAndStop(3);
this.downArrow_mc.gotoAndStop(3);
this.downArrow_mc.onPress = (this.downArrow_mc.onRelease = (this.downArrow_mc.onDragOut = null));
this.upArrow_mc.onPress = (this.upArrow_mc.onRelease = (this.upArrow_mc.onDragOut = null));
this.scrollTrack_mc.onPress = (this.scrollTrack_mc.onRelease = null);
this.scrollTrack_mc.onDragOut = (this.scrollTrack_mc.onRollOut = null);
this.scrollTrack_mc.useHandCursor = false;
} else {
var tmp = this.getScrollPosition();
this.upArrow_mc.gotoAndStop(1);
this.downArrow_mc.gotoAndStop(1);
this.upArrow_mc.onPress = (this.upArrow_mc.onDragOver = this.startUpScroller);
this.upArrow_mc.onRelease = (this.upArrow_mc.onDragOut = this.stopScrolling);
this.downArrow_mc.onPress = (this.downArrow_mc.onDragOver = this.startDownScroller);
this.downArrow_mc.onRelease = (this.downArrow_mc.onDragOut = this.stopScrolling);
this.scrollTrack_mc.onPress = (this.scrollTrack_mc.onDragOver = this.startTrackScroller);
this.scrollTrack_mc.onRelease = this.stopScrolling;
this.scrollTrack_mc.onDragOut = this.stopScrolling;
this.scrollTrack_mc.onRollOut = this.stopScrolling;
this.scrollTrack_mc.useHandCursor = false;
this.attachMovie("ScrollThumb", "scrollThumb_mc", 3);
this.scrollThumb_mc._x = 0;
this.scrollThumb_mc._y = this.upArrow_mc._height;
this.scrollThumb_mc.onPress = this.startDragThumb;
this.scrollThumb_mc.controller = this;
this.scrollThumb_mc.onRelease = (this.scrollThumb_mc.onReleaseOutside = this.stopDragThumb);
this.scrollThumb_mc.useHandCursor = false;
this.thumbHeight = (this.pageSize / ((this.maxPos - this.minPos) + this.pageSize)) * this.trackSize;
this.thumbMid_mc = this.scrollThumb_mc.mc_sliderMid;
this.thumbTop_mc = this.scrollThumb_mc.mc_sliderTop;
this.thumbBot_mc = this.scrollThumb_mc.mc_sliderBot;
this.thumbHeight = Math.max(this.thumbHeight, 6);
this.midHeight = (this.thumbHeight - this.thumbTop_mc._height) - this.thumbBot_mc._height;
this.thumbMid_mc._yScale = (this.midHeight * 100) / this.thumbMid_mc._height;
this.thumbMid_mc._y = this.thumbTop_mc._height;
this.thumbBot_mc._y = this.thumbTop_mc._height + this.midHeight;
this.scrollTop = this.scrollThumb_mc._y;
this.trackHeight = this.trackSize - this.thumbHeight;
this.scrollBot = this.trackHeight + this.scrollTop;
tmp = Math.min(tmp, this.maxPos);
this.setScrollPosition(Math.max(tmp, this.minPos));
}
};
FScrollBarClass.prototype.getScrollPosition = function () {
return(this.scrollPosition);
};
FScrollBarClass.prototype.setScrollPosition = function (pos) {
this.scrollPosition = pos;
if (this.scrollThumb_mc != undefined) {
pos = Math.min(pos, this.maxPos);
pos = Math.max(pos, this.minPos);
}
this.scrollThumb_mc._y = (((pos - this.minPos) * this.trackHeight) / (this.maxPos - this.minPos)) + this.scrollTop;
this.executeCallBack();
};
FScrollBarClass.prototype.setLargeScroll = function (lScroll) {
this.largeScroll = lScroll;
};
FScrollBarClass.prototype.setSmallScroll = function (sScroll) {
this.smallScroll = sScroll;
};
FScrollBarClass.prototype.setEnabled = function (enabledFlag) {
var wasEnabled = this.enable;
if (enabledFlag && (!wasEnabled)) {
this.enable = enabledFlag;
if (this.textField != undefined) {
this.setScrollTarget(this.textField);
} else {
this.setScrollProperties(this.pageSize, this.cachedMinPos, this.cachedMaxPos);
this.setScrollPosition(this.cachedPos);
}
this.clickFilter = undefined;
} else if ((!enabledFlag) && (wasEnabled)) {
this.textField.removeListener(this);
this.cachedPos = this.getScrollPosition();
this.cachedMinPos = this.minPos;
this.cachedMaxPos = this.maxPos;
if (this.clickFilter == undefined) {
this.setScrollProperties(this.pageSize, 0, 0);
} else {
this.clickFilter = true;
}
this.enable = enabledFlag;
}
};
FScrollBarClass.prototype.setSize = function (hgt) {
if (this._height == 1) {
return(undefined);
}
this.width = hgt;
this.scrollTrack_mc._yscale = 100;
this.scrollTrack_mc._yscale = (100 * this.width) / this.scrollTrack_mc._height;
if (this.upArrow_mc == undefined) {
this.attachMovie("UpArrow", "upArrow_mc", 1);
this.attachMovie("DownArrow", "downArrow_mc", 2);
this.downArrow_mc.controller = (this.upArrow_mc.controller = this);
this.upArrow_mc.useHandCursor = (this.downArrow_mc.useHandCursor = false);
this.upArrow_mc._x = (this.upArrow_mc._y = 0);
this.downArrow_mc._x = 0;
}
this.scrollTrack_mc.controller = this;
this.downArrow_mc._y = this.width - this.downArrow_mc._height;
this.trackSize = this.width - (2 * this.downArrow_mc._height);
if (this.textField != undefined) {
this.onTextChanged();
} else {
this.setScrollProperties(this.pageSize, this.minPos, this.maxPos);
}
};
FScrollBarClass.prototype.scrollIt = function (inc, mode) {
var delt = this.smallScroll;
if (inc != "one") {
delt = ((this.largeScroll == 0) ? (this.pageSize) : (this.largeScroll));
}
var newPos = (this.getScrollPosition() + (mode * delt));
if (newPos > this.maxPos) {
newPos = this.maxPos;
} else if (newPos < this.minPos) {
newPos = this.minPos;
}
this.setScrollPosition(newPos);
};
FScrollBarClass.prototype.startDragThumb = function () {
this.lastY = this._ymouse;
this.onMouseMove = this.controller.dragThumb;
};
FScrollBarClass.prototype.dragThumb = function () {
this.scrollMove = this._ymouse - this.lastY;
this.scrollMove = this.scrollMove + this._y;
if (this.scrollMove < this.controller.scrollTop) {
this.scrollMove = this.controller.scrollTop;
} else if (this.scrollMove > this.controller.scrollBot) {
this.scrollMove = this.controller.scrollBot;
}
this._y = this.scrollMove;
var c = this.controller;
c.scrollPosition = Math.round(((c.maxPos - c.minPos) * (this._y - c.scrollTop)) / c.trackHeight) + c.minPos;
this.controller.isScrolling = true;
updateAfterEvent();
this.controller.executeCallBack();
};
FScrollBarClass.prototype.stopDragThumb = function () {
this.controller.isScrolling = false;
this.onMouseMove = null;
};
FScrollBarClass.prototype.startTrackScroller = function () {
this.controller.trackScroller();
this.controller.scrolling = setInterval(this.controller, "scrollInterval", 500, "page", -1);
};
FScrollBarClass.prototype.scrollInterval = function (inc, mode) {
clearInterval(this.scrolling);
if (inc == "page") {
this.trackScroller();
} else {
this.scrollIt(inc, mode);
}
this.scrolling = setInterval(this, "scrollInterval", 35, inc, mode);
};
FScrollBarClass.prototype.trackScroller = function () {
if ((this.scrollThumb_mc._y + this.thumbHeight) < this._ymouse) {
this.scrollIt("page", 1);
} else if (this.scrollThumb_mc._y > this._ymouse) {
this.scrollIt("page", -1);
}
};
FScrollBarClass.prototype.stopScrolling = function () {
this.controller.downArrow_mc.gotoAndStop(1);
this.controller.upArrow_mc.gotoAndStop(1);
clearInterval(this.controller.scrolling);
};
FScrollBarClass.prototype.startUpScroller = function () {
this.controller.upArrow_mc.gotoAndStop(2);
this.controller.scrollIt("one", -1);
this.controller.scrolling = setInterval(this.controller, "scrollInterval", 500, "one", -1);
};
FScrollBarClass.prototype.startDownScroller = function () {
this.controller.downArrow_mc.gotoAndStop(2);
this.controller.scrollIt("one", 1);
this.controller.scrolling = setInterval(this.controller, "scrollInterval", 500, "one", 1);
};
FScrollBarClass.prototype.setScrollTarget = function (tF) {
if (tF == undefined) {
this.textField.removeListener(this);
delete this.textField[(this.horizontal ? "hScroller" : "vScroller")];
if ((this.textField.hScroller != undefined) && (this.textField.vScroller != undefined)) {
this.textField.unwatch("text");
this.textField.unwatch("htmltext");
}
}
this.textField = undefined;
if (!(tF instanceof TextField)) {
return(undefined);
}
this.textField = tF;
this.textField[(this.horizontal ? "hScroller" : "vScroller")] = this;
this.onTextChanged();
this.onChanged = function () {
this.onTextChanged();
};
this.onScroller = function () {
if (!this.isScrolling) {
if (!this.horizontal) {
this.setScrollPosition(this.textField.scroll);
} else {
this.setScrollPosition(this.textField.hscroll);
}
}
};
this.textField.addListener(this);
this.textField.watch("text", this.callback);
this.textField.watch("htmlText", this.callback);
};
FScrollBarClass.prototype.callback = function (prop, oldVal, newVal) {
clearInterval(this.hScroller.synchScroll);
clearInterval(this.vScroller.synchScroll);
this.hScroller.synchScroll = setInterval(this.hScroller, "onTextChanged", 50);
this.vScroller.synchScroll = setInterval(this.vScroller, "onTextChanged", 50);
return(newVal);
};
FScrollBarClass.prototype.onTextChanged = function () {
if ((!this.enable) || (this.textField == undefined)) {
return(undefined);
}
clearInterval(this.synchScroll);
if (this.horizontal) {
var pos = this.textField.hscroll;
this.setScrollProperties(this.textField._width, 0, this.textField.maxhscroll);
this.setScrollPosition(Math.min(pos, this.textField.maxhscroll));
} else {
var pos = this.textField.scroll;
var pageSize = (this.textField.bottomScroll - this.textField.scroll);
this.setScrollProperties(pageSize, 1, this.textField.maxscroll);
this.setScrollPosition(Math.min(pos, this.textField.maxscroll));
}
};
FScrollBarClass.prototype.executeCallBack = function () {
if (this.textField == undefined) {
super.executeCallBack();
} else if (this.horizontal) {
this.textField.hscroll = this.getScrollPosition();
} else {
this.textField.scroll = this.getScrollPosition();
}
};
Object.registerClass("FScrollBarSymbol", FScrollBarClass);
#endinitclip
Symbol 259 MovieClip Frame 1
stop();
function Vector(x, y) {
this.x = x;
this.y = y;
}
function Line(orig_x, orig_y, m_x, m_y) {
if (Math.abs(m_x) == Number.POSITIVE_INFINITY) {
m_x = 1;
m_y = 0;
} else if (Math.abs(m_y) == Number.POSITIVE_INFINITY) {
m_x = 0;
m_y = 1;
}
this._origin = new Vector(orig_x, orig_y);
this._slope = new Vector(m_x, m_y);
}
function SetGolfer() {
var xdiff = (_root._xmouse - _root.ball._x);
var ydiff = (-(_root._ymouse - _root.ball._y));
var rad = Math.atan2(ydiff, xdiff);
SetPosition(_root.ball._x, _root.ball._y, (rad * 180) / Math.PI);
SetArrow(_root.ball._x, _root.ball._y, _root._xmouse, _root._ymouse, (rad * 180) / Math.PI);
if ((((!putting) && (!_root.ball.ball_in_motion)) && (!_root.BallIsInCup())) && (!_root.ball.can_be_placed)) {
_root.arrow._visible = true;
}
}
function SetPosition(ballx, bally, dir) {
if (((!putting) && (!_root.ball.ball_in_motion)) && (!_root.BallIsInCup())) {
this._alpha = 100;
this.direction = dir;
this._rotation = this.default_direction - this.direction;
this._x = ballx - (this.radius * Math.sin(deg2rad(this.direction)));
this._y = bally - (this.radius * Math.cos(deg2rad(this.direction)));
}
}
function SetArrow(ballx, bally, xmouse, ymouse, dir) {
if (((!putting) && (!_root.ball.ball_in_motion)) && (!_root.BallIsInCup())) {
var a = _root.arrow;
var xdiff = ((xmouse - ballx) + arrow_gap);
var ydiff = (-((ymouse - bally) + arrow_gap));
var diff = Math.sqrt((xdiff * xdiff) + (ydiff * ydiff));
if ((diff - arrow_gap) < (2 * default_arrow_radius)) {
a._xscale = 100 * ((diff - arrow_gap) / (2 * default_arrow_radius));
} else {
a._xscale = 100;
}
var r = CalculateArrowRadius();
a.direction = dir;
a._rotation = -dir;
a._x = ballx + ((r + arrow_gap) * Math.cos(deg2rad(dir)));
a._y = bally - ((r + arrow_gap) * Math.sin(deg2rad(dir)));
}
}
function CalculateArrowRadius() {
_root.arrow._rotation = 0;
var r = (_root.arrow._width / 2);
_root.arrow._rotation = -_root.arrow.direction;
return(r);
}
function HitBall() {
if (can_move) {
can_move = false;
var b = _root.ball;
_root.current_strokes++;
_root.green_info.strokes = _root.current_strokes;
b.dir = this.direction;
b.velocity = min_power + (((max_power - min_power) * _root.arrow._xscale) * 0.01);
b.ball_in_motion = true;
_root.arrow._visible = false;
var back_front_slope = new Vector(_root.x_component(1, this.direction), -_root.y_component(1, this.direction));
var left_right_slope = new Vector(_root.x_component(1, this.direction - 90), -_root.y_component(1, this.direction - 90));
backline = new Line(this._x + _root.x_component(-35, this.direction - 90), this._y - _root.y_component(-35, this.direction - 90), back_front_slope.x, back_front_slope.y);
frontline = new Line(this._x + _root.x_component(16, this.direction - 90), this._y - _root.y_component(16, this.direction - 90), back_front_slope.x, back_front_slope.y);
rightline = new Line(this._x + _root.x_component(29, this.direction), this._y - _root.y_component(29, this.direction), left_right_slope.x, left_right_slope.y);
leftline = new Line(this._x + _root.x_component(-25, this.direction), this._y - _root.y_component(-25, this.direction), left_right_slope.x, left_right_slope.y);
}
}
function deg2rad(deg) {
return((Math.PI/180) * deg);
}
Vector.prototype.Add = function (v) {
return(new Vector(this.x + v.x, this.y + v.y));
};
Vector.prototype.Reverse = function () {
this.x = -this.x;
this.y = -this.y;
};
Vector.prototype.DotProduct = function (v) {
return((this.x * v.x) + (this.y * v.y));
};
Vector.prototype.Normalize = function () {
var total = Math.sqrt((this.x * this.x) + (this.y * this.y));
this.x = this.x / total;
this.y = this.y / total;
};
Vector.prototype.toString = function () {
return(((("<" + this.x) + ", ") + this.y) + ">");
};
Line.prototype.Origin = function () {
return(this._origin);
};
Line.prototype.Slope = function () {
return(this._slope);
};
Line.prototype.Slope2 = function () {
if (!this._slope2) {
this._slope2 = this._slope.y / this._slope.x;
}
return(this._slope2);
};
Line.prototype.YIntercept = function () {
if (!this._yintercept) {
this._yintercept = this._origin.y - (this._origin.x * (this._slope.y / this._slope.x));
}
return(this._yintercept);
};
Line.prototype.Intersection = function (line2) {
if (this.Slope2() == line2.Slope2()) {
return(null);
}
if ((this.Slope2() == Number.POSITIVE_INFINITY) || (this.Slope2() == Number.NEGATIVE_INFINITY)) {
return(new Vector(this.Origin().x, (line2.Slope2() * this.Origin().x) + line2.YIntercept()));
}
if ((line2.Slope2() == Number.POSITIVE_INFINITY) || (line2.Slope2() == Number.NEGATIVE_INFINITY)) {
return(new Vector(line2.Origin().x, (this.Slope2() * line2.Origin().x) + this.YIntercept()));
}
var x = ((line2.YIntercept() - this.YIntercept()) / (this.Slope2() - line2.Slope2()));
var y = ((this.Slope2() * x) + this.YIntercept());
return(new Vector(x, y));
};
Line.prototype.Normal = function () {
if (!this._normal) {
this._normal = new Vector(-this.Slope().y, this.Slope().x);
this._normal.Normalize();
if ((this._normal.x < 0) && (this._normal.y < 0)) {
this._normal.x = -this._normal.x;
this._normal.y = -this._normal.y;
}
}
return(this._normal);
};
Line.prototype.toString = function () {
var s = (((("Origin (" + this.Origin().x) + ", ") + this.Origin().y) + ") ");
s = s + (((("Slope (" + this.Slope().x) + ", ") + this.Slope().y) + ") ");
s = s + (((("Normal (" + this.Normal().x) + ", ") + this.Normal().y) + ")");
return(s);
};
var theta = 0.150371428007135;
var radius = 33.3766385365573;
var default_direction = theta;
var direction = 0;
var arrow_gap = 5;
var default_arrow_radius = CalculateArrowRadius();
var max_power = 180;
var min_power = 50;
Symbol 259 MovieClip Frame 2
putting = true;
Symbol 259 MovieClip Frame 13
HitBall();
Symbol 259 MovieClip Frame 40
stop();
putting = false;
SetGolfer();
Symbol 273 MovieClip Frame 1
var radius = (_width / 2);
var xy_dist_45 = _root.x_component(this.radius, 45);
var x_dist_60 = _root.x_component(this.radius, 60);
var y_dist_60 = _root.y_component(this.radius, 60);
Symbol 361 Button
on (press) {
_root.scorecard.show = false;
_root.scorecard._visible = false;
_root.NextGreen();
}
Symbol 383 MovieClip Frame 1
closeX.onPress = function () {
_root.instructions._visible = false;
};
var help_msg = "";
help_msg = help_msg + "<b>Objective</b>\n";
help_msg = help_msg + "Have the golfer sink the putt for each green in the fewest number of shots.\n\n";
help_msg = help_msg + "<b>Aiming, Power, and Putting</b>\n";
help_msg = help_msg + "Use the mouse to direct the golfer where to putt the golf ball. An arrow ";
help_msg = help_msg + "will follow the mouse as you move it around on the green, helping you align ";
help_msg = help_msg + "your shot. The length of the arrow determines how hard the golfer will ";
help_msg = help_msg + "putt. Reduce the length of the arrow by moving the mouse closer to the ";
help_msg = help_msg + "golf ball. Once the shot is aligned and the strength set, single click the ";
help_msg = help_msg + "mouse to make the golfer putt.\n\n";
help_msg = help_msg + "<b>Obstacles</b>\n";
help_msg = help_msg + "Each green has one or more obstacles on it to make sinking the putt more ";
help_msg = help_msg + "difficult. The list of obstacles is described below:\n\n";
help_msg = help_msg + "- <b>Sand</b> traps cause the ball to slow down very quickly and are hard to get out of.\n";
help_msg = help_msg + "- <b>Ice</b> lowers the green's surface friction and allows the ball to travel further with less power.\n";
help_msg = help_msg + "- <b>Bridges</b> allow the ball to travel over surfaces with much less friction and can also help avoid other obstacles. To get on a bridge the ball must enter the bridge at either end point. The bridge will turn transparent if the ball hits it but the ball isn't already on the bridge.\n";
help_msg = help_msg + "- <b>Black Holes</b> will attract the ball when the ball gets close enough. If the ball passes too closely to the black hole, the ball will disappear and reappear elsewhere on the green. If the ball has enough velocity, it's path may only be warped by the black hole without actually getting drawn into it.\n";
help_msg = help_msg + "- <b>Cones</b> will push the ball away from the center of the cone.\n";
help_msg = help_msg + "- <b>Pits</b> will attract the ball into the bottom of the pit. Once the ball is at the bottom of a pit, it is significantly harder to hit the ball than on the green.\n";
help_msg = help_msg + "- <b>Pegs</b> and <b>Interior Walls</b> will deflect the ball accordingly.\n\n";
help_msg = help_msg + "<b>Tips and Tricks</b>\n";
help_msg = help_msg + "- Use black holes to warp the ball's path in order to allow the ball to go around tight corners.\n";
help_msg = help_msg + "- Use pits in a similar fashion as black holes, using the sides of the pit to curve the ball's path.\n";
help_text.html = true;
help_text.htmlText = help_msg;
Instance of Symbol 251 MovieClip [FScrollBarSymbol] in Symbol 383 MovieClip Frame 1
//component parameters
onClipEvent (initialize) {
_targetInstanceName = "help_text";
horizontal = false;
}
Symbol 399 MovieClip Frame 1
play_golf.onPress = function () {
_root.splash_page._visible = false;
_root.StartGame();
};
Symbol 409 MovieClip Frame 1
_visible = false;
play_again.onPress = function () {
var prev_green = _root["green" + _root.current_green];
prev_green.removeMovieClip();
_root.scorecard.show = false;
_root.scorecard._visible = false;
_root.scorecard.next_hole._visible = true;
_root.in_current_green = -1;
_root.in_strokes = "";
_root.current_green = -1;
_root.current_strokes = 0;
_root.strokes = new Array();
_root.pars = new Array();
_root.current_green_depth = 1;
_root.par_total = 0;
_root.stroke_total = 0;
_root.scorecard._visible = false;
_root.instructions._visible = false;
_root.splash_page._visible = false;
_root.golfer._visible = false;
_visible = false;
_root.StartGame();
};
full_version.onPress = function () {
getURL ("http://www.possumstew.com/xit");
};