Frame 1
var myGameData = SharedObject.getLocal("myGameData");
if (myGameData.data.savedHighScore) {
var highScore = myGameData.data.savedHighScore;
}
loadingbar.onEnterFrame = function () {
if (_root.getBytesLoaded() >= _root.getBytesTotal()) {
_root.gotoAndPlay("init");
} else {
this._xscale = (_root.getBytesLoaded() / _root.getBytesTotal()) * 100;
}
};
stop();
Frame 5
function getScore(darthit_x, darthit_y) {
var _local11 = _root.dart_board._x;
var _local9 = _root.dart_board._y;
var _local12 = 20;
var _local14 = 60;
var _local13 = 80;
var _local10 = 100;
var _local8 = 120;
var _local3 = new Array(20, 1, 18, 4, 13, 6, 10, 15, 2, 17, 3, 19, 7, 16, 8, 11, 14, 9, 12, 5, 20);
var _local7 = darthit_x - _local11;
var _local6 = darthit_y - _local9;
var _local2 = Math.sqrt(Math.pow(Math.abs(_local7), 2) + Math.pow(Math.abs(_local6), 2));
var _local5 = ((Math.atan2(_local6, _local7) * 180) / Math.PI) + 90;
if (_local5 < 0) {
_local5 = 360 + _local5;
}
var _local4 = Math.floor((_local5 + 9) / 18);
if (_local2 <= _local12) {
pointvalue = 25;
} else if (_local2 <= _local14) {
var pointvalue = (_local3[_local4] * 1);
} else if (_local2 <= _local13) {
var pointvalue = (_local3[_local4] * 3);
} else if (_local2 <= _local10) {
var pointvalue = (_local3[_local4] * 1);
} else if (_local2 <= _local8) {
var pointvalue = (_local3[_local4] * 2);
} else {
var pointvalue = 0;
}
return(pointvalue);
}
var Snd_alert_good = new Sound();
Snd_alert_good.attachSound("alert_good");
var Snd_alert_bad = new Sound();
Snd_alert_bad.attachSound("alert_bad");
var perspective_scalefactor = 0.998;
var scale = 100;
var max_dist = 500;
var scalearray = new Array();
var dist = 0;
while (dist <= max_dist) {
scale = scale * perspective_scalefactor;
scalearray.push(scale);
dist++;
}
stop();
var boardDist = 400;
var controller = new Object();
controller.aim = function () {
this._x = _xmouse;
this._y = _ymouse;
};
controller.shoot_click = function () {
this.startTime = getTimer();
this.start_x = _xmouse;
this.start_y = _ymouse;
};
controller.shoot_release = function () {
this.endTime = getTimer();
this.end_x = _xmouse;
this.end_y = _ymouse;
var _local6 = Math.abs(this.start_x - this.end_x) + 1;
var _local5 = Math.abs(this.start_y - this.end_y) + 1;
var _local4 = Math.sqrt(Math.pow(_local6, 2) + Math.pow(_local5, 2));
var _local7 = this.endTime - this.startTime;
var _local3 = ((_local4 / _local7) * 10) - 10;
duplicateMovieClip (this, "dart_hit", 1);
_root.game.dart_hit.fall = 7;
_root.game.dart_hit.speed = 40 + _local3;
_root.game.dart_hit.lift = _root.game.dart_hit.speed * 0.8;
_root.game.dart_hit.lateraloffset = (this.start_x - this.end_x) * 0.15;
_root.game.dart_hit.pos_x = this.end_x;
_root.game.dart_hit.pos_y = this.end_y;
_root.game.dart_hit.pos_z = 0;
if (this.start_y > this.end_y) {
_root.game.dart_hit.lateraloffset = _root.game.dart_hit.lateraloffset * -1;
}
_root.game.dart_hit.onEnterFrame = controller.fly;
_root.game.dart._visible = false;
_root.game.dart.onMouseUp = null;
};
controller.fly = function () {
this.pos_x = this.pos_x + this.lateraloffset;
this.pos_y = this.pos_y - this.lift;
this.pos_z = this.pos_z + this.speed;
var _local4 = _root.scalearray[Math.round(this.pos_z)];
this._xscale = _local4;
this._yscale = _local4;
this._x = this.pos_x;
this._y = this.pos_y * (_local4 * 0.01);
this.lift = this.lift - this.fall;
this.speed = this.speed * 0.96;
if ((this.pos_z >= _root.boardDist) || (this.pos_y >= 2000)) {
this.gotoAndPlay("hit");
var _local3 = _root.getScore(this._x, this._y);
_root.game.attachMovie("point_display", "point_display", 3);
_root.game.point_display._x = this._x;
_root.game.point_display._y = this._y;
_root.game.point_display.pointvalue = _local3;
_root.throws++;
if ((_root.score - _local3) == 0) {
_root.score = 0;
_root.alerttext = "CLOSED! YOU GOT IT!!";
_root.alert.gotoAndPlay(2);
_root.Snd_alert_good.start();
var intervalID = setInterval(function () {
gotoAndPlay ("game_over");
clearInterval(intervalID);
}, 1500);
} else if ((_root.score - _local3) < 0) {
_root.alerttext = "BUST! (MUST CLOSE OUT EXACTLY)";
_root.alert.gotoAndPlay(2);
_root.Snd_alert_bad.start(0, 2);
_root.game.dart._visible = true;
_root.game.dart.onMouseUp = controller.shoot_release;
} else {
_root.score = _root.score - _local3;
_root.game.dart._visible = true;
_root.game.dart.onMouseUp = controller.shoot_release;
}
_root.game.dart_hit.onEnterFrame = null;
}
};
Frame 10
var throws = 0;
var score = 600;
_root.game.attachMovie("dart", "dart", 10);
_root.game.dart.onEnterFrame = controller.aim;
_root.game.dart.onMouseDown = controller.shoot_click;
_root.game.dart.onMouseUp = controller.shoot_release;
stop();
Frame 15
if (throws <= highScore) {
highScore = throws;
myGameData.data.savedHighScore = highScore;
myGameData.data.flush();
}
stop();
Symbol 6 MovieClip [dart] Frame 1
stop();
Symbol 6 MovieClip [dart] Frame 9
stop();
Symbol 10 MovieClip [point_display] Frame 20
this.removeMovieClip();
Symbol 14 MovieClip Frame 1
stop();
Symbol 14 MovieClip Frame 42
gotoAndStop (1);
Symbol 34 Button
on (release) {
gotoAndPlay ("play");
}