Combined Code
movieClip 1 skidmark {
frame 71 {
this.removemovieclip();
}
}
frame 1 {
txtPercentage = Math.round((_root.getBytesLoaded() / _root.getBytesTotal()) * 100) + '% loaded';
tellTarget ('loader') {
gotoAndPlay(Math.round((_root.getBytesLoaded() / _root.getBytesTotal()) * 100));
}
}
button 16 {
on (release) {
_root.gotoAndPlay(3);
}
}
movieClip 17 {
frame 1 {
stop();
}
}
frame 2 {
if (_root.getBytesLoaded() == _root.getBytesTotal()) {
gotoAndStop(3);
} else {
gotoAndPlay(1);
}
}
frame 3 {
t;
}
frame 3 {
play();
}
button 21 {
on (release) {
getURL('http://www.liquidgeneration.com/', '_blank');
}
}
button 27 {
on (release) {
getURL('http://www.liquidgeneration.com/s2f/?/games/car_race.asp', '_blank');
}
}
frame 94 {
stop();
_root:carBody = 0;
_root.car._alpha = 0;
lives = 3;
yourLives = 'lives' + lives;
}
movieClip 40 {
frame 25 {
stop();
}
frame 33 {
stop();
}
}
movieClip 43 {
}
movieClip 44 {
}
movieClip 55 {
frame 1 {
gotoAndStop(_root:carBody);
}
}
button 61 {
on (release) {
_root.title.play();
_parent.gotoAndPlay('selected');
}
}
movieClip 62 {
frame 1 {
stop();
}
frame 2 {
play();
}
frame 5 {
stop();
}
}
button 64 {
on (rollOver) {
gotoAndStop('1');
}
on (rollOut) {
gotoAndStop('stop');
}
on (release) {
_root:carBody = 1;
yours.car.gotoAndStop(_root:carBody);
yours.gotoAndStop(2);
}
}
button 65 {
on (rollOver) {
gotoAndStop('2');
}
on (rollOut) {
gotoAndStop('stop');
}
on (release) {
_root:carBody = 2;
yours.car.gotoAndStop(_root:carBody);
yours.gotoAndStop(2);
}
}
button 66 {
on (rollOver) {
gotoAndStop('3');
}
on (rollOut) {
gotoAndStop('stop');
}
on (release) {
_root:carBody = 3;
yours.car.gotoAndStop(_root:carBody);
yours.gotoAndStop(2);
}
}
button 67 {
on (rollOver) {
gotoAndStop('4');
}
on (rollOut) {
gotoAndStop('stop');
}
on (release) {
_root:carBody = 4;
yours.car.gotoAndStop(_root:carBody);
yours.gotoAndStop(2);
}
}
button 68 {
on (rollOver) {
gotoAndStop('5');
}
on (rollOut) {
gotoAndStop('stop');
}
on (release) {
_root:carBody = 5;
yours.car.gotoAndStop(_root:carBody);
yours.gotoAndStop(2);
}
}
button 69 {
on (rollOver) {
gotoAndStop('6');
}
on (rollOut) {
gotoAndStop('stop');
}
on (release) {
_root:carBody = 6;
yours.car.gotoAndStop(_root:carBody);
yours.gotoAndStop(2);
}
}
movieClip 77 {
frame 14 {
stop();
}
frame 36 {
stop();
_root.nextFrame();
}
}
frame 95 {
stop();
}
button 91 {
on (release) {
play();
}
}
frame 106 {
stopAllSounds();
}
movieClip 100 {
frame 62 {
_root.nextFrame();
stop();
}
}
frame 108 {
stop();
}
frame 109 {
stop();
_root.track_x = track._x;
_root.track_y = track._y;
LGtimer = function () {
this.reset();
};
LGt = LGtimer.prototype;
LGt.reset = function () {
this.oldTime = 0;
this.pause = true;
this.totalTime = 0;
};
LGt.stop = function () {
if (!this.pause) {
this.pause = true;
this.totalTime += getTimer() - this.oldTime;
}
};
LGt.start = function () {
if (this.pause) {
this.pause = false;
this.oldTime = getTimer();
}
};
LGt.getMili = function () {
var returnTime = this.totalTime;
if (!this.pause) {
returnTime += getTimer() - this.oldTime;
}
return returnTime;
};
LGt.getSecs = function () {
var returnTime = this.totalTime / 1000;
if (!this.pause) {
returnTime += (getTimer() - this.oldTime) / 1000;
}
return Math.round(returnTime);
};
LGt.getMins = function () {
var returnTime = this.totalTime / 1000;
if (!this.pause) {
returnTime += (getTimer() - this.oldTime) / 1000 / 60;
}
return Math.round(returnTime);
};
LGt.getCount = function (secs) {
var returnTime = this.totalTime;
if (!this.pause) {
returnTime += (getTimer() - this.oldTime) / 1000;
}
var count = secs - returnTime;
return Math.round(count);
};
}
movieClip 106 {
}
movieClip 108 {
}
movieClip 110 {
frame 1 {
stop();
}
}
movieClip 113 {
frame 1 {
stop();
}
}
movieClip 116 {
}
movieClip 117 {
frame 1 {
stop();
_root:loseRound = false;
_root:otherLap = 0;
}
frame 751 {
++_root:otherLap;
if (_root:otherLap < 3) {
gotoAndPlay(2);
} else {
stop();
_root:loseRound = true;
}
}
}
movieClip 118 {
frame 1 {
this.track._visible = false;
this.rough._visible = false;
this.water._visible = false;
this.slick._visible = false;
this.check0._visible = false;
this.crunchers._visible = false;
stop();
}
}
movieClip 127 {
frame 1 {
lap = '0' + _root:otherLap;
}
frame 2 {
lap = '0' + _root:otherLap;
if (_root:loseRound == true) {
--_root:lives;
_root:yourLives = 'lives' + _root:lives;
_root.life.gotoAndPlay(_root:yourLives);
play();
} else {
gotoAndPlay(1);
}
}
frame 6 {
stop();
_root.gotoAndStop('lose1');
}
}
instance car of movieClip 55 {
onClipEvent (load) {
angle = 1.5609317684435;
_rotation = angle * 180 / Math.PI;
_root:track_x = _root.track._x;
_root:track_y = _root.track._y;
_root.lap1 = '';
_root.lap2 = '';
_root.lap3 = '';
_root.timer = '';
}
}
movieClip 140 {
frame 1 {
stop();
}
}
movieClip 146 {
frame 70 {
_root.nextFrame();
this.removeMovieClip();
}
}
movieClip 149 {
}
movieClip 151 {
frame 1 {
stop();
gotoAndStop(_root:yourLives);
}
frame 8 {
stop();
}
frame 15 {
stop();
}
frame 22 {
stop();
}
frame 29 {
stop();
}
}
movieClip 154 {
}
movieClip 156 {
}
frame 110 {
stop();
_root.track.otherGuy.play();
}
instance car of movieClip 55 {
onClipEvent (load) {
function getPos(clip) {
var p = {'x': 0, 'y': 0};
clip.localToGlobal(p);
return p;
}
function two(x) {
if (9 >= x) {
return '0' + x;
}
return '' + x;
}
function three(x) {
if (9 >= x) {
return (99 < x ? '' : '0') + '0' + x;
}
return (99 < x ? '' : '0') + '' + x;
}
function displaytime(ms) {
var sec = Math.floor(ms / 1000);
ms %= 1000;
var t = three(ms);
var min = Math.floor(sec / 60);
sec %= 60;
t = two(sec) + ':' + t;
var hr = Math.floor(min / 60);
min %= 60;
t = two(min) + ':' + t;
return t;
}
function skid(Handbrakey) {
var skidleft = _root.track.attachMovie('skidmark', 'skidleft' + skids, skids);
var i = 0;
while (i < this.displaywheels) {
wheelsPos[i] = getPos(this['w' + i]);
if (handbrakey) {
skidleft.lineStyle(4, 0, 70);
skidleft.moveto(this.wheelsPos[i].x - track_x, this.wheelsPos[i].y - track_y);
skidleft.lineTo(this.lastpos[i].x, this.lastpos[i].y);
} else {
skidleft.lineStyle(3, 0, 50);
skidleft.moveto(this.wheelsPos[i].x - track_x, this.wheelsPos[i].y - track_y);
skidleft.lineTo(this.lastpos[i].x, this.lastpos[i].y);
}
lastpos[i].x = this.wheelsPos[i].x - track_x;
lastpos[i].y = this.wheelsPos[i].y - track_y;
++skids;
++i;
}
return true;
}
function setLastpos() {
var i = 0;
while (i < this.displaywheels) {
this.wheelsPos[i] = getPos(this['w' + i]);
lastpos[i].x = this.wheelsPos[i].x - track_x;
lastpos[i].y = this.wheelsPos[i].y - track_y;
++i;
}
}
function adjust(v, threshold, maximum) {
vx = 0;
if (threshold >= v) {
vx = (v / threshold) * 1;
return vx;
}
vx = 1;
return vx;
}
accel = 0.2;
steer = 0.08;
steer_normal = 0.08;
steer_handbrake = 0.09900000000000001;
steer_threshold = 4;
MINspd = -5;
MAXspd = 22;
MAXskiddisplay = 2;
MAXturnSpd = 10;
MaxTurnSkid = 18;
deccel = 0.92;
handbrake = 0.9300000000000001;
handbrake_traction = 20;
drift = 0.98;
speed = 0;
surface = 4;
traction = 5;
traction_max = 1;
vector = [0, 0];
bounceBack = 0.6;
laptimesA = new Array();
laps = 3;
i = 1;
while (laps >= i) {
laptimesA[i] = 0;
++i;
}
checkpoints = new Array();
checks = 4;
i = 0;
while (checks >= i) {
checkpoints[i] = false;
++i;
}
lap = 0;
collide = false;
track_x = _root:track_x;
track_y = _root:track_y;
angle = 1.5609317684435;
_rotation = angle * 180 / Math.PI;
myTimer = new _root.LGtimer();
displaywheels = 2;
wheelsPos = new Array();
lastPos = new Array();
var i = 0;
while (i < displaywheels) {
wheelsPos[i] = getPos(this['w' + i]);
lastPos[i] = wheelspos[i];
++i;
}
skidding = false;
turnskidding = false;
skids = 1;
myTimer.start();
}
onClipEvent (enterFrame) {
_rotation = angle * 180 / Math.PI;
_root.track._x = track_x;
_root.track._y = track_y;
UD = Key.isDown(38) - Key.isDown(40);
LR = Key.isDown(39) - Key.isDown(37);
HAND = Key.isDown(32);
if (LR) {
angle += LR * steer * adjust(Math.Abs(speed), steer_threshold, MAXSpd);
if (maxturnskid < speed) {
if (!turnskidding) {
setLastpos();
}
turnskidding = skid(HAND);
} else {
turnskidding = false;
}
} else {
turnskidding = false;
}
if (!UD) {
speed *= drift;
} else {
if (UD & !HAND) {
speed = Math.min(Math.max(speed + UD * accel, MINspd), MAXspd);
}
}
if (Math.abs(speed) < accel / 2) {
speed = 0;
}
if (HAND) {
speed *= handbrake;
if (MAXskiddisplay < speed) {
steer = steer_handbrake;
if (!skidding) {
setLastpos();
}
skidding = skid(HAND);
}
traction = handbrake_traction / surface;
} else {
skidding = false;
traction = Math.max(traction_max, Math.abs((speed - MAXturnSpd) / surface));
steer = steer_normal;
}
if (speed < 0) {
traction = 1;
}
if (!_root.track.track.hittest(_x, _y, true)) {
speed *= 0.95;
traction *= 1.2;
}
if (_root.track.rough.hittest(_x, _y, true)) {
speed *= 0.9;
traction *= 0.95;
} else {
if (_root.track.slick.hittest(_x, _y, true)) {
speed *= 1.1;
} else {
if (_root.track.water.hittest(_x, _y, true)) {
traction *= 4;
} else {}
}
}
var frontpos = new Array();
var i = 0;
while (i < this.displaywheels) {
this.frontpos[i] = getPos(this['f' + i]);
++i;
}
if (_root.track.crunchers.hittest(frontpos[0].x, frontpos[0].y, true) & !collide || _root.track.crunchers.hittest(frontpos[1].x, frontpos[1].y, true) & !collide) {
speed = -speed * bounceback;
vector[0] = -vector[0];
vector[1] = -vector[1];
collide = true;
} else {
if (_root.track.otherGuy.hittest(frontpos[0].x, frontpos[0].y, true) & !collide || _root.track.otherGuy.hittest(frontpos[1].x, frontpos[1].y, true) & !collide) {
speed = -speed * bounceback;
vector[0] = -vector[0];
vector[1] = -vector[1];
collide = true;
} else {
collide = false;
}
}
vector[0] += (Math.cos(angle) * speed - vector[0]) / traction;
track_x += vector[0];
vector[1] += (Math.sin(angle) * speed - vector[1]) / traction;
track_y += vector[1];
_root.timer = displaytime(myTimer.getMili());
_root.speedHand._rotation = Math.max(-11, Math.Abs(speed * 8.5));
if (_root.track.check1.hittest(_x, _y, true)) {
checkpoints[1] = true;
_root.track.check1.gotoAndPlay(5);
}
if (_root.track.check2.hittest(_x, _y, true)) {
checkpoints[2] = true;
_root.track.check2.gotoAndPlay(5);
}
if (_root.track.check3.hittest(_x, _y, true)) {
checkpoints[3] = true;
_root.track.check3.gotoAndPlay(5);
}
if (_root.track.check4.hittest(_x, _y, true)) {
checkpoints[4] = true;
_root.track.check4.gotoAndPlay(5);
}
if (_root.track.check0.hittest(_x, _y, true)) {
if (checkpoints[1] & checkpoints[2] & checkpoints[3] & checkpoints[4]) {
_root.lapDisplay.play();
++lap;
_root.yourTimer.nextFrame();
if (lap == 1) {
laptimesA[1] = myTimer.getMili();
_root.lap1 = displaytime(laptimesA[1]);
} else {
if (lap == 2) {
laptimesA[2] = myTimer.getMili() - laptimesA[1];
_root.lap2 = displaytime(laptimesA[2]);
} else {
if (lap == 3) {
laptimesA[3] = myTimer.getMili() - laptimesA[2] - laptimesA[1];
_root.lap3 = displaytime(laptimesA[3]);
}
}
}
i = 0;
while (checks >= i) {
checkpoints[i] = false;
++i;
}
if (lap >= laps) {
mytimer.stop();
_root.racetimer = myTimer.getMili();
_root:bestlaptime = Math.min(laptimesA[1], Math.min(laptimesA[2], laptimesA[3]));
if (laptimesA[2] < laptimesA[1] && laptimesA[3] < laptimesA[1]) {
_root:bestLapNumA = 1;
} else {
if (laptimesA[1] < laptimesA[2] && laptimesA[3] < laptimesA[2]) {
_root:bestLapNumA = 2;
} else {
if (laptimesA[1] < laptimesA[3] && laptimesA[2] < laptimesA[3]) {
_root:bestLapNumA = 3;
}
}
}
_root.nextFrame();
}
}
}
}
}
movieClip 160 {
frame 1 {
nextFrame();
}
frame 26 {
nextFrame();
}
frame 51 {
nextFrame();
}
frame 76 {
_root.nextFrame();
}
}
frame 111 {
function two(x) {
if (9 >= x) {
return '0' + x;
}
return '' + x;
}
function three(x) {
if (9 >= x) {
return (99 < x ? '' : '0') + '0' + x;
}
return (99 < x ? '' : '0') + '' + x;
}
function displaytime(ms) {
var sec = Math.floor(ms / 1000);
ms %= 1000;
var t = three(ms);
var min = Math.floor(sec / 60);
sec %= 60;
t = two(sec) + ':' + t;
var hr = Math.floor(min / 60);
min %= 60;
t = two(min) + ':' + t;
return t;
}
_root.totalraceA = displaytime(_root.racetimer);
_root.bestlapA = displaytime(_root.bestlaptime);
stop();
}
frame 112 {
_root.track.otherGuy.stop();
stop();
}
button 173 {
on (release) {
stopAllSounds();
gotoAndStop('track2');
}
}
button 186 {
on (release) {
gotoAndPlay(3);
}
}
movieClip 191 {
frame 63 {
_root.nextFrame();
stop();
}
}
frame 122 {
stop();
_root.track_x = track._x;
_root.track_y = track._y;
}
movieClip 195 {
}
movieClip 197 {
}
movieClip 199 {
}
movieClip 201 {
}
movieClip 204 {
}
movieClip 205 {
frame 1 {
stop();
_root:loseRound = false;
_root:otherLap = 0;
}
frame 977 {
++_root:otherLap;
if (_root:otherLap < 3) {
gotoAndPlay(2);
} else {
stop();
_root:loseRound = true;
}
}
}
movieClip 206 {
frame 1 {
this.track._visible = false;
this.crunchers._visible = false;
this.rough._visible = false;
this.slick._visible = false;
this.check0._visible = false;
stop();
}
}
movieClip 213 {
frame 1 {
lap = '0' + _root:otherLap;
}
frame 2 {
lap = '0' + _root:otherLap;
if (_root:loseRound == true) {
--_root:lives;
_root:yourLives = 'lives' + _root:lives;
_root.life.gotoAndPlay(_root:yourLives);
play();
} else {
gotoAndPlay(1);
}
}
frame 6 {
stop();
_root.gotoAndStop('lose2');
}
}
instance car of movieClip 55 {
onClipEvent (load) {
_root:track_x = _root.track._x;
_root:track_y = _root.track._y;
angle = 1.5609317684435;
_rotation = angle * 180 / Math.PI;
_root.lap1 = '';
_root.lap2 = '';
_root.lap3 = '';
_root.timer = '';
}
}
frame 123 {
stop();
_root.track.otherGuy.play();
}
instance car of movieClip 55 {
onClipEvent (load) {
function getPos(clip) {
var p = {'x': 0, 'y': 0};
clip.localToGlobal(p);
return p;
}
function two(x) {
if (9 >= x) {
return '0' + x;
}
return '' + x;
}
function three(x) {
if (9 >= x) {
return (99 < x ? '' : '0') + '0' + x;
}
return (99 < x ? '' : '0') + '' + x;
}
function displaytime(ms) {
var sec = Math.floor(ms / 1000);
ms %= 1000;
var t = three(ms);
var min = Math.floor(sec / 60);
sec %= 60;
t = two(sec) + ':' + t;
var hr = Math.floor(min / 60);
min %= 60;
t = two(min) + ':' + t;
return t;
}
function skid(Handbrakey) {
var skidleft = _root.track.attachMovie('skidmark', 'skidleft' + skids, skids);
var i = 0;
while (i < this.displaywheels) {
wheelsPos[i] = getPos(this['w' + i]);
if (handbrakey) {
skidleft.lineStyle(4, 0, 70);
skidleft.moveto(this.wheelsPos[i].x - track_x, this.wheelsPos[i].y - track_y);
skidleft.lineTo(this.lastpos[i].x, this.lastpos[i].y);
} else {
skidleft.lineStyle(3, 0, 50);
skidleft.moveto(this.wheelsPos[i].x - track_x, this.wheelsPos[i].y - track_y);
skidleft.lineTo(this.lastpos[i].x, this.lastpos[i].y);
}
lastpos[i].x = this.wheelsPos[i].x - track_x;
lastpos[i].y = this.wheelsPos[i].y - track_y;
++skids;
++i;
}
return true;
}
function setLastpos() {
var i = 0;
while (i < this.displaywheels) {
this.wheelsPos[i] = getPos(this['w' + i]);
lastpos[i].x = this.wheelsPos[i].x - track_x;
lastpos[i].y = this.wheelsPos[i].y - track_y;
++i;
}
}
function adjust(v, threshold, maximum) {
vx = 0;
if (threshold >= v) {
vx = (v / threshold) * 1;
return vx;
}
vx = 1;
return vx;
}
accel = 0.2;
steer = 0.08;
steer_normal = 0.08;
steer_handbrake = 0.09900000000000001;
steer_threshold = 4;
MINspd = -5;
MAXspd = 22;
MAXskiddisplay = 2;
MAXturnSpd = 10;
MaxTurnSkid = 18;
deccel = 0.92;
handbrake = 0.9300000000000001;
handbrake_traction = 20;
drift = 0.98;
speed = 0;
surface = 3;
traction = 5;
traction_max = 1;
vector = [0, 0];
bounceBack = 0.6;
laptimesB = new Array();
laps = 3;
i = 1;
while (laps >= i) {
laptimesB[i] = 0;
++i;
}
checkpoints = new Array();
checks = 5;
i = 0;
while (checks >= i) {
checkpoints[i] = false;
++i;
}
lap = 0;
collide = false;
track_x = _root:track_x;
track_y = _root:track_y;
angle = 1.5609317684435;
_rotation = angle * 180 / Math.PI;
myTimer = new _root.LGtimer();
displaywheels = 2;
wheelsPos = new Array();
lastPos = new Array();
var i = 0;
while (i < displaywheels) {
wheelsPos[i] = getPos(this['w' + i]);
lastPos[i] = wheelspos[i];
++i;
}
skidding = false;
turnskidding = false;
skids = 1;
myTimer.start();
}
onClipEvent (enterFrame) {
_rotation = angle * 180 / Math.PI;
_root.track._x = track_x;
_root.track._y = track_y;
UD = Key.isDown(38) - Key.isDown(40);
LR = Key.isDown(39) - Key.isDown(37);
HAND = Key.isDown(32);
if (LR) {
angle += LR * steer * adjust(Math.Abs(speed), steer_threshold, MAXSpd);
if (maxturnskid < speed) {
if (!turnskidding) {
setLastpos();
}
turnskidding = skid(HAND);
} else {
turnskidding = false;
}
} else {
turnskidding = false;
}
if (!UD) {
speed *= drift;
} else {
if (UD & !HAND) {
speed = Math.min(Math.max(speed + UD * accel, MINspd), MAXspd);
}
}
if (Math.abs(speed) < accel / 2) {
speed = 0;
}
if (HAND) {
speed *= handbrake;
if (MAXskiddisplay < speed) {
steer = steer_handbrake;
if (!skidding) {
setLastpos();
}
skidding = skid(HAND);
}
traction = handbrake_traction / surface;
} else {
skidding = false;
traction = Math.max(traction_max, Math.abs((speed - MAXturnSpd) / surface));
steer = steer_normal;
}
if (speed < 0) {
traction = 1;
}
if (!_root.track.track.hittest(_x, _y, true)) {
speed *= 0.95;
traction *= 1.2;
}
if (_root.track.rough.hittest(_x, _y, true)) {
speed *= 0.9;
traction *= 0.95;
} else {
if (_root.track.slick.hittest(_x, _y, true)) {
speed *= 1.1;
} else {
if (_root.track.water.hittest(_x, _y, true)) {
traction *= 4;
} else {}
}
}
var frontpos = new Array();
var i = 0;
while (i < this.displaywheels) {
this.frontpos[i] = getPos(this['f' + i]);
++i;
}
if (_root.track.crunchers.hittest(frontpos[0].x, frontpos[0].y, true) & !collide || _root.track.crunchers.hittest(frontpos[1].x, frontpos[1].y, true) & !collide) {
speed = -speed * bounceback;
vector[0] = -vector[0];
vector[1] = -vector[1];
collide = true;
} else {
if (_root.track.otherGuy.hittest(frontpos[0].x, frontpos[0].y, true) & !collide || _root.track.otherGuy.hittest(frontpos[1].x, frontpos[1].y, true) & !collide) {
speed = -speed * bounceback;
vector[0] = -vector[0];
vector[1] = -vector[1];
collide = true;
} else {
collide = false;
}
}
vector[0] += (Math.cos(angle) * speed - vector[0]) / traction;
track_x += vector[0];
vector[1] += (Math.sin(angle) * speed - vector[1]) / traction;
track_y += vector[1];
_root.timer = displaytime(myTimer.getMili());
_root.speedHand._rotation = Math.max(-11, Math.Abs(speed * 8.5));
if (_root.track.check1.hittest(_x, _y, true)) {
checkpoints[1] = true;
_root.track.check1.gotoAndPlay(5);
}
if (_root.track.check2.hittest(_x, _y, true)) {
checkpoints[2] = true;
_root.track.check2.gotoAndPlay(5);
}
if (_root.track.check3.hittest(_x, _y, true)) {
checkpoints[3] = true;
_root.track.check3.gotoAndPlay(5);
}
if (_root.track.check4.hittest(_x, _y, true)) {
checkpoints[4] = true;
_root.track.check4.gotoAndPlay(5);
}
if (_root.track.check5.hittest(_x, _y, true)) {
checkpoints[5] = true;
_root.track.check5.gotoAndPlay(5);
}
if (_root.track.check0.hittest(_x, _y, true)) {
if (checkpoints[1] & checkpoints[2] & checkpoints[3] & checkpoints[4] & checkpoints[5]) {
_root.lapDisplay.play();
++lap;
_root.yourTimer.nextFrame();
if (lap == 1) {
laptimesB[1] = myTimer.getMili();
_root.lap1 = displaytime(laptimesB[1]);
} else {
if (lap == 2) {
laptimesB[2] = myTimer.getMili() - laptimesB[1];
_root.lap2 = displaytime(laptimesB[2]);
} else {
if (lap == 3) {
laptimesB[3] = myTimer.getMili() - laptimesB[2] - laptimesB[1];
_root.lap3 = displaytime(laptimesB[3]);
}
}
}
i = 0;
while (checks >= i) {
checkpoints[i] = false;
++i;
}
if (lap >= laps) {
mytimer.stop();
_root.racetimer = myTimer.getMili();
_root.bestlaptime = Math.min(laptimesB[1], Math.min(laptimesB[2], laptimesB[3]));
if (laptimesB[2] < laptimesB[1] && laptimesB[3] < laptimesB[1]) {
_root.bestLapNumB = 1;
} else {
if (laptimesB[1] < laptimesB[2] && laptimesB[3] < laptimesB[2]) {
_root.bestLapNumB = 2;
} else {
if (laptimesB[1] < laptimesB[3] && laptimesB[2] < laptimesB[3]) {
_root.bestLapNumB = 3;
}
}
}
_root.nextFrame();
}
}
}
}
}
frame 124 {
function two(x) {
if (9 >= x) {
return '0' + x;
}
return '' + x;
}
function three(x) {
if (9 >= x) {
return (99 < x ? '' : '0') + '0' + x;
}
return (99 < x ? '' : '0') + '' + x;
}
function displaytime(ms) {
var sec = Math.floor(ms / 1000);
ms %= 1000;
var t = three(ms);
var min = Math.floor(sec / 60);
sec %= 60;
t = two(sec) + ':' + t;
var hr = Math.floor(min / 60);
min %= 60;
t = two(min) + ':' + t;
return t;
}
_root.totalraceB = displaytime(_root.racetimer);
_root.bestlapB = displaytime(_root.bestlaptime);
stop();
}
frame 125 {
stop();
}
button 219 {
on (release) {
stopAllSounds();
gotoAndStop('track3');
}
}
movieClip 229 {
frame 63 {
_root.nextFrame();
stop();
}
}
frame 135 {
stop();
_root.track_x = track._x;
_root.track_y = track._y;
}
movieClip 233 {
}
movieClip 235 {
}
movieClip 237 {
}
movieClip 240 {
}
movieClip 241 {
frame 1 {
stop();
_root:loseRound = false;
_root:otherLap = 0;
}
frame 1135 {
++_root:otherLap;
if (_root:otherLap < 3) {
gotoAndPlay(2);
} else {
stop();
_root:loseRound = true;
}
}
}
movieClip 242 {
frame 1 {
this.track._visible = false;
this.crunchers._visible = false;
this.rough._visible = false;
this.check0._visible = false;
stop();
}
}
movieClip 249 {
frame 1 {
lap = '0' + _root:otherLap;
}
frame 2 {
lap = '0' + _root:otherLap;
if (_root:loseRound == true) {
--_root:lives;
_root:yourLives = 'lives' + _root:lives;
_root.life.gotoAndPlay(_root:yourLives);
play();
} else {
gotoAndPlay(1);
}
}
frame 6 {
stop();
_root.gotoAndStop('lose3');
}
}
instance car of movieClip 55 {
onClipEvent (load) {
_root:track_x = _root.track._x;
_root:track_y = _root.track._y;
angle = 1.5609317684435;
_rotation = angle * 180 / Math.PI;
_root.lap1 = '';
_root.lap2 = '';
_root.lap3 = '';
_root.timer = '';
}
}
frame 136 {
stop();
_root.track.otherGuy.play();
}
instance car of movieClip 55 {
onClipEvent (load) {
function getPos(clip) {
var p = {'x': 0, 'y': 0};
clip.localToGlobal(p);
return p;
}
function two(x) {
if (9 >= x) {
return '0' + x;
}
return '' + x;
}
function three(x) {
if (9 >= x) {
return (99 < x ? '' : '0') + '0' + x;
}
return (99 < x ? '' : '0') + '' + x;
}
function displaytime(ms) {
var sec = Math.floor(ms / 1000);
ms %= 1000;
var t = three(ms);
var min = Math.floor(sec / 60);
sec %= 60;
t = two(sec) + ':' + t;
var hr = Math.floor(min / 60);
min %= 60;
t = two(min) + ':' + t;
return t;
}
function skid(Handbrakey) {
var skidleft = _root.track.attachMovie('skidmark', 'skidleft' + skids, skids);
var i = 0;
while (i < this.displaywheels) {
wheelsPos[i] = getPos(this['w' + i]);
if (handbrakey) {
skidleft.lineStyle(4, 0, 70);
skidleft.moveto(this.wheelsPos[i].x - track_x, this.wheelsPos[i].y - track_y);
skidleft.lineTo(this.lastpos[i].x, this.lastpos[i].y);
} else {
skidleft.lineStyle(3, 0, 50);
skidleft.moveto(this.wheelsPos[i].x - track_x, this.wheelsPos[i].y - track_y);
skidleft.lineTo(this.lastpos[i].x, this.lastpos[i].y);
}
lastpos[i].x = this.wheelsPos[i].x - track_x;
lastpos[i].y = this.wheelsPos[i].y - track_y;
++skids;
++i;
}
return true;
}
function setLastpos() {
var i = 0;
while (i < this.displaywheels) {
this.wheelsPos[i] = getPos(this['w' + i]);
lastpos[i].x = this.wheelsPos[i].x - track_x;
lastpos[i].y = this.wheelsPos[i].y - track_y;
++i;
}
}
function adjust(v, threshold, maximum) {
vx = 0;
if (threshold >= v) {
vx = (v / threshold) * 1;
return vx;
}
vx = 1;
return vx;
}
accel = 0.2;
steer = 0.08;
steer_normal = 0.08;
steer_handbrake = 0.09900000000000001;
steer_threshold = 4;
MINspd = -5;
MAXspd = 22;
MAXskiddisplay = 2;
MAXturnSpd = 10;
MaxTurnSkid = 18;
deccel = 0.92;
handbrake = 0.9300000000000001;
handbrake_traction = 20;
drift = 0.98;
speed = 0;
surface = 3;
traction = 5;
traction_max = 1;
vector = [0, 0];
bounceBack = 0.6;
laptimesC = new Array();
laps = 3;
i = 1;
while (laps >= i) {
laptimesC[i] = 0;
++i;
}
checkpoints = new Array();
checks = 7;
i = 0;
while (checks >= i) {
checkpoints[i] = false;
++i;
}
lap = 0;
collide = false;
track_x = _root:track_x;
track_y = _root:track_y;
angle = 1.5609317684435;
_rotation = angle * 180 / Math.PI;
myTimer = new _root.LGtimer();
displaywheels = 2;
wheelsPos = new Array();
lastPos = new Array();
var i = 0;
while (i < displaywheels) {
wheelsPos[i] = getPos(this['w' + i]);
lastPos[i] = wheelspos[i];
++i;
}
skidding = false;
turnskidding = false;
skids = 1;
myTimer.start();
}
onClipEvent (enterFrame) {
_rotation = angle * 180 / Math.PI;
_root.track._x = track_x;
_root.track._y = track_y;
UD = Key.isDown(38) - Key.isDown(40);
LR = Key.isDown(39) - Key.isDown(37);
HAND = Key.isDown(32);
if (LR) {
angle += LR * steer * adjust(Math.Abs(speed), steer_threshold, MAXSpd);
if (maxturnskid < speed) {
if (!turnskidding) {
setLastpos();
}
turnskidding = skid(HAND);
} else {
turnskidding = false;
}
} else {
turnskidding = false;
}
if (!UD) {
speed *= drift;
} else {
if (UD & !HAND) {
speed = Math.min(Math.max(speed + UD * accel, MINspd), MAXspd);
}
}
if (Math.abs(speed) < accel / 2) {
speed = 0;
}
if (HAND) {
speed *= handbrake;
if (MAXskiddisplay < speed) {
steer = steer_handbrake;
if (!skidding) {
setLastpos();
}
skidding = skid(HAND);
}
traction = handbrake_traction / surface;
} else {
skidding = false;
traction = Math.max(traction_max, Math.abs((speed - MAXturnSpd) / surface));
steer = steer_normal;
}
if (speed < 0) {
traction = 1;
}
if (!_root.track.track.hittest(_x, _y, true)) {
speed *= 0.95;
traction *= 1.2;
}
if (_root.track.rough.hittest(_x, _y, true)) {
speed *= 0.9;
traction *= 0.95;
} else {
if (_root.track.slick.hittest(_x, _y, true)) {
speed *= 1.1;
} else {
if (_root.track.water.hittest(_x, _y, true)) {
traction *= 4;
} else {}
}
}
var frontpos = new Array();
var i = 0;
while (i < this.displaywheels) {
this.frontpos[i] = getPos(this['f' + i]);
++i;
}
if (_root.track.crunchers.hittest(frontpos[0].x, frontpos[0].y, true) & !collide || _root.track.crunchers.hittest(frontpos[1].x, frontpos[1].y, true) & !collide) {
speed = -speed * bounceback;
vector[0] = -vector[0];
vector[1] = -vector[1];
collide = true;
} else {
if (_root.track.otherGuy.hittest(frontpos[0].x, frontpos[0].y, true) & !collide || _root.track.otherGuy.hittest(frontpos[1].x, frontpos[1].y, true) & !collide) {
speed = -speed * bounceback;
vector[0] = -vector[0];
vector[1] = -vector[1];
collide = true;
} else {
collide = false;
}
}
vector[0] += (Math.cos(angle) * speed - vector[0]) / traction;
track_x += vector[0];
vector[1] += (Math.sin(angle) * speed - vector[1]) / traction;
track_y += vector[1];
_root.timer = displaytime(myTimer.getMili());
_root.speedHand._rotation = Math.max(-11, Math.Abs(speed * 8.5));
if (_root.track.check1.hittest(_x, _y, true)) {
checkpoints[1] = true;
_root.track.check1.gotoAndPlay(5);
}
if (_root.track.check2.hittest(_x, _y, true)) {
checkpoints[2] = true;
_root.track.check2.gotoAndPlay(5);
}
if (_root.track.check3.hittest(_x, _y, true)) {
checkpoints[3] = true;
_root.track.check3.gotoAndPlay(5);
}
if (_root.track.check4.hittest(_x, _y, true)) {
checkpoints[4] = true;
_root.track.check4.gotoAndPlay(5);
}
if (_root.track.check5.hittest(_x, _y, true)) {
checkpoints[5] = true;
_root.track.check5.gotoAndPlay(5);
}
if (_root.track.check6.hittest(_x, _y, true)) {
checkpoints[6] = true;
_root.track.check6.gotoAndPlay(5);
}
if (_root.track.check7.hittest(_x, _y, true)) {
checkpoints[7] = true;
_root.track.check7.gotoAndPlay(5);
}
if (_root.track.check0.hittest(_x, _y, true)) {
if (checkpoints[1] & checkpoints[2] & checkpoints[3] & checkpoints[4] & checkpoints[5] & checkpoints[6] & checkpoints[7]) {
_root.lapDisplay.play();
++lap;
_root.yourTimer.nextFrame();
if (lap == 1) {
laptimesC[1] = myTimer.getMili();
_root.lap1 = displaytime(laptimesC[1]);
} else {
if (lap == 2) {
laptimesC[2] = myTimer.getMili() - laptimesC[1];
_root.lap2 = displaytime(laptimesC[2]);
} else {
if (lap == 3) {
laptimesC[3] = myTimer.getMili() - laptimesC[2] - laptimesC[1];
_root.lap3 = displaytime(laptimesC[3]);
}
}
}
i = 0;
while (checks >= i) {
checkpoints[i] = false;
++i;
}
if (lap >= laps) {
mytimer.stop();
_root.racetimer = myTimer.getMili();
_root.bestlaptime = Math.min(laptimesC[1], Math.min(laptimesC[2], laptimesC[3]));
if (laptimesC[2] < laptimesC[1] && laptimesC[3] < laptimesC[1]) {
_root.bestLapNumC = 1;
} else {
if (laptimesC[1] < laptimesC[2] && laptimesC[3] < laptimesC[2]) {
_root.bestLapNumC = 2;
} else {
if (laptimesC[1] < laptimesC[3] && laptimesC[2] < laptimesC[3]) {
_root.bestLapNumC = 3;
}
}
}
_root.nextFrame();
}
}
}
}
}
frame 137 {
function two(x) {
if (9 >= x) {
return '0' + x;
}
return '' + x;
}
function three(x) {
if (9 >= x) {
return (99 < x ? '' : '0') + '0' + x;
}
return (99 < x ? '' : '0') + '' + x;
}
function displaytime(ms) {
var sec = Math.floor(ms / 1000);
ms %= 1000;
var t = three(ms);
var min = Math.floor(sec / 60);
sec %= 60;
t = two(sec) + ':' + t;
var hr = Math.floor(min / 60);
min %= 60;
t = two(min) + ':' + t;
return t;
}
_root.totalraceC = displaytime(_root.racetimer);
_root.bestlapC = displaytime(_root.bestlaptime);
stop();
}
frame 138 {
stop();
bestRound = Math.min(_root.totalraceA, Math.min(_root.totalraceB, _root.totalraceC));
}
button 257 {
on (release) {
stopAllSounds();
gotoAndStop('finalScore');
}
}
movieClip 265 {
frame 1 {
stop();
num = random(3) + 1;
gotoAndStop(num);
}
}
frame 155 {
stop();
}