Frame 1
stop();
car1.code = "player";
totalLaps = 10;
acceleration = 0.4;
speedDecay = 0.96;
rotationStep = 10;
maxSpeed = 10;
backSpeed = 1;
currentCheckpoint1 = 1;
currentLap1 = 0;
checkpoints = 2;
currentLapTXT = "1/10";
function step(who) {
if (_root["car" + who].code == "player") {
if (this["speed" + who] > 0.3) {
this["speed" + who] = this["speed" + who] * _root.speedDecay;
} else {
this["speed" + who] = 0;
}
if (Key.isDown(38) && (this["speed" + who] < _root.maxSpeed)) {
this["speed" + who] = this["speed" + who] + _root.acceleration;
}
if (Key.isDown(40)) {
this["speed" + who] = this["speed" + who] - _root.backSpeed;
}
if (Key.isDown(37) && (Math.abs(this["speed" + who]) > 0.3)) {
_root["car" + who]._rotation = _root["car" + who]._rotation - (_root.rotationStep * (this["speed" + who] / _root.maxSpeed));
}
if (Key.isDown(39) && (Math.abs(this["speed" + who]) > 0.3)) {
_root["car" + who]._rotation = _root["car" + who]._rotation + (_root.rotationStep * (this["speed" + who] / _root.maxSpeed));
}
this["rotation" + who] = _root["car" + who]._rotation;
this["speedx" + who] = Math.sin(this["rotation" + who] * (Math.PI/180)) * this["speed" + who];
this["speedy" + who] = (Math.cos(this["rotation" + who] * (Math.PI/180)) * this["speed" + who]) * -1;
_root["car" + who]._x = _root["car" + who]._x + this["speedx" + who];
_root["car" + who]._y = _root["car" + who]._y + this["speedy" + who];
_root["car" + who].pointLeft = {x:-20, y:0};
_root["car" + who].localToGlobal(_root["car" + who].pointLeft);
_root["car" + who].pointRight = {x:20, y:0};
_root["car" + who].localToGlobal(_root["car" + who].pointRight);
_root["car" + who].pointFront = {x:0, y:-25};
_root["car" + who].localToGlobal(_root["car" + who].pointFront);
_root["car" + who].pointBack = {x:0, y:25};
_root["car" + who].localToGlobal(_root["car" + who].pointBack);
this["lpx" + who] = _root["car" + who].pointLeft.x;
this["lpy" + who] = _root["car" + who].pointLeft.y;
this["rpx" + who] = _root["car" + who].pointRight.x;
this["rpy" + who] = _root["car" + who].pointRight.y;
this["fpx" + who] = _root["car" + who].pointFront.x;
this["fpy" + who] = _root["car" + who].pointFront.y;
this["bpx" + who] = _root["car" + who].pointBack.x;
this["bpy" + who] = _root["car" + who].pointBack.y;
if (_root.terrain.hitTest(this["lpx" + who], this["lpy" + who], true)) {
_root["car" + who]._rotation = _root["car" + who]._rotation + 5;
this["speed" + who] = this["speed" + who] * 0.85;
}
if (_root.terrain.hitTest(this["rpx" + who], this["rpy" + who], true)) {
_root["car" + who]._rotation = _root["car" + who]._rotation - 5;
this["speed" + who] = this["speed" + who] * 0.85;
}
if (_root.terrain.hitTest(this["fpx" + who], this["fpy" + who], true)) {
this["speed" + who] = -1;
}
if (_root.terrain.hitTest(this["bpx" + who], this["bpy" + who], true)) {
this["speed" + who] = 1;
}
_root["shadow" + who]._x = _root["car" + who]._x - 4;
_root["shadow" + who]._y = _root["car" + who]._y + 2;
_root["shadow" + who]._rotation = _root["car" + who]._rotation;
if (_root["car" + who].hitTest(_root["checkpoint" + _root["currentCheckpoint" + who]])) {
if (_root["currentCheckpoint" + who] == 1) {
if (_root["currentLap" + who] != 0) {
_root.setBestLap();
}
if (_root["currentLap" + who] == _root.totalLaps) {
_root.gotoAndStop("finish");
} else {
_root["currentLap" + who]++;
}
_root.currentLapTXT = _root["currentLap" + who] + "/10";
}
_root["currentCheckpoint" + who]++;
if (_root["currentCheckpoint" + who] > _root.checkpoints) {
_root["currentCheckpoint" + who] = 1;
}
}
}
if (_root["car" + who].code == "computer") {
}
}
function setTimes() {
timeElapsed = getTimer() - _root.initialTime;
milliseconds = timeElapsed;
seconds = Math.floor(milliseconds / 1000);
minutes = Math.floor(seconds / 60);
minutesTXT = minutes;
secondsTXT = seconds - (minutes * 60);
tensTXT = Math.round((milliseconds - (seconds * 1000)) / 10);
if (minutesTXT < 10) {
minutesTXT = "0" + minutesTXT;
}
if (secondsTXT < 10) {
secondsTXT = "0" + secondsTXT;
}
if (tensTXT < 10) {
tensTXT = "0" + tensTXT;
}
_root.totalTimeTXT = (((minutesTXT + ".") + secondsTXT) + ".") + tensTXT;
}
function setBestLap() {
bestTime = getTimer() - _root.lapTime;
milliseconds = bestTime;
if ((oldMilliseconds > milliseconds) || (oldMilliseconds == null)) {
oldMilliseconds = milliseconds;
seconds = Math.floor(milliseconds / 1000);
minutes = Math.floor(seconds / 60);
minutesTXT = minutes;
secondsTXT = seconds - (minutes * 60);
tensTXT = Math.round((milliseconds - (seconds * 1000)) / 10);
if (minutesTXT < 10) {
minutesTXT = "0" + minutesTXT;
}
if (secondsTXT < 10) {
secondsTXT = "0" + secondsTXT;
}
if (tensTXT < 10) {
tensTXT = "0" + tensTXT;
}
_root.bestLapTXT = (((minutesTXT + ".") + secondsTXT) + ".") + tensTXT;
}
_root.lapTime = getTimer();
}
Instance of Symbol 4 MovieClip "terrain" in Frame 1
onClipEvent (load) {
this._visible = false;
}
Frame 2
stop();
initialTime = getTimer();
lapTime = initialTime;
Instance of Symbol 34 MovieClip "stepper" in Frame 2
onClipEvent (load) {
speed1 = 0;
}
onClipEvent (enterFrame) {
_root.setTimes();
_root.step(1);
}
Frame 3
stop();
Symbol 25 MovieClip Frame 50
_root.soundmc.engineStart.start(0, 1);
_root.soundmc.engineLoop.start(0, 9999);
_root.soundmc.engineLoop.setVolume(40);
_root.play();
Symbol 25 MovieClip Frame 72
stop();
Symbol 39 Button
on (release) {
_root.gotoAndPlay("readySet");
}
Symbol 44 MovieClip Frame 11
stop();