Frame 1
function restart() {
trace("RESTART");
removeMovieClip(bike.mymc);
bike = new vehicle();
bike.mymc.swapDepths(gui.mymc);
targets.restart();
gui.closeDialog();
}
function newMap() {
trace("--NEW MAP--");
removeMovieClip(lines.mymc);
removeMovieClip(targets.mymc);
removeMovieClip(gui.tools.mymc);
lines = new lineHandler();
targets = new targetHandler();
gui.tools = new drawingTools();
restart();
}
stop();
_quality = "MEDIUM";
Stage.scaleMode = "noScale";
var domain1 = "http://www.onemorelevel";
var domain2 = "http://onemorelevel";
if ((_url.substr(0, length(domain1)) != domain1) && (_url.substr(0, length(domain2)) != domain2)) {
}
var cam = new cameraHandler();
var targets = new targetHandler();
var lines = new lineHandler();
var bike = new vehicle();
var gui = new bikeGUI();
var fps = new fpsCounter();
new line(new cartesian(-50, 50), new cartesian(50, 50));
onEnterFrame = function () {
bike.advance();
cam.advance();
gui.advance();
bike.updateMC();
lines.updateMC();
targets.updateMC();
gui.updateMC();
fps.advance();
};
Symbol 29 MovieClip Frame 1
function onPress() {
_root.gamePause = false;
_root.tools.importFile(_parent.textBox.text);
}
Symbol 58 MovieClip [__Packages.cartesian] Frame 0
class cartesian
{
var x, y;
function cartesian (pX, pY) {
x = pX;
y = pY;
}
function report() {
return((((" [x:" + (Math.round(x * 10) / 10)) + " y:") + (Math.round(y * 10) / 10)) + "]");
}
function getPolar() {
return(new polar(Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)), Math.atan2(y, x)));
}
function getUnit() {
return(FACTOR(1 / getLength()));
}
function getLength() {
return(Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)));
}
function EQU(p) {
x = p.x;
y = p.y;
return(p);
}
function TEND(pTarget, pSpeed) {
x = x + ((pTarget.x - x) / pSpeed);
y = y + ((pTarget.y - y) / pSpeed);
return(pTarget);
}
function FACTOR(p) {
return(new cartesian(x * p, y * p));
}
function OFFSET(pX, pY) {
return(new cartesian(x + pX, y + pY));
}
function ADD(p) {
return(new cartesian(x + p.x, y + p.y));
}
function SUB(p) {
return(new cartesian(x - p.x, y - p.y));
}
function INC(p) {
x = x + p.x;
y = y + p.y;
return(new cartesian(x + p.x, y + p.y));
}
function DOT(p) {
return((x * p.x) + (y * p.y));
}
}
Symbol 59 MovieClip [__Packages.polar] Frame 0
class polar
{
var r, a;
function polar (npr, npa) {
r = npr;
a = soupMath.mod2Pi(npa);
}
function report() {
return((((" [r:" + Math.round(r)) + " a:") + (Math.round(a * 100) / 100)) + "]");
}
function getCartesian() {
return(new cartesian(r * Math.cos(a), r * Math.sin(a)));
}
function aDegs() {
return((a / 6.283185) * 360);
}
function FACTOR(p) {
return(new polar(r * p, a));
}
function INC(p) {
a = a + p;
a = soupMath.mod2Pi(a);
}
function INCDEGS(p) {
a = a + (((p / 360) * 2) * 3.141593);
a = soupMath.mod2Pi(a);
}
function OFFSETDEGS(p) {
return(new polar(r, a + (((p / 360) * 2) * 3.141593)));
}
function EQU(p) {
r = p.r;
a = p.a;
return(p);
}
function TEND(pTarget, pSpeed) {
var _local2 = pTarget.a - a;
var _local3 = Math.floor(Math.abs(_local2) / 3.141593);
if (_local2 != 0) {
_local2 = ((_local2 / Math.abs(_local2)) * (1 - (2 * _local3))) * ((6.283185 * _local3) + (Math.abs(_local2) * (1 - (2 * _local3))));
INC(_local2 / pSpeed);
}
}
}
Symbol 60 MovieClip [__Packages.soupMath] Frame 0
class soupMath extends Math
{
function soupMath () {
super();
}
static function toRads(p) {
return((p * 3.141593) / 180);
}
static function toDegs(p) {
return((p * 180) / 3.141593);
}
static function mod(p1, p2) {
return((Math.abs(p1 / p2) - Math.floor(Math.abs(p1 / p2))) * p2);
}
static function mod2Pi(p) {
return((((p / 6.283185) - Math.floor(p / 6.283185)) * 3.141593) * 2);
}
static function modSpecial(p) {
if (p == 0) {
return(0);
}
return((p / Math.abs(p)) * mod(Math.abs(p), 3.141593));
}
static function rand(p) {
return((Math.random() - Math.random()) * p);
}
}
Symbol 61 MovieClip [__Packages.cameraHandler] Frame 0
class cameraHandler
{
var pos, focus, mode3d;
function cameraHandler () {
pos = new cartesian(-250, -200);
focus = 1;
mode3d = false;
trace("new camera");
}
function swapFocus() {
focus = focus * -1;
}
function focusBike() {
var _local3 = new cartesian(0, 0);
_local3 = _root.bike.headWheel.pos.ADD(new cartesian(-250, -250));
_local3 = _local3.ADD(_root.bike.headWheel.vel);
pos.INC(pos.SUB(_local3).FACTOR(-0.2));
}
function advance() {
if (focus == 1) {
focusBike();
}
}
}
Symbol 62 MovieClip [__Packages.drawingTools] Frame 0
class drawingTools
{
var mymc, p1, p2, oldMousePos, mousePress, drawing, tool, allowDraw;
function drawingTools () {
mymc = _root.createEmptyMovieClip("drawing", _root.getNextHighestDepth());
p1 = new cartesian(50, 50);
p2 = new cartesian(50, 50);
oldMousePos = new cartesian(0, 0);
mousePress = false;
drawing = false;
tool = 1;
allowDraw = true;
}
function mouseDown() {
mousePress = true;
if (((tool == 1) && (Key.isDown(17) == false)) && (allowDraw)) {
startPen();
}
if (((tool == 4) && (Key.isDown(17) == false)) && (allowDraw)) {
addTarget();
}
}
function mouseUp() {
mousePress = false;
if ((((tool == 1) && (Key.isDown(17) == false)) && (drawing)) && (allowDraw)) {
stopPen();
}
}
function startPen() {
drawing = true;
_root.cam.focus = -1;
if (Key.isDown(16) == false) {
p1.x = _root._xmouse + _root.cam.pos.x;
p1.y = _root._ymouse + _root.cam.pos.y;
if (p2.SUB(p1).getLength() < 10) {
p1.EQU(p2);
}
}
}
function addTarget() {
if (_root.targets.count < 20) {
var _local2 = new cartesian();
_local2.x = _root._xmouse + _root.cam.pos.x;
_local2.y = _root._ymouse + _root.cam.pos.y;
new target(_local2);
}
}
function stopPen() {
p2.x = _root._xmouse + _root.cam.pos.x;
p2.y = _root._ymouse + _root.cam.pos.y;
new line(p1, p2);
p1.x = _root._xmouse + _root.cam.pos.x;
p1.y = _root._ymouse + _root.cam.pos.y;
drawing = false;
}
function doErase() {
var _local2 = new cartesian(_root._xmouse + _root.cam.pos.x, _root._ymouse + _root.cam.pos.y);
_root.lines.erase(_local2);
_root.targets.erase(_local2);
}
function doHand() {
_root.cam.focus = -1;
_root.cam.pos.x = _root.cam.pos.x + (oldMousePos.x - _root._xmouse);
_root.cam.pos.y = _root.cam.pos.y + (oldMousePos.y - _root._ymouse);
}
function advance() {
mymc.clear();
if (mousePress) {
if ((tool == "2") && (!Key.isDown(17))) {
doErase();
}
if ((tool == "3") || (Key.isDown(17))) {
doHand();
}
}
oldMousePos = new cartesian(_root._xmouse, _root._ymouse);
if ((tool == 1) && (drawing || (Key.isDown(16)))) {
mymc.lineStyle(1, 4095, 100);
mymc.moveTo(p1.x - _root.cam.pos.x, p1.y - _root.cam.pos.y);
mymc.lineTo(_root._xmouse, _root._ymouse);
}
graphics.cross(p2.x - _root.cam.pos.x, p2.y - _root.cam.pos.y, mymc);
}
}
Symbol 63 MovieClip [__Packages.target] Frame 0
class target
{
var pos, hit, mymc;
function target (pPos) {
pos = new cartesian(0, 0);
pos.EQU(pPos);
hit = false;
_root.targets.addRef(pos.x, pos.y, this);
var _local3 = _root.targets.mymc.getNextHighestDepth();
mymc = _root.targets.mymc.attachMovie("target", "target_" + _local3, _local3);
updateMC();
trace("new target");
_root.targets.count++;
}
function kill() {
removeMovieClip(mymc);
_root.targets.count = _root.targets.count + -1;
if (hit) {
_root.targets.hit = _root.targets.hit + -1;
}
}
function updateMC() {
mymc._visible = true;
mymc._rotation = mymc._rotation + 2;
mymc._x = pos.x - _root.cam.pos.x;
mymc._y = pos.y - _root.cam.pos.y;
if (hit) {
mymc.gotoAndStop("hit");
} else {
mymc.gotoAndStop("unHit");
}
}
function checkMass(pObj) {
if ((hit == false) && (pObj.pos.SUB(pos).getLength() < 25)) {
hit = true;
_root.targets.hit++;
if (_root.targets.hit == _root.targets.count) {
_root.gui.showWinDialog();
}
}
}
function erase(pPos) {
if (pPos.SUB(pos).getLength() < 10) {
kill();
return(1);
}
return(0);
}
}
Symbol 64 MovieClip [__Packages.line] Frame 0
class line
{
var p1, p2, P1ToP2, hit, d, objToP1, objToP2, l, active, u, ld;
function line (pP1, pP2) {
p1 = new cartesian(0, 0);
p2 = new cartesian(0, 0);
P1ToP2 = new cartesian(0, 0);
p1.EQU(pP1);
p2.EQU(pP2);
hit = false;
d = new cartesian(0, 0);
objToP1 = new cartesian(0, 0);
objToP2 = new cartesian(0, 0);
createReferences();
updateMC();
}
function createReferences() {
P1ToP2 = p2.SUB(p1);
l = P1ToP2.getLength();
if (((l < 5) || (p1.getLength() > 5000)) || (p2.getLength() > 5000)) {
active = false;
}
var _local5;
var _local6;
var _local3 = new cartesian(0, 0);
var _local4 = 0;
while (_local4 < l) {
_local3 = p1.ADD(P1ToP2.FACTOR(_local4 / l));
if ((Math.floor(_local3.x / _root.lines.sectorSize) != _local5) || (Math.floor(_local3.y / _root.lines.sectorSize) != _local6)) {
_local5 = Math.floor(_local3.x / _root.lines.sectorSize);
_local6 = Math.floor(_local3.y / _root.lines.sectorSize);
_root.lines.addRef(_local3.x, _local3.y, this);
}
_local4++;
}
}
function checkMass(pObj) {
if (hit == true) {
return(0);
}
hit = true;
_root.fps.count2++;
objToP1 = pObj.pos.SUB(p1);
objToP2 = pObj.pos.SUB(p2);
u = objToP1.DOT(P1ToP2) / Math.pow(l, 2);
if ((u > 0) && (u < 1)) {
d = objToP1.SUB(P1ToP2.FACTOR(u));
ld = d.getLength();
if (ld <= pObj.radius) {
var _local4 = new cartesian((-d.y) / ld, d.x / ld);
pObj.rotate(_local4);
pObj.drive(_local4);
if (pObj.vel.DOT(d.FACTOR(1 / ld)) > 10) {
ld = ld * -1;
}
pObj.lineForce(d.FACTOR((pObj.radius - ld) / ld));
return(1);
}
}
d = objToP1;
ld = d.getLength();
if (ld <= pObj.radius) {
var _local4 = new cartesian((-d.y) / ld, d.x / ld);
pObj.rotate(_local4);
pObj.drive(_local4);
pObj.lineForce(d.FACTOR((pObj.radius - ld) / ld));
return(1);
}
d = objToP2;
ld = d.getLength();
if (ld <= pObj.radius) {
var _local4 = new cartesian((-d.y) / ld, d.x / ld);
pObj.rotate(_local4);
pObj.drive(_local4);
pObj.lineForce(d.FACTOR((pObj.radius - ld) / ld));
return(1);
}
return(0);
}
function erase(pPos) {
var _local2;
var _local4;
var _local3 = new cartesian(0, 0);
_local2 = pPos.SUB(p1).DOT(P1ToP2) / Math.pow(l, 2);
if ((_local2 > 0) && (_local2 < 1)) {
_local3 = pPos.SUB(P1ToP2.FACTOR(_local2).ADD(p1));
_local4 = _local3.getLength();
if (_local4 <= 10) {
active = false;
return(1);
}
}
return(0);
}
function updateMC() {
if (hit == false) {
hit = true;
_root.lines.mymc.lineStyle(1, 0, 100);
var _local3 = p1.SUB(_root.cam.pos);
var _local4 = p2.SUB(_root.cam.pos);
if (_root.cam.mode3d == false) {
_root.lines.mymc.moveTo(_local3.x, _local3.y);
_root.lines.mymc.lineTo(_local4.x, _local4.y);
} else {
var _local5 = new cartesian(_local3.x - 250, _local3.y - 200).FACTOR(0.05);
var _local6 = new cartesian(_local4.x - 250, _local4.y - 200).FACTOR(0.05);
var _local7 = 50 * Math.abs(P1ToP2.y / l);
_root.lines.mymc.beginFill(10066431, _local7);
_root.lines.mymc.lineStyle(2, 0, 100);
_root.lines.mymc.moveTo(_local3.x + _local5.x, _local3.y + _local5.y);
_root.lines.mymc.lineTo(_local4.x + _local6.x, _local4.y + _local6.y);
_root.lines.mymc.lineStyle(0, 0, 40);
_root.lines.mymc.lineTo(_local4.x - _local6.x, _local4.y - _local6.y);
_root.lines.mymc.lineStyle(0, 0, 100);
_root.lines.mymc.lineTo(_local3.x - _local5.x, _local3.y - _local5.y);
_root.lines.mymc.lineStyle(0, 0, 40);
_root.lines.mymc.lineTo(_local3.x + _local5.x, _local3.y + _local5.y);
_root.lines.mymc.endFill();
}
}
}
}
Symbol 65 MovieClip [__Packages.graphics] Frame 0
class graphics
{
function graphics () {
}
static function normalFormat(field, bold, align) {
var _local1 = new TextFormat();
_local1.font = "_sans";
_local1.size = 12;
_local1.bold = bold;
_local1.align = align;
field.setNewTextFormat(_local1);
field.multiline = true;
field.wordWrap = true;
}
static function inputFormat(field) {
var _local1 = new TextFormat();
_local1.font = "_sans";
_local1.size = 9;
field.setNewTextFormat(_local1);
field.multiline = true;
field.wordWrap = true;
}
static function rect(x1, y1, x2, y2, mc) {
mc.lineStyle(0, 0, 100);
mc.moveTo(x1, y1);
mc.lineTo(x2, y1);
mc.lineTo(x2, y2);
mc.lineTo(x1, y2);
mc.lineTo(x1, y1);
}
static function rectFill(x1, y1, x2, y2, mc) {
mc.lineStyle(0, 0, 100);
mc.beginFill(15658751, 95);
mc.moveTo(x1, y1);
mc.lineTo(x2, y1);
mc.lineTo(x2, y2);
mc.lineTo(x1, y2);
mc.lineTo(x1, y1);
mc.endFill();
}
static function label(pText, x, y, width, height, mc) {
var _local1 = mc.getNextHighestDepth();
mc.createTextField("label_" + _local1, _local1, x, y, width, height);
var _local2 = mc["label_" + _local1];
_local2.selectable = false;
normalFormat(_local2, false, "left");
_local2.text = pText;
}
static function boldLabel(pText, x, y, width, height, mc) {
var _local2 = mc.getNextHighestDepth();
mc.createTextField("label_" + _local2, _local2, x, y, width, height);
var _local1 = mc["label_" + _local2];
_local1.selectable = false;
_local1.textAlign = normalFormat(_local1, true, "center");
_local1.text = pText;
}
static function title(pText, x, y, width, height, mc) {
var _local2 = mc.getNextHighestDepth();
mc.createTextField("label_" + _local2, _local2, x, y, width, height);
var _local3 = mc["label_" + _local2];
normalFormat(_local3, true, "left");
_local3.text = pText;
_local3.selectable = false;
mc.lineStyle(1, 136, 70);
mc.moveTo(x, y + 18);
mc.lineTo(x + 100, y + 18);
}
static function inputBox(name, x, y, width, height, mc) {
var _local3 = mc.getNextHighestDepth();
mc.createTextField(name, _local3, x, y, width, height);
var _local1 = mc[name];
_local1.type = "input";
_local1.border = true;
_local1.background = true;
inputFormat(_local1, false);
}
static function smallButton(name, text, x, y, mc) {
var _local2 = mc.getNextHighestDepth();
var _local1 = mc.createEmptyMovieClip(name, _local2);
rectFill(0, 0, 50, 20, _local1);
boldLabel(text, 0, 0, 50, 20, _local1);
_local1._x = x;
_local1._y = y;
}
static function cross(x, y, mc) {
mc.lineStyle(1, 16711680, 100);
mc.moveTo(x - 2, y - 2);
mc.lineTo(x + 2, y + 2);
mc.moveTo(x + 2, y - 2);
mc.lineTo(x - 2, y + 2);
}
}
Symbol 66 MovieClip [__Packages.bikeGUI] Frame 0
class bikeGUI
{
var tools, mymc, dialog, penButton, targetButton, eraseButton, handButton, clearButton, playButton, stopButton, saveButton, loadButton, threeDButton, helpButton, targetInfo;
function bikeGUI () {
Mouse.addListener(this);
tools.allowDraw = true;
trace("new GUI");
tools = new drawingTools();
mymc = _root.createEmptyMovieClip("gui", _root.getNextHighestDepth());
graphics.rectFill(0, 0, 30, 400, mymc);
createButtons();
createTargetInfo();
showSplash();
}
function closeDialog() {
removeMovieClip(dialog);
tools.allowDraw = true;
_root.cam.focus = 1;
}
function showLoadDialog() {
closeDialog();
tools.allowDraw = false;
dialog = mymc.createEmptyMovieClip("dialog", mymc.getNextHighestDepth());
dialog._x = 100;
dialog._y = 50;
graphics.rectFill(0, 0, 300, 300, dialog);
graphics.title("Open Map", 5, 5, 280, 40, dialog);
graphics.label("Copy the map code, paste it into the box (Ctrl+V) and press OK.", 5, 25, 290, 35, dialog);
graphics.inputBox("inputBox", 5, 65, 290, 195, dialog);
graphics.smallButton("okButton", "Open", 5, 270, dialog);
graphics.smallButton("cancelButton", "Cancel", 65, 270, dialog);
dialog.okButton.onPress = function () {
parser.parseMap(this._parent.inputBox.text);
_root.gui.closeDialog();
};
dialog.cancelButton.onPress = function () {
_root.gui.closeDialog();
};
}
function showSaveDialog() {
closeDialog();
tools.allowDraw = false;
dialog = mymc.createEmptyMovieClip("dialog", mymc.getNextHighestDepth());
dialog._x = 100;
dialog._y = 50;
graphics.rectFill(0, 0, 300, 300, dialog);
graphics.title("Save Map", 5, 5, 280, 40, dialog);
graphics.label("Copy the map code (Ctrl-C), and paste it into an email, forum or instant message.", 5, 25, 290, 35, dialog);
graphics.inputBox("inputBox", 5, 65, 290, 195, dialog);
graphics.smallButton("okButton", "Copy", 5, 270, dialog);
graphics.smallButton("cancelButton", "Close", 65, 270, dialog);
dialog.inputBox.text = parser.export(_root.lines, _root.targets);
dialog.okButton.onPress = function () {
System.setClipboard(this._parent.inputBox.text);
};
dialog.cancelButton.onPress = function () {
_root.gui.closeDialog();
};
}
function showClearDialog() {
closeDialog();
tools.allowDraw = false;
dialog = mymc.createEmptyMovieClip("dialog", mymc.getNextHighestDepth());
dialog._x = 100;
dialog._y = 150;
graphics.rectFill(0, 0, 300, 100, dialog);
graphics.title("Clear Map", 5, 5, 280, 40, dialog);
graphics.label("Are you sure you want to clear the map?", 5, 25, 290, 35, dialog);
graphics.smallButton("okButton", "Clear", 5, 70, dialog);
graphics.smallButton("cancelButton", "Cancel", 65, 70, dialog);
dialog.okButton.onPress = function () {
_root.newMap();
new line(new cartesian(-50, 50), new cartesian(50, 50));
_root.gui.closeDialog();
};
dialog.cancelButton.onPress = function () {
_root.gui.closeDialog();
};
}
function showDeadDialog() {
closeDialog();
tools.allowDraw = false;
dialog = mymc.createEmptyMovieClip("dialog", mymc.getNextHighestDepth());
dialog._x = 100;
dialog._y = 150;
graphics.rectFill(0, 0, 300, 100, dialog);
graphics.title("Ouch!", 5, 5, 280, 40, dialog);
graphics.label("Level failed. (Press Space)", 5, 25, 290, 35, dialog);
graphics.smallButton("okButton", "Retry", 5, 70, dialog);
Key.addListener(dialog);
dialog.okButton.onPress = function () {
_root.restart();
_root.gui.closeDialog();
};
}
function showWinDialog() {
closeDialog();
tools.allowDraw = false;
dialog = mymc.createEmptyMovieClip("dialog", mymc.getNextHighestDepth());
dialog._x = 100;
dialog._y = 150;
graphics.rectFill(0, 0, 300, 100, dialog);
graphics.title("Level Complete!", 5, 5, 280, 40, dialog);
graphics.label("You beat the level!", 5, 25, 290, 35, dialog);
graphics.smallButton("okButton", "Retry", 5, 70, dialog);
Key.addListener(dialog);
dialog.okButton.onPress = function () {
_root.restart();
_root.gui.closeDialog();
};
}
function showHelp() {
closeDialog();
tools.allowDraw = false;
dialog = mymc.createEmptyMovieClip("dialog", mymc.getNextHighestDepth());
dialog._x = 100;
dialog._y = 50;
graphics.rectFill(0, 0, 300, 300, dialog);
graphics.title("Help", 5, 5, 80, 90, dialog);
var _local3 = new String();
_local3 = "Accelerate: UP\rBrake: DOWN\rLean: LEFT/RIGHT\rTurn Around: X\r\r";
_local3 = _local3 + "Use the mouse to draw a map, create some stars, then try to collect them all.\r\r";
_local3 = _local3 + "Tips: Use CTRL to quickly move the camera. Use SHIFT to draw consecutive lines.\r\r";
_local3 = _local3 + "Contact the developer: freeridergame@hotmail.co.uk\r\r";
_local3 = _local3 + "Thanks Av4rice and the rest of #klined";
graphics.label(_local3, 5, 25, 290, 245, dialog);
graphics.smallButton("cancelButton", "Close", 5, 270, dialog);
dialog.cancelButton.onPress = function () {
_root.gui.closeDialog();
};
}
function showSplash() {
var _local2 = mymc.attachMovie("splash", "splash", mymc.getNextHighestDepth());
_local2._x = 100;
_local2._y = 50;
_local2.onEnterFrame = function () {
this._alpha = this._alpha + -0.1;
if (this._alpha < 1) {
removeMovieClip(this);
}
};
}
function createButtons() {
penButton = mymc.attachMovie("penButton", "penButton", 1, {_x:10, _y:20});
targetButton = mymc.attachMovie("targetButton", "targetButton", 2, {_x:10, _y:50});
eraseButton = mymc.attachMovie("eraseButton", "eraseButton", 3, {_x:10, _y:80});
handButton = mymc.attachMovie("handButton", "handButton", 4, {_x:10, _y:110});
clearButton = mymc.attachMovie("clearButton", "clearButton", 5, {_x:10, _y:140});
playButton = mymc.attachMovie("playButton", "playButton", 6, {_x:10, _y:170});
stopButton = mymc.attachMovie("stopButton", "stopButton", 7, {_x:10, _y:200});
saveButton = mymc.attachMovie("saveButton", "saveButton", 8, {_x:10, _y:230});
loadButton = mymc.attachMovie("loadButton", "loadButton", 9, {_x:10, _y:260});
threeDButton = mymc.attachMovie("threeDButton", "threeDButton", 10, {_x:10, _y:290});
helpButton = mymc.attachMovie("helpButton", "helpButton", 11, {_x:10, _y:320});
penButton.onPress = function () {
_root.gui.tools.tool = 1;
_root.cam.focus = -1;
};
targetButton.onPress = function () {
_root.gui.tools.tool = 4;
_root.cam.focus = -1;
};
eraseButton.onPress = function () {
_root.gui.tools.tool = 2;
_root.cam.focus = -1;
};
handButton.onPress = function () {
_root.gui.tools.tool = 3;
_root.cam.focus = -1;
};
clearButton.onPress = function () {
_root.gui.showClearDialog();
};
playButton.onPress = function () {
_root.pauseGame = false;
_root.cam.focus = 1;
};
stopButton.onPress = function () {
_root.restart();
_root.cam.focus = 1;
};
saveButton.onPress = function () {
_root.gui.showSaveDialog();
};
loadButton.onPress = function () {
_root.gui.showLoadDialog();
};
threeDButton.onPress = function () {
if (_root.cam.mode3d) {
_root.cam.mode3d = false;
} else {
_root.cam.mode3d = true;
}
};
helpButton.onPress = function () {
_root.gui.showHelp();
};
}
function onMouseDown() {
if ((_root._xmouse > 40) && (tools.allowDraw)) {
tools.mouseDown();
}
}
function onMouseUp() {
if ((_root._xmouse > 40) && (tools.allowDraw)) {
tools.mouseUp();
}
}
function advance() {
if (_root._xmouse > 40) {
tools.advance();
} else {
tools.mymc.clear();
}
}
function updateMC() {
if (tools.tool == 1) {
penButton._x = penButton._x + ((20 - penButton._x) * 0.7);
} else {
penButton._x = penButton._x + ((10 - penButton._x) * 0.7);
}
if (tools.tool == 4) {
targetButton._x = targetButton._x + ((20 - targetButton._x) * 0.7);
} else {
targetButton._x = targetButton._x + ((10 - targetButton._x) * 0.7);
}
if (tools.tool == 2) {
eraseButton._x = eraseButton._x + ((20 - eraseButton._x) * 0.7);
} else {
eraseButton._x = eraseButton._x + ((10 - eraseButton._x) * 0.7);
}
if ((tools.tool == 3) || (Key.isDown(17))) {
handButton._x = handButton._x + ((20 - handButton._x) * 0.7);
} else {
handButton._x = handButton._x + ((10 - handButton._x) * 0.7);
}
targetInfo.label_1.text = (_root.targets.hit + " / ") + _root.targets.count;
}
function createTargetInfo() {
targetInfo = mymc.createEmptyMovieClip("targetInfo", mymc.getNextHighestDepth());
targetInfo._x = 420;
targetInfo._y = 10;
targetInfo.attachMovie("target", "targetImage", 0, {_x:10, _y:10});
targetInfo.targetImage.stop();
graphics.label("0 / 0", 20, 1, 70, 20, targetInfo);
}
}
Symbol 67 MovieClip [__Packages.parser] Frame 0
class parser
{
function parser () {
}
static function exportTargetSector(pSector) {
var _local2 = "";
var _local1 = 0;
while (_local1 < pSector.myArray.length) {
_local2 = _local2 + (Math.round(pSector.myArray[_local1].pos.x).toString(32) + ",");
_local2 = _local2 + (Math.round(pSector.myArray[_local1].pos.y).toString(32) + " ");
_local1++;
}
return(_local2);
}
static function exportLineSector(pSector) {
var _local2 = "";
var _local1 = 0;
while (_local1 < pSector.myArray.length) {
if (pSector.myArray[_local1].hit == false) {
pSector.myArray[_local1].hit = true;
_local2 = _local2 + (Math.round(pSector.myArray[_local1].p1.x).toString(32) + ",");
_local2 = _local2 + (Math.round(pSector.myArray[_local1].p1.y).toString(32) + ",");
_local2 = _local2 + (Math.round(pSector.myArray[_local1].p2.x).toString(32) + ",");
_local2 = _local2 + (Math.round(pSector.myArray[_local1].p2.y).toString(32) + " ");
}
_local1++;
}
return(_local2);
}
static function export(pLines, pTargets) {
var _local4 = "";
if (pLines != undefined) {
var _local5 = pLines.min.x;
while (_local5 <= pLines.max.x) {
var _local2 = pLines.min.y;
while (_local2 <= pLines.max.y) {
pLines.myArray[_local5][_local2].unHit();
_local2++;
}
_local5++;
}
_local5 = pLines.min.x;
while (_local5 <= pLines.max.x) {
var _local2 = pLines.min.y;
while (_local2 <= pLines.max.y) {
if (pLines.myArray[_local5][_local2] != undefined) {
_local4 = _local4 + exportLineSector(pLines.myArray[_local5][_local2]);
}
_local2++;
}
_local5++;
}
_local4 = _local4 + "#";
_local5 = pTargets.min.x;
while (_local5 <= pTargets.max.x) {
var _local2 = pTargets.min.y;
while (_local2 <= pTargets.max.y) {
if (pTargets.myArray[_local5][_local2] != undefined) {
_local4 = _local4 + exportTargetSector(pTargets.myArray[_local5][_local2]);
}
_local2++;
}
_local5++;
}
}
return(_local4);
}
static function parseLines(file) {
var _local7 = file.split(" ");
var _local2 = 0;
while (_local2 < _local7.length) {
var _local1 = _local7[_local2].split(",", 4);
var _local3 = parseInt(_local1[0], 32);
var _local5 = parseInt(_local1[1], 32);
var _local4 = parseInt(_local1[2], 32);
var _local6 = parseInt(_local1[3], 32);
if ((((Math.abs(_local3) < 5000) && (Math.abs(_local4) < 5000)) && (Math.abs(_local5) < 5000)) && (Math.abs(_local6) < 5000)) {
new line(new cartesian(_local3, _local5), new cartesian(_local4, _local6));
} else {
return(0);
}
_local2++;
}
return(1);
}
static function parseTargets(file) {
var _local5 = file.split(" ", 20);
var _local1 = 0;
while (_local1 < _local5.length) {
var _local4 = _local5[_local1].split(",", 2);
var _local2 = parseInt(_local4[0], 32);
var _local3 = parseInt(_local4[1], 32);
if ((Math.abs(_local2) < 5000) && (Math.abs(_local3) < 5000)) {
new target(new cartesian(_local2, _local3));
} else {
return(0);
}
_local1++;
}
return(1);
}
static function parseMap(file) {
_root.newMap();
parseLines(file.split("#")[0]);
parseTargets(file.split("#")[1]);
}
}
Symbol 68 MovieClip [__Packages.vehicle] Frame 0
class vehicle
{
var mymc, headWheel, leftWheel, rightWheel, baseSpring, rightSpring, leftSpring, dir, dead, letGoX, letGoSpace;
function vehicle () {
trace("new vehicle");
var _local3 = _root.getNextHighestDepth();
mymc = _root.createEmptyMovieClip("vehicle_" + _local3, _local3);
mymc._alpha = 0;
headWheel = new head(new cartesian(0, 0), "head", this);
leftWheel = new wheel(new cartesian(-20, 30), "wheel", this);
rightWheel = new wheel(new cartesian(20, 30), "wheel", this);
baseSpring = new chasse(leftWheel, rightWheel, 35, "chasse", this);
rightSpring = new muscle(rightWheel, headWheel, 35, "arm", this);
leftSpring = new muscle(leftWheel, headWheel, 35, "body", this);
leftSpring.myKey1 = 37;
leftSpring.myKey2 = 39;
rightSpring.myKey2 = 37;
rightSpring.myKey1 = 39;
dir = -1;
dead = false;
swap();
updateMC();
}
function swap() {
dir = dir * -1;
leftWheel.motor = Math.floor(dir + 1) / 2;
rightWheel.motor = (-Math.floor(1 - dir)) / 2;
leftSpring.mymc.gotoAndStop((-dir) + 3);
rightSpring.mymc.gotoAndStop(dir + 3);
leftSpring.mymc._yscale = 100 * dir;
rightSpring.mymc._yscale = 100 * dir;
leftSpring.mymc.swapDepths(rightSpring.mymc);
}
function advance() {
if (Key.isDown(38)) {
leftSpring.trueLength = 35 + (4 * dir);
rightSpring.trueLength = 35 - (4 * dir);
} else {
leftSpring.trueLength = 35;
rightSpring.trueLength = 35;
}
leftWheel.advance();
rightWheel.advance();
headWheel.advance();
leftSpring.advance();
rightSpring.advance();
baseSpring.advance();
if (Key.isDown(88) && (letGoX)) {
letGoX = false;
swap();
}
if (Key.isDown(88) == false) {
letGoX = true;
}
if (Key.isDown(32) && (letGoSpace)) {
_root.restart();
}
if (Key.isDown(32) == false) {
letGoSpace = true;
}
}
function updateMC() {
leftWheel.updateMC();
rightWheel.updateMC();
headWheel.updateMC();
leftSpring.updateMC();
rightSpring.updateMC();
baseSpring.updateMC();
if (dead) {
mymc._alpha = mymc._alpha + -2;
if (mymc._alpha < 4) {
_root.restart();
}
} else {
mymc._alpha = mymc._alpha + ((100 - mymc._alpha) * 0.05);
}
}
function die() {
if (dead == false) {
dead = true;
_root.gui.showDeadDialog();
leftSpring.springConstant = 0.08;
rightSpring.springConstant = 0.08;
leftSpring.dampConstant = 0.1;
rightSpring.dampConstant = 0.1;
}
leftWheel.motor = 0;
rightWheel.motor = 0;
}
}
Symbol 69 MovieClip [__Packages.mass] Frame 0
class mass
{
var pos, posOld, vel, radius, parent, mymc;
function mass (pPos, pFrame, pParent) {
pos = new cartesian(0, 0);
posOld = new cartesian(0, 0);
vel = new cartesian(0, 0);
pos.EQU(pPos);
posOld.EQU(pPos);
radius = 10;
parent = pParent;
var _local2 = parent.mymc.getNextHighestDepth();
mymc = parent.mymc.attachMovie("mass", "mass_" + _local2, _local2);
mymc.gotoAndStop(pFrame);
updateMC();
}
function updateMC() {
mymc._x = pos.x - _root.cam.pos.x;
mymc._y = pos.y - _root.cam.pos.y;
mymc._xscale = radius * 10;
mymc._yscale = radius * 10;
}
function rotate(pDir) {
mymc._rotation = mymc._rotation + (pDir.getUnit().DOT(vel) * 3);
}
function drive(pDir) {
}
function lineForce(pDir) {
pos.INC(pDir);
}
function springForce(pDir) {
vel.INC(pDir);
}
function advance() {
vel.y = vel.y + 0.8;
vel.EQU(vel.FACTOR(0.98));
pos.INC(vel);
_root.lines.checkMass(this);
_root.targets.checkMass(this);
vel.EQU(pos.SUB(posOld));
posOld.EQU(pos);
}
}
Symbol 70 MovieClip [__Packages.head] Frame 0
class head extends mass
{
var vel, pos, parent, posOld;
function head (pPos, pFrame, pParent) {
super(pPos, pFrame, pParent);
}
function advance() {
vel.y = vel.y + 0.6;
vel.EQU(vel.FACTOR(0.98));
pos.INC(vel);
if (pos.y > ((_root.lines.max.y + 5) * _root.lines.sectorSize)) {
parent.die();
}
_root.lines.checkMass(this);
_root.targets.checkMass(this);
vel.EQU(pos.SUB(posOld));
posOld.EQU(pos);
}
function lineForce(pDir) {
pos.INC(pDir);
parent.die();
}
}
Symbol 71 MovieClip [__Packages.wheel] Frame 0
class wheel extends mass
{
var motor, accel, contact, pos, vel, posOld;
function wheel (pPos, pFrame, pParent) {
super(pPos, pFrame, pParent);
motor = 0;
accel = 0;
}
function drive(pDir) {
contact = true;
if (Key.isDown(38)) {
_root.cam.focus = 1;
accel = accel + ((2.5 - accel) * 0.1);
pos.INC(pDir.FACTOR(accel * motor));
} else {
accel = 0;
}
if (Key.isDown(40)) {
pos.INC(pDir.FACTOR((-pDir.DOT(vel)) * 0.5));
}
}
function advance() {
vel.y = vel.y + 0.6;
vel.EQU(vel.FACTOR(0.98));
pos.INC(vel);
contact = false;
_root.lines.checkMass(this);
_root.targets.checkMass(this);
if (contact == false) {
accel = 0;
trace(accel);
}
vel.EQU(pos.SUB(posOld));
posOld.EQU(pos);
}
}
Symbol 72 MovieClip [__Packages.spring] Frame 0
class spring
{
var m1, m2, length, dampConstant, springConstant, parent, mymc, s, dist, tens, damp;
function spring (pM1, pM2, pL, pFrame, pParent) {
m1 = pM1;
m2 = pM2;
length = pL;
dampConstant = 0.4;
springConstant = 0.6;
parent = pParent;
var _local2 = parent.mymc.getNextHighestDepth();
mymc = parent.mymc.attachMovie("spring", "spring_" + _local2, _local2);
mymc.gotoAndStop(pFrame);
}
function updateMC() {
var _local3 = m1.pos.ADD(m2.pos).FACTOR(0.5);
mymc._x = _local3.x - _root.cam.pos.x;
mymc._y = _local3.y - _root.cam.pos.y;
mymc._rotation = s.getPolar().aDegs();
if (springConstant == 0) {
mymc._alpha = mymc._alpha + ((-mymc._alpha) * 0.2);
} else {
mymc._alpha = 100;
}
}
function advance() {
s = m2.pos.SUB(m1.pos);
dist = s.getLength();
tens = s.FACTOR(((dist - length) * springConstant) / dist);
damp = m2.vel.SUB(m1.vel).DOT(s.getUnit()) * dampConstant;
tens.INC(s.FACTOR(damp / dist));
m2.springForce(tens.FACTOR(-1));
m1.springForce(tens);
}
}
Symbol 73 MovieClip [__Packages.chasse] Frame 0
class chasse extends spring
{
var m1, m2, mymc, s, length, parent, dist, tens, springConstant, damp, dampConstant;
function chasse (pM1, pM2, pL, pFrame, pParent) {
super(pM1, pM2, pL, pFrame, pParent);
}
function updateMC() {
var _local3 = m1.pos.ADD(m2.pos).FACTOR(0.5);
mymc._x = _local3.x - _root.cam.pos.x;
mymc._y = _local3.y - _root.cam.pos.y;
mymc._rotation = s.getPolar().aDegs();
mymc._xscale = mymc._xscale + (((((parent.dir * s.getLength()) / length) * 100) - mymc._xscale) * 0.3);
}
function advance() {
s = m2.pos.SUB(m1.pos);
dist = s.getLength();
if (Key.isDown(37)) {
var _local2 = s.FACTOR(0.3 / dist);
_local2 = new cartesian(-_local2.y, _local2.x);
m1.pos.INC(_local2);
m2.pos.INC(_local2.FACTOR(-1));
}
if (Key.isDown(39)) {
var _local2 = s.FACTOR(0.3 / dist);
_local2 = new cartesian(-_local2.y, _local2.x);
m2.pos.INC(_local2);
m1.pos.INC(_local2.FACTOR(-1));
}
tens = s.FACTOR(((dist - length) * springConstant) / dist);
damp = m2.vel.SUB(m1.vel).DOT(s.getUnit()) * dampConstant;
tens.INC(s.FACTOR(damp / dist));
m2.springForce(tens.FACTOR(-1));
m1.springForce(tens);
}
}
Symbol 74 MovieClip [__Packages.muscle] Frame 0
class muscle extends spring
{
var trueLength, s, m2, m1, dist, myKey1, myKey2, length, tens, springConstant, damp, dampConstant;
function muscle (pM1, pM2, pL, pFrame, pParent) {
super(pM1, pM2, pL, pFrame, pParent);
trueLength = pL;
}
function advance() {
s = m2.pos.SUB(m1.pos);
dist = s.getLength();
if (!(Key.isDown(myKey1) || (Key.isDown(myKey2)))) {
length = length + ((trueLength - length) * 0.1);
}
if (Key.isDown(myKey1)) {
length = length + (((trueLength - 5) - length) * 0.15);
}
if (Key.isDown(myKey2)) {
length = length + (((trueLength + 5) - length) * 0.15);
}
tens = s.FACTOR(((dist - length) * springConstant) / dist);
damp = m2.vel.SUB(m1.vel).DOT(s.getUnit()) * dampConstant;
tens.INC(s.FACTOR(damp / dist));
m2.springForce(tens.FACTOR(-1));
m1.springForce(tens);
}
}
Symbol 75 MovieClip [__Packages.fpsCounter] Frame 0
class fpsCounter
{
var count2, count, lastTimer;
function fpsCounter () {
count2 = 0;
count = 0;
lastTimer = getTimer();
_root.createEmptyMovieClip("fpsLayer", _root.getNextHighestDepth());
_root.fpsLayer.createTextField("textfield", 1, 10, 1, 70, 15);
var _local3 = new TextFormat();
_local3.font = "_sans";
_local3.size = 10;
_local3.color = 11184810 /* 0xAAAAAA */;
_root.fpsLayer.textfield.setNewTextFormat(_local3);
_root.fpsLayer.textfield.selectable = false;
_root.fpsLayer._x = 430;
_root.fpsLayer._y = 380;
report();
}
function report() {
var _local3 = getTimer() - lastTimer;
if (_local3 > 0) {
var _local4 = Math.round((sampleRate * (1000 / _local3)) * 100) / 100;
lastTimer = getTimer();
_root.fpsLayer.textfield.text = "FPS:" + _local4;
_root.fpsLayer.clear();
}
}
function advance() {
count++;
if (count >= sampleRate) {
report();
count = 0;
}
}
var sampleRate = 50;
}
Symbol 76 MovieClip [__Packages.lineHandler] Frame 0
class lineHandler
{
var myArray, mymc, sectorSize, min, max;
function lineHandler () {
trace("new lineHandler");
myArray = new Array();
mymc = _root.createEmptyMovieClip("lineLayer", _root.getNextHighestDepth());
sectorSize = 50;
min = new cartesian(0, 0);
max = new cartesian(0, 0);
}
function updateMC() {
mymc.clear();
var _local6 = Math.floor(_root.cam.pos.x / sectorSize);
var _local4 = Math.floor(_root.cam.pos.y / sectorSize);
var _local5 = _local6;
while (_local5 < (_local6 + 12)) {
var _local3 = _local4;
while (_local3 < (_local4 + 10)) {
myArray[_local5][_local3].unHit();
_local3++;
}
_local5++;
}
_local5 = _local6;
while (_local5 < (_local6 + 12)) {
var _local3 = _local4;
while (_local3 < (_local4 + 10)) {
myArray[_local5][_local3].updateMC();
_local3++;
}
_local5++;
}
}
function addRef(pX, pY, pObj) {
var _local2 = Math.floor(pX / sectorSize);
var _local3 = Math.floor(pY / sectorSize);
min.x = Math.min(_local2, min.x);
min.y = Math.min(_local3, min.y);
max.x = Math.max(_local2, max.x);
max.y = Math.max(_local3, max.y);
if (myArray[_local2] == undefined) {
myArray[_local2] = new Array();
}
if (myArray[_local2][_local3] == undefined) {
myArray[_local2][_local3] = new sector(_local2, _local3);
}
myArray[_local2][_local3].plus(pObj);
}
function checkMass(pObj) {
var _local2 = Math.floor((pObj.pos.x / sectorSize) - 0.5);
var _local3 = Math.floor((pObj.pos.y / sectorSize) - 0.5);
myArray[_local2][_local3].unHit();
myArray[_local2 + 1][_local3].unHit();
myArray[_local2 + 1][_local3 + 1].unHit();
myArray[_local2][_local3 + 1].unHit();
myArray[_local2][_local3].checkMass(pObj);
myArray[_local2 + 1][_local3].checkMass(pObj);
myArray[_local2 + 1][_local3 + 1].checkMass(pObj);
myArray[_local2][_local3 + 1].checkMass(pObj);
}
function erase(pPos) {
var _local2 = Math.floor((pPos.x / sectorSize) - 0.5);
var _local3 = Math.floor((pPos.y / sectorSize) - 0.5);
myArray[_local2][_local3].erase(pPos);
myArray[_local2 + 1][_local3].erase(pPos);
myArray[_local2 + 1][_local3 + 1].erase(pPos);
myArray[_local2][_local3 + 1].erase(pPos);
}
}
Symbol 77 MovieClip [__Packages.sector] Frame 0
class sector
{
var myArray, i, j;
function sector (pI, pJ) {
myArray = new Array();
i = pI;
j = pJ;
}
function unHit() {
var _local2 = 0;
while (_local2 < myArray.length) {
myArray[_local2].hit = false;
_local2++;
}
}
function checkMass(pObj) {
var _local2 = 0;
while (_local2 < myArray.length) {
myArray[_local2].checkMass(pObj);
_local2++;
}
}
function updateMC() {
var _local2 = 0;
while (_local2 < myArray.length) {
myArray[_local2].updateMC();
if (myArray[_local2].active == false) {
myArray.splice(_local2, 1);
}
_local2++;
}
}
function erase(pPos) {
var _local2 = 0;
while (_local2 < myArray.length) {
if (myArray[_local2].erase(pPos) == 1) {
myArray.splice(_local2, 1);
}
_local2++;
}
}
function plus(pObj) {
if (myArray.length < 8) {
myArray.push(pObj);
}
}
}
Symbol 78 MovieClip [__Packages.targetHandler] Frame 0
class targetHandler
{
var myArray, mymc, sectorSize, count, hit, min, max;
function targetHandler () {
trace("new targetHandler");
myArray = new Array();
mymc = _root.createEmptyMovieClip("targetLayer", _root.getNextHighestDepth());
sectorSize = 50;
count = 0;
hit = 0;
min = new cartesian(0, 0);
max = new cartesian(0, 0);
}
function updateMC() {
var _local5 = 0;
while (_local5 < mymc.getNextHighestDepth()) {
mymc.getInstanceAtDepth(_local5)._visible = false;
_local5++;
}
var _local7 = Math.floor(_root.cam.pos.x / sectorSize);
var _local6 = Math.floor(_root.cam.pos.y / sectorSize);
var _local4 = _local7;
while (_local4 < (_local7 + 12)) {
var _local3 = _local6;
while (_local3 < (_local6 + 10)) {
myArray[_local4][_local3].updateMC();
_local3++;
}
_local4++;
}
}
function addRef(pX, pY, pObj) {
var _local2 = Math.floor(pX / sectorSize);
var _local3 = Math.floor(pY / sectorSize);
min.x = Math.min(_local2, min.x);
min.y = Math.min(_local3, min.y);
max.x = Math.max(_local2, max.x);
max.y = Math.max(_local3, max.y);
if (myArray[_local2] == undefined) {
myArray[_local2] = new Array();
}
if (myArray[_local2][_local3] == undefined) {
myArray[_local2][_local3] = new sector(_local2, _local3);
}
myArray[_local2][_local3].plus(pObj);
}
function checkMass(pObj) {
var _local2 = Math.floor((pObj.pos.x / sectorSize) - 0.5);
var _local3 = Math.floor((pObj.pos.y / sectorSize) - 0.5);
myArray[_local2][_local3].checkMass(pObj);
myArray[_local2 + 1][_local3].checkMass(pObj);
myArray[_local2 + 1][_local3 + 1].checkMass(pObj);
myArray[_local2][_local3 + 1].checkMass(pObj);
}
function erase(pPos) {
var _local2 = Math.floor((pPos.x / sectorSize) - 0.5);
var _local3 = Math.floor((pPos.y / sectorSize) - 0.5);
myArray[_local2][_local3].erase(pPos);
myArray[_local2 + 1][_local3].erase(pPos);
myArray[_local2 + 1][_local3 + 1].erase(pPos);
myArray[_local2][_local3 + 1].erase(pPos);
}
function restart() {
hit = 0;
var _local3 = min.x;
while (_local3 <= max.x) {
var _local2 = min.y;
while (_local2 <= max.y) {
myArray[_local3][_local2].unHit();
_local2++;
}
_local3++;
}
}
}