Frame 1
function gameMenu(menu, obj) {
getURL (_root.authorsSite, "_blank");
}
this._lockroot = true;
var gameName = "darts";
vNum = "Version 1.0 b-7";
flashVersionsNeeded = 8;
legalDomain = "http://www.terrypaton.com";
authorName = "Terry Paton";
authorContact = "terry@terrypaton.com";
authorsSite = "http://www.terrypaton.com";
gameLocation = _root._url.substr(0, legalDomain.length);
gameQuality = "AUTO";
var menu_cm = new ContextMenu();
menu_cm.customItems.push(new ContextMenuItem(authorsSite, gameMenu));
menu_cm.hideBuiltInItems();
_root.menu = menu_cm;
this._lockroot = true;
if (gameLocation != legalDomain) {
}
Frame 2
loadingClip.onLoad = function () {
};
loadingClip.onEnterFrame = function () {
pL = Math.floor((this._parent.getBytesLoaded() / this._parent.getBytesTotal()) * 100);
if (pL < 100) {
this.mask._xscale = (pL / 100) * 100;
this._parent.stop();
} else {
i = 0;
while (i < stringLength) {
removeMovieClip(eval ("loadingHolder.l" + i));
i++;
}
this._parent.play();
}
};
wordString = "DARTS";
stringLength = wordString.length;
wordOffset = (stringLength * 20) / 2;
this.createEmptyMovieClip("loadingHolder", 1);
loadingHolder._x = (320 - wordOffset) + 10;
loadingHolder._y = 175;
i = 0;
while (i < stringLength) {
loadingHolder.attachMovie("letter", "l" + i, i);
eval ("loadingHolder.l" + i)._x = i * 20;
eval ("loadingHolder.l" + i)._y = 0;
eval ("loadingHolder.l" + i).angle = i;
eval ("loadingHolder.l" + i).Lvar.text = wordString.charAt(i);
i++;
}
stop();
Frame 4
function attachSoundFromLibrary(idname) {
var _local2 = new Sound(this);
_local2.attachSound(idname);
return(_local2);
}
dartsStorage = SharedObject.getLocal("dartsStore");
yourhigh = dartsStorage.data.myhighscore;
trace(yourhigh);
if (yourhigh == undefined) {
trace("yo");
dartsStorage.data.myhighscore = 0;
yourhigh = 0;
dartsStorage.flush();
}
musicstate = dartsStorage.data.musicsetting;
if ((musicstate == undefined) || (musicstate == 2)) {
musicstate = 1;
dartsStorage.data.musicsetting = 1;
}
var dartHit1 = attachSoundFromLibrary("dartHit1.wav");
var dartHit2 = attachSoundFromLibrary("dartHit2.wav");
var dartHit3 = attachSoundFromLibrary("dartHit3.wav");
var dartHit4 = attachSoundFromLibrary("dartHit4.wav");
var throwDartSnd1 = attachSoundFromLibrary("throwDart1.wav");
var throwDartSnd2 = attachSoundFromLibrary("throwDart2.wav");
var throwDartSnd3 = attachSoundFromLibrary("throwDart3.wav");
var missBoardSnd1 = attachSoundFromLibrary("missBoard.wav");
var missBoardSnd2 = attachSoundFromLibrary("missBoard2.wav");
var missBoardSnd3 = attachSoundFromLibrary("missBoard3.wav");
var cheeringCrowd = attachSoundFromLibrary("cheeringCrowd.wav");
var booCrowd = attachSoundFromLibrary("booCrowd.wav");
var targetHitSnd = attachSoundFromLibrary("targetHit.wav");
var musicSnd = attachSoundFromLibrary("musicSnd.wav");
Frame 5
if (false) {
}
Frame 6
if (false) {
}
Frame 18
playBtn.onRelease = function () {
gotoAndPlay (20);
};
howToBtn.onRelease = function () {
gotoAndPlay (61);
};
websiteBtn.onRelease = function () {
getURL ("http://www.terrypaton.com", "_blank");
};
Frame 19
stop();
Frame 20
function calcScore() {
this.shadowHolder.attachMovie("dartHole", "dh" + dartHoleNum, dartHoleNum);
with (eval ("this.shadowHolder.dh" + dartHoleNum)) {
_x = eval ("dart" + dartNum)._x;
_y = eval ("dart" + dartNum)._y;
gotoAndStop(random(5) + 1);
}
dartHoleNum++;
px = dartBoardCenterX - eval ("dart" + dartNum)._x;
py = dartBoardCenterY - eval ("dart" + dartNum)._y;
radians = Math.atan2(py, px);
rotVal = (radians * 180) / Math.PI;
dx = px;
dy = py;
dist = Math.floor(Math.sqrt((dx * dx) + (dy * dy)));
missedBoard = false;
missedTargets = false;
hitBullseye = false;
hitDouble = false;
hitTriple = false;
if (dist > 94) {
missedTargets = true;
}
if (dist > 118) {
trace("you missed the board");
missedBoard = true;
switch (random(3)) {
case 0 :
missBoardSnd1.start();
case 1 :
missBoardSnd2.start();
break;
case 2 :
missBoardSnd3.start();
break;
default :
missBoardSnd1.start();
}
} else {
switch (random(4)) {
case 0 :
dartHit1.start();
case 1 :
dartHit2.start();
break;
case 2 :
dartHit3.start();
break;
case 3 :
dartHit4.start();
break;
default :
dartHit1.start();
}
}
if (dist < 5) {
trace("you hit a bullseye!");
hitBullseye = true;
}
if ((dist > 4) && (dist < 10)) {
trace("you hit an outer bullseye!");
hitouterBullseye = true;
}
if ((dist > 84) && (dist < 95)) {
trace("you got a double");
hitDouble = true;
}
if ((dist > 48) && (dist < 54)) {
trace("you got a triple");
hitTriple = true;
}
youHit = 0;
if (rotVal < 0) {
angleWithin = Math.floor((rotVal + 8) / 18);
} else {
angleWithin = Math.floor((rotVal - 8) / 18);
}
dx = eval ("dart" + dartNum)._x;
dy = eval ("dart" + dartNum)._y;
if ((((!missedTargets) && (!missedBoard)) && (!hitBullseye)) && (!hitouterBullseye)) {
i = 1;
while (i < 21) {
if (eval ("hitSpot." + i).hitTest(dx, dy, true)) {
trace("hit number " + i);
youHit = i;
}
i++;
}
}
if (whosturn == "computer") {
if (youHit == computerTarget) {
targetHitSnd.start();
compScoreAlert.gotoAndPlay(1);
computerTarget++;
tempScore = 0;
if (hitBullseye) {
tempScore = tempScore + 50;
} else if (hitouterBullseye) {
tempScore = tempScore + 25;
} else if (youHit > 0) {
tempScore = tempScore + youHit;
if (hitDouble) {
tempScore = tempScore + youHit;
attachMovie("tellPlayerClip", "tellPlayer2", 1001);
tellPlayer2._x = 320;
tellPlayer2._y = 240;
tellPlayer2.clip.textBox.text = "Hits a double!";
}
if (hitTriple) {
tempScore = tempScore + (youHit + youHit);
attachMovie("tellPlayerClip", "tellPlayer2", 1001);
tellPlayer2._x = 320;
tellPlayer2._y = 240;
tellPlayer2.clip.textBox.text = "Hits a triple!";
}
}
computerScore = computerScore + tempScore;
}
} else if (youHit == playerTarget) {
targetHitSnd.start();
playerScoreAlert.gotoAndPlay(1);
playerTarget++;
tempScore = 0;
if (hitBullseye) {
tempScore = tempScore + 50;
} else if (hitouterBullseye) {
tempScore = tempScore + 25;
} else if (youHit > 0) {
tempScore = tempScore + youHit;
if (hitDouble) {
attachMovie("tellPlayerClip", "tellPlayer2", 1001);
tellPlayer2._x = 320;
tellPlayer2._y = 240;
tellPlayer2.clip.textBox.text = "You hit a double!";
tempScore = tempScore + youHit;
}
if (hitTriple) {
tempScore = tempScore + (youHit + youHit);
attachMovie("tellPlayerClip", "tellPlayer2", 1001);
tellPlayer2._x = 320;
tellPlayer2._y = 240;
tellPlayer2.clip.textBox.text = "You hit a triple!";
}
}
score = score + tempScore;
}
gameState = "next dart";
}
function computerAim() {
powerAmount = 51;
computerX = 320;
powerAmount = random(39) + 30;
computerX = random(200) + 220;
aimFor = computerTarget;
aimdegrees = computerAimArray[aimFor];
aimdegrees = aimdegrees + (random(16) - 8);
trace(aimdegrees);
distanceFromCenter = 20 + random(75);
tmpAngle = (aimdegrees * Math.PI) / 180;
bx = distanceFromCenter * Math.cos(tmpAngle);
by = distanceFromCenter * Math.sin(tmpAngle);
trace("by = " + by);
powerAmount = (52 + ((by / 90) * 17)) + (random(6) - 3);
computerX = 320 + bx;
trace(testY);
currentMouse = 630;
}
computerAimArray = new Array(0, 72.5, -54, -90, 36, 108, 0, -127, -163, 144, -18, -180, 126, 17, 163, -36, -144, -73, 54, -108, 90);
function setup() {
startPower = false;
trace("musicstate = " + musicstate);
if (musicstate == 1) {
musicSnd.start(0, 100);
} else {
on_off.gotoAndStop(2);
}
compShotsTaken = 0;
playerShotsTaken = 0;
playerTarget = 1;
computerTarget = 1;
dartHoleNum = 50;
roundNumber = 1;
round1Score = 0;
round2Score = 0;
round3Score = 0;
compRound1Score = 0;
compRound2Score = 0;
compRound3Score = 0;
computerScore = 0;
score = 0;
lastPower = 0;
dartBoardCenterX = 320;
dartBoardCenterY = 207;
gravity = 3;
angle = 300;
dartspeed = 5;
draggingY = false;
draggingX = true;
pwrDir = "up";
pwrMove = 2;
maxPwr = 100;
whosturn = "player";
onMouseDown = function () {
if ((gameState == "playing") && (whosturn == "player")) {
powerAmount = 0;
startYMouse = 370;
startXMouse = _xmouse;
draggingX = false;
draggingY = true;
attachMovie("powerBar", "powerBar", 900);
powerBar._x = startXMouse - 40;
powerBar._y = 370;
powerBar._yscale = 100;
startPower = true;
}
};
onMouseUp = function () {
if (((startPower == true) && (gameState == "playing")) && (whosturn == "player")) {
gameState = "start throw";
playerShotsTaken++;
startPower = false;
}
};
websiteBtn.onRelease = function () {
getURL ("http://www.terrypaton.com", "_blank");
};
var _local1 = new Object();
_local1.onKeyDown = function () {
trace("sdfdfg");
if (gameState == "playing") {
if (!(Key.getCode() === 32)) {
} else {
trace("jump");
if (musicstate == 1) {
musicstate = 0;
dartsStorage.data.musicsetting = 0;
trace("music off");
musicSnd.stop();
on_off.gotoAndStop(2);
} else {
trace("music on");
musicstate = 1;
dartsStorage.data.musicsetting = 1;
musicSnd.start(0, 100);
on_off.gotoAndStop(1);
}
}
}
};
Key.addListener(_local1);
}
function convertToRadians(tempAngle) {
return((tempAngle * Math.PI) / 180);
}
gameState = "setup";
onEnterFrame = function () {
switch (gameState) {
case "setup" :
setup();
gameState = "start next round";
return;
case "playing" :
if (whosturn == "player") {
if (draggingX) {
currentMouse = _xmouse;
if (currentMouse < 50) {
currentMouse = 50;
} else if (currentMouse > 590) {
currentMouse = 590;
}
eval ("dart" + dartNum)._x = currentMouse;
}
if (draggingY) {
if (pwrDir == "up") {
powerAmount = powerAmount + pwrMove;
if (powerAmount > maxPwr) {
pwrDir = "down";
}
}
if (pwrDir == "down") {
powerAmount = powerAmount - pwrMove;
if (powerAmount < 1) {
pwrDir = "up";
}
}
powerBar.pwrClip._yscale = powerAmount;
powerBar.lastpwrClip._yscale = lastPower;
}
} else {
if (currentMouse < computerX) {
currentMouse = currentMouse + ((computerX - currentMouse) / 10);
}
if (currentMouse > computerX) {
currentMouse = currentMouse - ((currentMouse - computerX) / 10);
}
eval ("dart" + dartNum)._x = currentMouse;
if (Math.abs(computerX - currentMouse) < 1) {
gameState = "start throw";
compShotsTaken++;
}
}
return;
case "start throw" :
switch (random(3)) {
case 0 :
throwDartSnd1.start();
case 1 :
throwDartSnd2.start();
break;
case 2 :
throwDartSnd3.start();
break;
default :
throwDartSnd1.start();
}
lastPower = powerAmount;
trace("powerAmount = " + powerAmount);
attachMovie("throwndart", "dart" + dartNum, dartNum + 100);
with (eval ("dart" + dartNum)) {
gotoAndStop(dartPos);
_x = currentMouse;
_y = 400;
}
if (whosturn == "computer") {
matrix = [-0.574, 1.43, 0.144, 0, 0, 0.426, 0.43, 0.144, 0, 0, 0.426, 1.43, -0.856, 0, 0, 0, 0, 0, 1, 0];
var filter = (new flash.filters.ColorMatrixFilter(matrix));
eval ("dart" + dartNum).cacheAsBitmap = true;
eval ("dart" + dartNum).filters = new Array(filter);
}
shadowHolder.attachMovie("dartshadow", "dartshadow" + dartNum, dartNum);
eval ("shadowHolder.dartshadow" + dartNum)._x = 500;
eval ("shadowHolder.dartshadow" + dartNum)._y = 640;
draggingX = true;
draggingY = false;
throwSpeed = 20;
dartspeed = 16 + (powerAmount / 2);
angle = 300;
angle = 330 - (powerAmount / 5);
centerScale = 480;
removeMovieClip(powerBar);
throwD = 0;
gameState = "throwing dart";
dartX = 0;
dartY = 400;
eval ("dart" + dartNum).play();
return;
case "throwing dart" :
tmpAngle = _root.convertToRadians(angle);
bx = dartspeed * Math.cos(tmpAngle);
by = dartspeed * Math.sin(tmpAngle);
angle = angle + gravity;
if (angle > 360) {
angle = angle - 360;
}
dartX = dartX + bx;
dartY = dartY + by;
eval ("dart" + dartNum)._y = dartY;
if (eval ("dart" + dartNum)._y > 470) {
eval ("dart" + dartNum)._y = 470;
}
with (eval ("shadowHolder.dartshadow" + dartNum)) {
_y = eval ("dart" + dartNum)._y;
_x = (eval ("dart" + dartNum)._x + 150) - (dartX / 4);
_alpha = (dartX / 640) * 100;
_xscale = (_yscale = 100 - (dartX / 12));
}
eval ("dart" + dartNum)._xscale = (eval ("dart" + dartNum)._yscale = 100 - (dartX / 12));
powerLine.lineTo(dartX, dartY);
if ((dartX > 600) || (dartY > 480)) {
gameState = "find target";
eval ("shadowHolder.dartshadow" + dartNum)._alpha = 100;
eval ("dart" + dartNum).stop();
}
return;
case "find target" :
calcScore();
return;
case "next dart" :
if (whosturn == "computer") {
if ((computerTarget > 20) || (playerTarget > 20)) {
gameState = "game over";
return;
}
computerAim();
glowSpots.gotoAndStop(computerTarget);
} else {
glowSpots.gotoAndStop(playerTarget);
}
dartNum++;
dartPos = random(26) + 1;
attachMovie("helddart", "dart" + dartNum, dartNum + 100);
eval ("dart" + dartNum).gotoAndStop(dartPos);
eval ("dart" + dartNum)._x = -50;
eval ("dart" + dartNum)._y = 370;
var matrix = new Array();
if (dartNum >= 4) {
gameState = "end of round";
} else {
if (whosturn == "player") {
remainingDarts.gotoAndStop(4 - dartNum);
if (playerTarget > 20) {
gameState = "game over";
return;
}
} else {
matrix = [-0.574, 1.43, 0.144, 0, 0, 0.426, 0.43, 0.144, 0, 0, 0.426, 1.43, -0.856, 0, 0, 0, 0, 0, 1, 0];
var filter = (new flash.filters.ColorMatrixFilter(matrix));
eval ("dart" + dartNum).cacheAsBitmap = true;
eval ("dart" + dartNum).filters = new Array(filter);
compRemainingDarts.gotoAndStop(4 - dartNum);
}
draggingY = false;
draggingX = true;
pwrDir = "up";
gameState = "playing";
}
return;
case "end of round" :
attachMovie("tellPlayerClip", "tellPlayer", 1000);
tellPlayer._x = 320;
tellPlayer._y = 390;
tellPlayer.clip.textBox.text = "End of turn";
roundWaitCount = 60;
if (whosturn == "player") {
whosturn = "computer";
} else {
whosturn = "player";
powerAmount = 0;
roundNumber++;
}
gameState = "end of round wait";
return;
case "end of round wait" :
roundWaitCount--;
if (roundWaitCount < 1) {
i = 0;
while (i < 10) {
removeMovieClip(eval ("dart" + i));
removeMovieClip(eval ("shadowHolder.dartshadow" + i));
i++;
}
removeMovieClip(tellPlayer);
gameState = "start next round";
}
return;
case "start next round" :
attachMovie("tellPlayerClip", "tellPlayer", 1000);
tellPlayer._x = 320;
tellPlayer._y = 390;
if (whosturn == "player") {
glowSpots.gotoAndStop(playerTarget);
dartNum = 0;
playerScorePanel.gotoAndStop(roundNumber);
remainingDarts.gotoAndStop(4 - dartNum);
tellPlayer.clip.textBox.text = "Your Turn";
} else {
glowSpots.gotoAndStop(computerTarget);
tellPlayer.clip.textBox.text = "Computers Turn";
compScorePanel.gotoAndStop(roundNumber);
compRemainingDarts.gotoAndStop(4 - dartNum);
dartNum = 0;
}
roundStartCount = 60;
gameState = "round start wait";
return;
case "round start wait" :
roundStartCount--;
if (roundStartCount < 1) {
removeMovieClip(tellPlayer);
gameState = "next dart";
}
return;
case "game over" :
computerWins = false;
if (computerTarget > 20) {
computerWins = true;
}
gameOverWait = 60;
gameState = "game over wait";
return;
case "game over wait" :
gameOverWait--;
if (gameOverWait < 1) {
i = 0;
while (i < 10) {
removeMovieClip("dart" + i);
i++;
}
gotoAndPlay (41);
}
return;
case "lose life" :
return;
case "lose life wait" :
return;
}
};
Frame 21
if (false) {
}
Frame 40
stop();
Frame 41
function goMain() {
gotoAndPlay (5);
}
delete gameState;
musicSnd.stop();
playerShotsTaken = 12;
bonusEquation = ("500 - (" + playerShotsTaken) + " Throws x 20)";
if (computerWins) {
BonusPoints = 0;
} else {
BonusPoints = 500 - (playerShotsTaken * 20);
}
if (BonusPoints < 0) {
BonusPoints = 0;
}
finalScore = score + BonusPoints;
if ((finalScore > yourhigh) || (playerScore > 2000)) {
yourhigh = finalScore;
dartsStorage.data.myhighscore = finalScore;
if (gameLocation == legalDomain) {
mainMenuBtn._x = 500;
enterHigh._visible = true;
} else {
enterHigh._visible = false;
mainMenuBtn._x = 320;
}
} else {
enterHigh._visible = false;
mainMenuBtn._x = 320;
}
if (computerWins) {
bonusClip._visible = false;
winMessage = "The computer beat you.";
booCrowd.start();
} else {
winMessage = "You beat the computer!";
cheeringCrowd.start();
}
Frame 60
stop();
Frame 61
mainMenuBtn.onRelease = function () {
gotoAndPlay (5);
};
Frame 68
stop();
Symbol 266 MovieClip [__Packages.letterClass] Frame 0
class letterClass extends MovieClip
{
var centerY, radiusY, speed, y, _y, x, _x, angle;
function letterClass () {
super();
}
function onLoad() {
centerY = 48;
radiusY = 5;
speed = 0.05;
y = _y;
x = _x;
}
function onEnterFrame() {
if (angle != undefined) {
y = centerY + (Math.sin(angle) * radiusY);
angle = angle + speed;
_x = x;
_y = y;
}
}
}
Symbol 13 MovieClip [letter] Frame 1
#initclip 2
Object.registerClass("letter", letterClass);
#endinitclip
Symbol 137 MovieClip [tellPlayerClip] Frame 79
stop();
Symbol 153 MovieClip Frame 1
stop();
Symbol 159 MovieClip Frame 1
_root.stop();
Symbol 159 MovieClip Frame 75
_root.play();
Symbol 187 MovieClip Frame 26
stop();
Symbol 200 MovieClip Frame 17
stop();
Symbol 216 MovieClip Frame 4
stop();
Symbol 218 MovieClip Frame 4
stop();
Symbol 224 MovieClip Frame 1
stop();
Symbol 232 MovieClip Frame 1
stop();
Symbol 256 Button
on (release) {
sendHighscore();
}
Symbol 257 MovieClip [highscore_entry] Frame 1
function sendHighscore() {
if (!submitted) {
if ((typeYourName != "type your name") && (typeYourName != "t")) {
tempName = "";
i = 0;
while (i < typeYourName.length) {
if (((typeYourName.charAt(i) == ",") || (typeYourName.charAt(i) == "%")) || (typeYourName.charAt(i) == "&")) {
} else {
tempName = tempName + typeYourName.charAt(i);
}
i++;
}
submitURL = (((("http://www.terrypaton.com/highscores/testScore.php?game=" + _root.gameName) + "&score=") + _root.finalScore) + "&name=") + tempName;
loadVariablesNum (submitURL, 0, "GET");
_root.mainMenu();
this.gotoAndPlay("loadingResult");
this._visible = false;
submitted = true;
}
}
}
typeYourName = "type your name";
nameEntry.onSetFocus = function () {
this.text = "";
};
nameEntry.onKillFocus = function () {
if (this.text == "") {
this.text = "type your name";
}
};
_root.yourPos = undefined;
submitted = false;
Symbol 257 MovieClip [highscore_entry] Frame 5
stop();
Symbol 260 Button
on (release) {
_root.goMain();
}