Frame 1
totalBytes = Math.round(getBytesTotal() / 1024);
loadedBytes = Math.round(getBytesLoaded() / 1024);
percentDone = Math.round((loadedBytes / totalBytes) * 100);
percentone = totalBytes / 100;
percent = Math.round(loadedBytes / percentone);
if (_root._framesloaded >= _root._totalframes) {
gotoAndPlay (3);
}
Frame 2
gotoAndPlay (1);
Frame 3
stop();
function clean() {
removeMovieClip(btn_start);
removeMovieClip(btn_tut);
removeMovieClip(btn_score);
delete f_sound;
}
function playBeginSound(string) {
if (firstSound == "") {
delete f_sound;
firstSound = string;
f_sound = new Sound();
f_sound.attachSound(string);
f_sound.start();
f_sound.onSoundComplete = function () {
firstSound = "";
delete f_sound;
};
}
}
stop();
stopAllSounds();
var lowestScore = 999999999;
var tempScore = new Array();
var numOfScore = 0;
var firstSound = "";
var myData = new LoadVars();
k = 0;
while (k < 10) {
tempScore[k] = "";
k++;
}
myData.load("scores.txt?" + (random(999999) + 1), myData, "POST");
myData.onLoad = function () {
kalimat4 = new String(myData.scores);
i = 0;
while (i <= kalimat4.length) {
subKata2 = kalimat4.substr(i, 1);
if (subKata2 == ";") {
numOfScore++;
} else {
tempScore[numOfScore] = tempScore[numOfScore] + subKata2;
}
i++;
}
j = 0;
while (j < (numOfScore - 1)) {
if (Number(tempScore[j]) < lowestScore) {
lowestScore = tempScore[j];
}
j++;
}
};
attachMovie("btn_start", "btn_start", 1);
btn_start._x = 495;
btn_start._y = 244;
btn_start.onRelease = function () {
clean();
gotoAndStop (4);
};
btn_tut.onRelease = function () {
clean();
gotoAndStop (7);
};
btn_score.onRelease = function () {
clean();
gotoAndStop (6);
};
this.onEnterFrame = function () {
if (Key.isDown(13)) {
clean();
gotoAndStop (4);
} else if (Key.isDown(32)) {
clean();
gotoAndStop (6);
}
playBeginSound("sIdle1");
};
Frame 4
function initAll() {
initJalan();
initMobil();
initEnemys();
initBonus();
initOthers();
}
function initJalan() {
attachMovie("jalan_mc", "jalan", 2, {_x:0, _y:0});
jalan_half_width = jalan._width * 0.5;
jalan_width_bagi = Math.floor(jalan._width / 6);
batas1 = jalan_width_bagi;
batas2 = jalan_width_bagi * 5;
jalan.gotoAndStop(1);
}
function initGaris() {
currp = 0;
nextY = 0;
listgaris = [];
i = 0;
while (i < 5) {
grs = attachMovie("garis_mc", "garis" + nextId, garisDepth + i);
grs._x = jalan_half_width;
grs._y = 400 - (400 * Math.atan2(nextY, viewh));
grs._xscale = 100 - (100 * Math.atan2(nextY, viewh));
grs._yscale = 135 - (100 * Math.atan2(nextY, viewh));
listgaris.push({clip:grs, oriy:nextY});
nextY = nextY + 120;
nextId++;
i++;
}
}
function initMobil() {
attachMovie("mobil_mc", "mobil", 999);
mobil_half_height = mobil._height * 0.5;
mobil_half_width = mobil._width * 0.5;
mobil._x = jalan_half_width;
mobil._y = (jalan._height - 20) - mobil_half_height;
mobil.gotoAndStop(1);
_root.mobil.oriY = currp;
attachMovie("mobil_mc", "mobil4collision", 1000);
mobil4collision._alpha = 0;
mobil4collision._x = mobil._x;
mobil4collision._y = mobil._y;
mobil4collision._xscale = (mobil4collision._yscale = 60);
}
function initEnemys() {
attachMovie("orang_mc1", "orang", 301);
orang._visible = false;
attachMovie("polisi_mc", "polisi", 302);
polisi._visible = false;
attachMovie("mobil_back_mc1", "mobil1", 303);
mobil1._visible = false;
attachMovie("mobil_front_mc1", "mobil2", 304);
mobil2._visible = false;
}
function initBonus() {
attachMovie("lifebonus_mc", "lifeBonus", 202);
lifeBonus._visible = false;
}
function initOthers() {
playSoundLoop();
isSoundCarLoop = true;
bgSound1 = new Sound(sbg);
bgSound1.attachSound("sIdle1");
bgSound2 = new Sound(sbg);
bgSound2.attachSound("sIdle2");
bgSound3 = new Sound(sbg);
bgSound3.attachSound("sEnd");
currBgSound = 1;
playBgMusic();
soundPlayed = "";
p_soundPlayed = "";
bg_soundPlayed = "";
stage = 1;
isPlay = true;
level = 1;
speed = _minSpeed;
isAccel = false;
score = 0;
life = 10;
lastTick = 0;
elapsed = 0;
isEnemyShowed = false;
enemyIndex = 99;
adjust = vanishingPoint - jalan._height;
isInvisible = false;
isBonusShowed = false;
bonusIndex = 99;
idEnemy = setInterval(showEnemy, 10);
idBonus = setInterval(showBonus, 1000);
idScore = setInterval(addScore, 100);
attachMovie("bg_mc", "bg", 1, {_x:100, _y:0});
bg.gotoAndPlay(1);
idBg = setInterval(updateBg, 1000);
attachMovie("zebra_cross_mc", "zCross", 99);
zCross._x = jalan_half_width;
zCross._visible = false;
attachMovie("areaCleared", "cleared", 5556);
cleared._x = 320;
cleared._y = 240;
cleared._visible = false;
i = 0;
while (i < max_digit_score) {
attachMovie("score_font_mc", "score_mc" + i, 10000 + i);
_root["score_mc" + i]._visible = false;
_root["score_mc" + i].gotoAndStop(1);
_root["score_mc" + i]._x = (jalan._width - ((_root["score_mc" + i]._width + 2) * (i + 1))) - 10;
_root["score_mc" + i]._y = 37;
i++;
}
_root.score_mc0._visible = true;
attachMovie("lifebar_mc2", "life_mc", 997, {_x:5, _y:37});
life_mc.gotoAndStop(life);
life_mc._visible = true;
attachMovie("input_mc", "input", 99999);
input._x = jalan_half_width;
input._y = jalan._height * 0.5;
input._visible = false;
Key.addListener(input);
attachMovie("gameover_mc", "gameover", 1000000);
gameover._x = 320;
gameover._y = 100;
attachMovie("finish_mc", "finish", 999999);
finish._x = jalan_half_width;
finish._y = 100;
finish._visible = false;
attachMovie("panel", "panel", 996);
attachMovie("btn_mainmenu", "mainmenu", 999998);
mainmenu._x = jalan_half_width;
mainmenu._y = 400;
gameover._visible = false;
mainmenu._visible = false;
idPlayAnimJalan = setInterval(changeImageJalan, jalanAnimateTiming);
}
function mobilKabur() {
turnSpeed = 0;
_root.mobil.ySpeed = topSpeed;
_root.mobil.oriY = _root.mobil.oriY + _root.mobil.ySpeed;
rel = _root.mobil.oriY - currp;
ang = Math.atan2(rel, viewh);
_root.mobil._y = 400 - (400 * ang);
scale = Math.floor((((_root.mobil._y + _root.mobil._height) + adjust) / vanishingPoint) * 90);
_root.mobil._xscale = scale;
_root.mobil._yscale = scale;
_root.mobil._x = scalingXPos(_root.mobil.oriX, _root.mobil.oriY);
if (((_root.mobil._y - (_root.mobil._height / 2)) > endOfRoad) and ((_root.mobil._y - (_root.mobil._height / 2)) < jalan._height)) {
_root.mobil._visible = true;
} else {
_root.mobil._visible = false;
}
if (_root.mobil._y < -170) {
_root.mobil._visible = false;
}
}
function updateMobil() {
_root.mobil.oriY = currp;
mobil_half_width = mobil._width * 0.5;
mobil._x = mobil._x + turnSpeed;
if ((mobil._x > batas1) and (mobil._x < batas2)) {
if (isInvisible == false) {
if (mobil._x < (batas1 * 2)) {
mobil.gotoAndStop(5);
mobil4collision.gotoAndStop(5);
mobil4collision._x = mobil._x;
mobil4collision._xscale = (mobil4collision._yscale = 80);
} else if (mobil._x > (batas1 * 4)) {
mobil.gotoAndStop(6);
mobil4collision.gotoAndStop(6);
mobil4collision._x = mobil._x;
mobil4collision._xscale = (mobil4collision._yscale = 80);
} else {
mobil.gotoAndStop(1);
mobil4collision.gotoAndStop(1);
mobil4collision._x = mobil._x;
mobil4collision._xscale = (mobil4collision._yscale = 100);
}
}
} else {
turnSpeed = 0;
if ((mobil._x < batas1) and (isInvisible == false)) {
mobil.gotoAndStop(3);
mobil4collision.gotoAndStop(3);
mobil4collision._x = mobil._x - 35;
mobil4collision._xscale = (mobil4collision._yscale = 60);
} else if ((mobil._x > batas2) and (isInvisible == false)) {
mobil.gotoAndStop(4);
mobil4collision.gotoAndStop(4);
mobil4collision._x = mobil._x + 35;
mobil4collision._xscale = (mobil4collision._yscale = 60);
}
if (mobil._x < (mobil_half_width - 20)) {
mobil._x = 0 + (mobil_half_width - 20);
mobil4collision._x = mobil._x - 35;
mobil4collision._xscale = (mobil4collision._yscale = 60);
} else if ((mobil._x + mobil_half_width) > (jalan._width + 20)) {
mobil._x = jalan._width - (mobil_half_width - 20);
mobil4collision._x = mobil._x + 35;
mobil4collision._xscale = (mobil4collision._yscale = 60);
}
}
if (mobil._currentframe != 2) {
curFrame = mobil._currentframe;
}
if (mobil._x > 320) {
_root.mobil.oriX = mobil._x - 320;
} else {
_root.mobil.oriX = -(320 - mobil._x);
}
}
function updateGaris() {
i = 0;
while (i < listgaris.length) {
grs = listgaris[i].clip;
rel = listgaris[i].oriy - currp;
ang = Math.atan2(rel, viewh);
grs._y = 400 - (400 * ang);
grs._xscale = 100 - (ang * 100);
grs._yscale = 135 - (ang * 100);
i++;
}
grs = listgaris[0].clip;
if ((grs._y - (grs._height * 0.5)) > jalan._height) {
lgaris = listgaris[listgaris.length - 1].clip;
lastypos = listgaris[listgaris.length - 1].oriy;
lastdept = listgaris[0].clip.getDepth();
listgaris[0].clip.removeMovieClip();
listgaris.splice(0, 1);
newgaris = attachMovie("garis_mc", "garis" + nextId, lastdept);
newgaris._x = lgaris._x;
lastypos = lastypos + 120;
angle = Math.atan2(lastposy, viewh);
newgaris._y = 400 - (400 * angle);
newgaris._xscale = 100 - (100 * angle);
newgaris._yscale = 135 - (100 * angle);
nextId++;
listgaris.push({clip:newgaris, oriy:lastypos});
}
}
function updateBg() {
if (idBg) {
bgCount++;
if (bgCount > bgCounter) {
bgCount = 0;
bg._y = bg._y - 1;
if ((bg._y < -90) and (bg._currentframe != 5)) {
stage++;
if (bg._currentframe < 4) {
depp = bg.getDepth();
bx = bg._x;
by = bg._y;
removeMovieClip(bg);
gameover._visible = false;
cleared._visible = true;
idAreaClear = setInterval(removeCleared, 3000);
attachMovie("bg_mc", "bg", depp, {_x:bx, _y:by});
bg.gotoAndStop(4);
bg._y = 0;
} else if (bg._currentframe == 4) {
depp = bg.getDepth();
bx = bg._x;
by = bg._y;
removeMovieClip(bg);
cleared._visible = true;
idAreaClear = setInterval(removeCleared, 3000);
attachMovie("bg_mc", "bg", depp, {_x:bx, _y:by});
bg.gotoAndStop(5);
bg._y = 0;
} else if (bg._currentframe == 5) {
isFinish = true;
idAreaClear = setInterval(removeCleared, 3000);
finish._visible = true;
stopAllSounds();
currBgSound = 3;
playBgMusic();
gameOver();
}
} else if ((bg._y < -50) and (bg._currentframe == 5)) {
stage++;
if (bg._currentframe < 4) {
depp = bg.getDepth();
bx = bg._x;
by = bg._y;
removeMovieClip(bg);
cleared._visible = true;
idAreaClear = setInterval(removeCleared, 3000);
attachMovie("bg_mc", "bg", depp, {_x:bx, _y:by});
bg.gotoAndStop(4);
bg._y = 0;
} else if (bg._currentframe == 4) {
depp = bg.getDepth();
bx = bg._x;
by = bg._y;
removeMovieClip(bg);
cleared._visible = true;
idAreaClear = setInterval(removeCleared, 3000);
attachMovie("bg_mc", "bg", depp, {_x:bx, _y:by});
bg.gotoAndStop(5);
bg._y = 0;
} else if (bg._currentframe == 5) {
isFinish = true;
idAreaClear = setInterval(removeCleared, 3000);
finish._visible = true;
stopAllSounds();
currBgSound = 3;
playBgMusic();
gameOver();
}
}
}
}
}
function removeCleared() {
cleared._visible = false;
clearInterval(idAreaClear);
}
function addScore() {
if (idScore) {
scoreCount++;
if ((speed > 0) and (scoreCount > scoreCounter)) {
scoreCount = 0;
score = score + speed;
score = Math.floor(score);
updateScore();
if (((score % 100) == 0) and (enemyCounter > 0)) {
enemyCounter = enemyCounter - 1;
}
level = Math.floor(score / 1000) + 1;
if (level > 99) {
level = 99;
}
}
}
}
function showEnemy() {
if (isEnemyShowed == false) {
enemyCount++;
if (enemyCount > enemyCounter) {
enemyCount = 0;
enemyIndex = random(4);
switch (enemyIndex) {
case 0 :
dep = orang.getDepth();
orang.removeMovieClip();
rand = random(2) + 1;
attachMovie("orang_mc" + rand, "orang", dep);
_root.orang._visible = false;
_root.orang.dangerous = true;
_root.orang.type = rand;
zOriY = (currp + vanishingPoint) + random(100);
zCross._y = 400 - (400 * Math.atan2(zOriY, viewh));
if (random(2) == 1) {
_root.orang.oriX = -random(jalan_half_width);
_root.orang.xSpeed = 6;
_root.orang.ySpeed = 0;
orang.gotoAndPlay(31);
} else {
_root.orang.oriX = random(jalan_half_width);
_root.orang.xSpeed = -6;
_root.orang.ySpeed = 0;
orang.gotoAndPlay(1);
}
_root.orang.oriY = zOriY;
_root.orang.startMovingAtY = random(zOriY - currp);
break;
case 1 :
polisi.gotoAndStop(1);
_root.polisi.oriY = currp - random(100);
polisi._y = 400 - (400 * Math.atan2(_root.polisi.oriY, viewh));
_root.polisi.xSpeed = 0;
_root.polisi.initYSpeed = 15 + level;
_root.polisi.ySpeed = 0;
polisi._visible = true;
_root.polisi.dangerous = true;
_root.polisi.active = true;
if (mobil._x < jalan_half_width) {
_root.polisi.oriX = random(jalan_half_width);
} else {
_root.polisi.oriX = -random(jalan_half_width);
}
break;
case 2 :
idCheat = setInterval(checkCheating, 10000);
dep = mobil1.getDepth();
removeMovieClip(mobil1);
index = random(4) + 1;
attachMovie("mobil_back_mc" + index, "mobil1", dep);
_root.mobil1.oriY = currp + vanishingPoint;
mobil1._y = 400 - (400 * Math.atan2(_root.mobil1.oriY, viewh));
_root.mobil1.xSpeed = 0;
_root.mobil1.ySpeed = (_topSpeed - 13) + level;
mobil1._visible = true;
_root.mobil1.dangerous = true;
_root.mobil1.active = true;
temp = random(jalan_half_width - 100);
if (temp < (mobil1._width * 0.5)) {
_root.mobil1.oriX = (mobil1._width * 0.5) + 30;
} else {
_root.mobil1.oriX = temp;
}
break;
case 3 :
dep = mobil2.getDepth();
removeMovieClip(mobil2);
index = random(4) + 1;
attachMovie("mobil_front_mc" + index, "mobil2", dep);
_root.mobil2.oriY = currp + vanishingPoint;
mobil2._y = 400 - (400 * Math.atan2(_root.mobil2.oriY, viewh));
_root.mobil2.xSpeed = 0;
_root.mobil2.ySpeed = Math.floor(_topSpeed) + level;
mobil2._visible = true;
_root.mobil2.dangerous = true;
_root.mobil2.active = true;
temp = random(jalan_half_width);
if (temp < (mobil2._width * 0.5)) {
_root.mobil2.oriX = (-(mobil2._width * 0.5)) - 30;
} else {
_root.mobil2.oriX = -temp;
}
}
isEnemyShowed = true;
}
}
}
function updateEnemy() {
if (isEnemyShowed == true) {
switch (enemyIndex) {
case 0 :
zOriY = zOriY - 5;
rel = zOriY - currp;
ang = Math.atan2(rel, viewh);
zCross._y = 400 - (400 * ang);
scale = Math.floor((((zCross._y + zCross._height) + adjust) / vanishingPoint) * 90);
zCross._xscale = scale;
zCross._yscale = scale;
if (zCross._y > (endOfRoad + 20)) {
zCross._visible = true;
}
_root.orang._y = zCross._y;
scale = Math.floor((((_root.orang._y + _root.orang._height) + adjust) * 100) / vanishingPoint);
_root.orang._xscale = scale;
_root.orang._yscale = scale;
if (_root.orang._y > endOfRoad) {
_root.orang._visible = true;
if (_root.orang.startMovingAtY < currp) {
_root.orang.oriX = _root.orang.oriX + _root.orang.xSpeed;
if (_root.orang.xSpeed > 0) {
if (_root.orang.oriX > jalan_half_width) {
_root.orang.xSpeed = 0;
}
} else if (_root.orang.oriX < (-jalan_half_width)) {
_root.orang.xSpeed = 0;
}
}
}
if (_root.orang._y > jalan._height) {
_root.orang._visible = false;
if (zCross._visible == true) {
zCross._visible = false;
}
isEnemyShowed = false;
}
_root.orang._x = scalingXPos(_root.orang.oriX, _root.orang.oriY);
break;
case 1 :
_root.polisi.oriY = _root.polisi.oriY + _root.polisi.ySpeed;
rel = _root.polisi.oriY - currp;
ang = Math.atan2(rel, viewh);
polisi._y = 400 - (400 * ang);
scale = Math.floor((((polisi._y + polisi._height) + adjust) / vanishingPoint) * 90);
polisi._xscale = scale;
polisi._yscale = scale;
if (_root.polisi._y < endOfRoad) {
polisi._visible = false;
} else {
polisi._visible = true;
}
if (_root.polisi.active == true) {
tempX = jalan_half_width + _root.polisi.oriX;
if ((tempX > batas1) and (tempX < batas2)) {
polisi.gotoAndStop(1);
} else if (tempX < batas1) {
polisi.gotoAndStop(2);
} else if (tempX > batas2) {
polisi.gotoAndStop(3);
}
_root.polisi.ySpeed = _root.polisi.initYSpeed + speed;
if ((_root.polisi._y + (polisi._height * 0.5)) < (mobil._y - mobil_half_height)) {
if (((polisi._x - (0.5 * polisi._width)) < (mobil._x - mobil_half_width)) and (_root.polisi.oriX < jalan_half_width)) {
_root.polisi.oriX = _root.polisi.oriX + turnTopSpeed;
} else if (((polisi._x + (polisi._width * 0.5)) > (mobil._x + mobil_half_width)) and (_root.polisi.oriX > (-jalan_half_width))) {
_root.polisi.oriX = _root.polisi.oriX - turnTopSpeed;
}
}
if ((_root.polisi._y - (polisi._height * 0.5)) < endOfRoad) {
_root.polisi.ySpeed = 0;
_root.polisi.active = false;
polisi.gotoAndStop(4);
playPoliceFx("sPBlock");
} else {
playPoliceFx("sPolice");
}
} else if ((_root.polisi._y - (polisi._width * 0.5)) > jalan._height) {
_root.polisi._visible = false;
isEnemyShowed = false;
}
_root.polisi._x = scalingXPos(_root.polisi.oriX, _root.polisi.oriY);
break;
case 2 :
tempX = jalan_half_width + _root.mobil1.oriX;
if ((tempX > batas1) and (tempX < batas2)) {
mobil1.gotoAndStop(1);
} else if (tempX < batas1) {
mobil1.gotoAndStop(3);
} else if (tempX > batas2) {
mobil1.gotoAndStop(4);
}
_root.mobil1.oriY = _root.mobil1.oriY + _root.mobil1.ySpeed;
rel = _root.mobil1.oriY - currp;
ang = Math.atan2(rel, viewh);
_root.mobil1._y = 400 - (400 * ang);
scale = Math.floor((((_root.mobil1._y + _root.mobil1._height) + adjust) / vanishingPoint) * 90);
_root.mobil1._xscale = scale;
_root.mobil1._yscale = scale;
_root.mobil1._x = scalingXPos(_root.mobil1.oriX, _root.mobil1.oriY);
if (((_root.mobil1._y - (_root.mobil1._height / 2)) > endOfRoad) and ((_root.mobil1._y - (_root.mobil1._height / 2)) < jalan._height)) {
_root.mobil1._visible = true;
} else {
if ((_root.mobil1._y - (_root.mobil1._height / 2)) > jalan._height) {
clearInterval(idCheat);
_root.mobil1.active = false;
isEnemyShowed = false;
}
_root.mobil1._visible = false;
}
if (_root.mobil1._y < -170) {
clearInterval(idCheat);
_root.mobil1.active = false;
isEnemyShowed = false;
_root.mobil1._visible = false;
}
break;
case 3 :
tempX = jalan_half_width + _root.mobil2.oriX;
if ((tempX > batas1) and (tempX < batas2)) {
mobil2.gotoAndStop(1);
} else if (tempX < batas1) {
mobil2.gotoAndStop(3);
} else if (tempX > batas2) {
mobil2.gotoAndStop(4);
}
_root.mobil2.oriY = _root.mobil2.oriY - _root.mobil2.ySpeed;
rel = _root.mobil2.oriY - currp;
ang = Math.atan2(rel, viewh);
_root.mobil2._y = 400 - (400 * ang);
scale = Math.floor((((_root.mobil2._y + _root.mobil2._height) + adjust) / vanishingPoint) * 90);
_root.mobil2._xscale = scale;
_root.mobil2._yscale = scale;
_root.mobil2._x = scalingXPos(_root.mobil2.oriX, _root.mobil2.oriY);
if (((_root.mobil2._y - (_root.mobil2._height / 2)) > endOfRoad) and ((_root.mobil2._y - (_root.mobil2._height / 2)) < jalan._height)) {
_root.mobil2._visible = true;
} else {
if ((_root.mobil2._y - (_root.mobil2._height / 2)) > jalan._height) {
_root.mobil2.active = false;
isEnemyShowed = false;
}
_root.mobil2._visible = false;
}
}
}
}
function checkCollisions() {
if ((isEnemyShowed == true) and (isInvisible == false)) {
switch (enemyIndex) {
case 0 :
if ((mobil4collision.hitTest(_root.orang) == true) and (_root.orang.dangerous == true)) {
rand = random(2) + 1;
life = life - 1;
collisionDetected();
_root.orang.dangerous = false;
_root.orang.xSpeed = 0;
if (_root.orang.type == 1) {
playOtherSFX("sMCrash" + rand);
} else {
playOtherSFX("sWCrash" + rand);
}
}
break;
case 1 :
if ((mobil4collision.hitTest(_root.polisi) == true) and (_root.polisi.dangerous == true)) {
playOtherSFX("sBreak");
life = life - 3;
collisionDetected();
_root.polisi.active = false;
_root.polisi.ySpeed = 0;
_root.polisi.dangerous = false;
}
break;
case 2 :
if ((mobil4collision.hitTest(_root.mobil1) == true) and (_root.mobil1.dangerous == true)) {
playOtherSFX("sBreak");
life = life - 2;
collisionDetected();
_root.mobil1.active = false;
_root.mobil1.dangerous = false;
}
break;
case 3 :
if (!((mobil4collision.hitTest(_root.mobil2) == true) and (_root.mobil2.dangerous == true))) {
break;
}
playCarFX("sBreak");
life = life - 2;
collisionDetected();
_root.mobil2.active = false;
_root.mobil2.dangerous = false;
}
}
if (isBonusShowed == true) {
switch (bonusIndex) {
case 0 :
if ((_root.boost.hitTest(mobil) == true) and (_root.boost.active == true)) {
doBonusThing();
_root.boost.active = false;
_root.boost._visible = false;
isBonusShowed = false;
}
break;
case 1 :
if (!((_root.lifeBonus.hitTest(mobil) == true) and (_root.lifeBonus.active == true))) {
break;
}
doBonusThing();
_root.lifeBonus.active = false;
_root.lifeBonus._visible = false;
isBonusShowed = false;
}
}
}
function setVisible() {
mobil.gotoAndStop(curframe);
mobil4collision.gotoAndStop(curframe);
isInvisible = false;
clearInterval(idInvisible);
clearInterval(idDrawInvisible);
}
function drawInvisible() {
if (mobil._x < batas1) {
curFrame = 3;
} else if (mobil._x > batas2) {
curFrame = 4;
} else if (mobil._x < (batas1 * 2)) {
curFrame = 5;
} else if (mobil._x > (batas1 * 4)) {
curFrame = 6;
} else {
curFrame = 1;
}
if (mobil._currentframe != 2) {
mobil.gotoAndStop(2);
mobil4collision.gotoAndStop(2);
} else {
mobil.gotoAndStop(curFrame);
mobil4collision.gotoAndStop(curFrame);
}
}
function scalingXPos(oriX, oriY) {
rely = oriY - currp;
posX = (jalan._width / 2) + (oriX * ((vanishingPoint - rely) / vanishingPoint));
return(posX);
}
function collisionDetected() {
speed = _minSpeed;
if (life < 0) {
life = 0;
}
if (life <= 0) {
stopAllSounds();
currBgSound = 3;
playBgMusic();
gameOver();
life_mc._visible = false;
} else {
if (life == 1) {
currBgSound = 2;
playBgMusic();
}
life_mc.gotoAndStop(life);
}
bonusCounter = life * 10;
isInvisible = true;
idInvisible = setInterval(setVisible, 2000);
idDrawInvisible = setInterval(drawInvisible, 20);
}
function showBonus() {
if ((isBonusShowed == false) and (score >= 1000)) {
bonusCount++;
if (bonusCount > bonusCounter) {
bonusCount = 0;
if (random(2) == 1) {
bonusIndex = 1;
_root.lifeBonus.active = true;
_root.lifeBonus.oriY = (currp + vanishingPoint) + random(100);
if (random(2) == 1) {
_root.lifeBonus.oriX = -random(jalan._height / 2);
} else {
_root.lifeBonus.oriX = random(jalan._height / 2);
}
isBonusShowed = true;
}
}
}
}
function updateBonus() {
if (isBonusShowed == true) {
switch (bonusIndex) {
case 0 :
rel = _root.boost.oriY - currp;
ang = Math.atan2(rel, viewh);
_root.boost._y = 400 - (400 * ang);
scale = Math.floor((((_root.boost._y + _root.boost._height) + adjust) / vanishingPoint) * 90);
_root.boost._xscale = scale;
_root.boost._yscale = scale;
_root.boost._x = scalingXPos(_root.boost.oriX, _root.boost.oriY);
if (((_root.boost._y + (_root.boost._height / 2)) > endOfRoad) and ((_root.boost._y - (_root.boost._height / 2)) < jalan._height)) {
_root.boost._visible = true;
} else {
if ((_root.boost._y - (_root.boost._height / 2)) > jalan._height) {
_root.boost.active = false;
isBonusShowed = false;
}
_root.boost._visible = false;
}
break;
case 1 :
rel = _root.lifeBonus.oriY - currp;
ang = Math.atan2(rel, viewh);
_root.lifeBonus._y = 400 - (400 * ang);
scale = Math.floor((((_root.lifeBonus._y + _root.lifeBonus._height) + adjust) / vanishingPoint) * 90);
_root.lifeBonus._xscale = scale;
_root.lifeBonus._yscale = scale;
_root.lifeBonus._x = scalingXPos(_root.lifeBonus.oriX, _root.lifeBonus.oriY);
if (((_root.lifeBonus._y + (_root.lifeBonus._height / 2)) > endOfRoad) and ((_root.lifeBonus._y - (_root.lifeBonus._height / 2)) < jalan._height)) {
_root.lifeBonus._visible = true;
} else {
if ((_root.lifeBonus._y - (_root.lifeBonus._height / 2)) > jalan._height) {
_root.lifeBonus.active = false;
isBonusShowed = false;
}
_root.lifeBonus._visible = false;
}
}
}
}
function doBonusThing() {
switch (bonusIndex) {
case 0 :
clearBoost();
accel = 2;
topSpeed = topSpeed + boostSpeed;
idBoost = setInterval(clearBoost, 3000);
return;
case 1 :
playOtherSFX("sHealth");
life++;
if (life > 10) {
life = 10;
}
currBgSound = 1;
playBgMusic();
life_mc.gotoAndStop(life);
bonusCounter = life * 10;
}
}
function clearBoost() {
accel = _accel;
topSpeed = _topSpeed;
clearInterval(idBoost);
}
function gameOver() {
isPlay = false;
clearInterval(idPlayAnimJalan);
clearInterval(idScore);
clearInterval(idBg);
delete idBg;
delete idScore;
if (score >= lowestScore) {
input._visible = true;
input.judul = "Input Your Name";
input.isi = "";
if (isFinish == false) {
gameover._visible = true;
}
} else {
cleared._visible = false;
if (isFinish == false) {
gameover._visible = true;
} else {
finish._visible = true;
}
mainmenu._visible = true;
}
}
function topTen() {
namaOrang = String(nama);
skorOrang = String(score);
myData = new LoadVars();
myData.newname = namaOrang;
myData.newscore = skorOrang;
if (myData.sendAndLoad("flash_score.php", myData, "POST") == true) {
onExit();
delete _root.onEnterFrame;
gotoAndStop (5);
} else {
onExit();
delete _root.onEnterFrame;
gotoAndStop (3);
}
}
function onExit() {
clearInterval(idEnemy);
clearInterval(idBonus);
clearInterval(idScore);
clearInterval(idBg);
delete idBg;
removeMovieClip(jalan);
removeMovieClip(trotoar);
removeMovieClip(finish);
i = 0;
while (i < listgaris.length) {
gr = listgaris[i].clip;
removeMovieClip(gr);
i++;
}
nextId = 0;
listgaris = [];
removeMovieClip(panel);
removeMovieClip(mobil);
removeMovieClip(mobil4collision);
removeMovieClip(orang);
removeMovieClip(polisi);
removeMovieClip(mobil1);
removeMovieClip(mobil2);
removeMovieClip(boost);
removeMovieClip(lifeBonus);
removeMovieClip(bg);
removeMovieClip(zCross);
removeMovieClip(life_mc);
removeMovieClip(input);
removeMovieClip(gameover);
removeMovieClip(mainmenu);
i = 0;
while (i < max_digit_score) {
removeMovieClip(_root["score_mc" + i]);
i++;
}
}
function playCarFx() {
if (((isAccel == true) and (isSoundCarLoop == false)) and (isDeaccelSound == true)) {
isDeaccelSound = false;
string = "sAccel";
soundPlayed = string;
carSound = null;
carSound = new Sound(scar);
carSound.setVolume(vol_car);
carSound.attachSound(string);
carSound.start();
carSound.onSoundComplete = function () {
soundPlayed = "";
};
} else if (((isAccel == false) and (isSoundCarLoop == false)) and (isAccelSound == true)) {
isAccelSound = false;
string = "sDeaccel";
soundPlayed = string;
carSound = null;
carSound = new Sound(scar);
carSound.setVolume(vol_car);
carSound.attachSound(string);
carSound.start();
carSound.onSoundComplete = function () {
soundPlayed = "";
};
} else if ((isSoundCarLoop == true) and (soundPlayed == "")) {
}
}
function playSoundLoop() {
string = "sCarLoop";
carSounds = null;
carSounds = new Sound(scar);
carSounds.attachSound(string);
carSounds.start();
carSounds.onSoundComplete = function () {
carSounds.start();
};
}
function playPoliceFx(string) {
if ((p_soundPlayed == "") || (string == "sPBlock")) {
p_soundPlayed = string;
policeSound = null;
policeSound = new Sound(sp);
policeSound.setVolume(vol_police);
policeSound.attachSound(string);
policeSound.start();
policeSound.onSoundComplete = function () {
p_soundPlayed = "";
};
}
}
function playOtherSFX(string) {
sfx = null;
sfx = new Sound(ssfx);
sfx.setVolume(vol_sfx);
sfx.attachSound(string);
sfx.start();
}
function resumeBgMusic() {
currPlay.start();
}
function playBgMusic() {
if (currPlay == bgSound1) {
currPlay.stop("sIdle1");
} else if (currPlay == bgSound2) {
currPlay.stop("sIdle2");
} else if (currPlay == bgSound3) {
currPlay.stop("sEnd");
}
switch (currBgSound) {
case 1 :
currPlay = bgSound1;
currPlay.onSoundComplete = resumeBgMusic;
currPlay.start();
return;
case 2 :
currPlay = bgSound2;
currPlay.onSoundComplete = resumeBgMusic;
currPlay.start();
return;
case 3 :
currPlay = bgSound3;
currPlay.onSoundComplete = resumeBgMusic;
currPlay.start();
}
}
function checkCheating() {
_root.mobil1.ySpeed = 0;
}
function checkCheating1() {
if (idCheat1) {
bonusCounter = 1000;
}
}
function turn() {
if (idTurn) {
if (isSelfTurn == false) {
isSelfTurn = true;
if (random(2) == 1) {
turnSelf = -7;
} else {
turnSelf = 7;
}
}
}
}
function changeImageJalan() {
if (idPlayAnimJalan) {
count++;
if (count > counter) {
count = 0;
if (curFrameJalan < jalan._framesloaded) {
curFrameJalan++;
} else {
curFrameJalan = 1;
}
jalan.gotoAndStop(curFrameJalan);
counter = 0;
}
}
}
function updateScore() {
index = 0;
tempScore = score;
temp = 0;
while (tempScore > 0) {
temp = tempScore % 10;
tempScore = (tempScore - temp) / 10;
_root["score_mc" + index].gotoAndStop(temp + 1);
_root["score_mc" + index]._visible = true;
index++;
}
}
stop();
stopAllSounds();
var jalanAnimateTiming = 33;
var _accel = 0.2;
var _topSpeed = 20;
var _minSpeed = 10;
var boostSpeed = 10;
var brake = 1;
var turnTopSpeed = 10;
var vanishingPoint = 550;
var endOfRoad = 66;
var vol_car = 100;
var vol_police = 100;
var vol_sfx = 100;
var vol_bg = 100;
var max_stage = 3;
var max_digit_score = 6;
var isPlay;
var topSpeed = _topSpeed;
var accel = _accel;
var score;
var life;
var speed;
var isAccel;
var turnSpeed;
var lastTick;
var elapsed;
var isEnemyShowed;
var enemyIndex;
var isInvisible;
var isBonusShowed;
var bonusIndex;
var nama = "none";
var curFrame = 1;
var level;
var soundPlayed;
var p_soundPlayed;
var bg_soundPlayed;
var isSoundCarLoop;
var currBgSound;
var bgSound1;
var bgSound2;
var bgSound3;
var stage;
var isFinish = false;
var lastYPos = 0;
var numOfLine = 0;
var adjust = 0;
var lineMargin = 0;
var zOriY;
var jalan_half_width;
var mobil_half_width;
var mobil_half_height;
var jalan_width_bagi;
var batas1;
var batas2;
var isAccelSound = false;
var isDeaccelSound = false;
var enemyCounter = 30;
var enemyCount = 0;
var bonusCounter = 0;
var bonusCount = 0;
var scoreCounter = 10;
var scoreCount = 0;
var bgCounter = 10;
var bgCount = 0;
var isSelfTurn = false;
var turnSelf = 0;
var counter = 0;
var count = 0;
var curFrameJalan = 1;
var nextId = 0;
var viewh = 400;
var currp = 0;
clearInterval(idEnemy);
clearInterval(idBonus);
clearInterval(idScore);
clearInterval(idCheat);
clearInterval(idCheat1);
clearInterval(idPlayAnimJalan);
clearInterval(idBg);
clearInterval(idInvisible);
clearInterval(idAreaClear);
clearInterval(idTurn);
idCheat1 = setInterval(checkCheating1, 5000);
idTurn = setInterval(turn, 100);
var MyListener = new Object();
MyListener.onKeyUp = function () {
if (!idTurn) {
idTurn = setInterval(turn, 100);
}
if (!idCheat1) {
idCheat1 = setInterval(checkCheating1, 5000);
}
if (isAccel == true) {
scoreCounter = 10;
}
isAccel = false;
};
Key.addListener(MyListener);
initAll();
this.onEnterFrame = function () {
playCarFx();
if (isSelfTurn == true) {
turnSpeed = turnSelf;
}
if (isPlay == true) {
if (speed >= (topSpeed - 2)) {
counter = 0;
} else if ((speed < (topSpeed - 2)) and (speed > (_minSpeed + 2))) {
counter = 1;
} else {
counter = 2;
}
bgCounter = topSpeed - speed;
if (isAccel == false) {
isDeaccelSound = true;
speed = speed - accel;
if (speed < _minSpeed) {
speed = _minSpeed;
} else {
isSoundCarLoop = false;
}
}
elapsed = elapsed + (getTimer() - lastTick);
lastTick = getTimer();
if (Key.isDown(37)) {
isSelfTurn = false;
clearInterval(idCheat1);
turnSpeed = ((-turnTopSpeed) * speed) / topSpeed;
} else if (Key.isDown(39)) {
isSelfTurn = false;
clearInterval(idCheat1);
turnSpeed = (turnTopSpeed * speed) / topSpeed;
}
if (Key.isDown(38)) {
clearInterval(idCheat1);
isAccelSound = true;
clearInterval(idAccel);
if (isAccel == false) {
scoreCounter = 0;
}
isAccel = true;
speed = (speed + accel) + (speed / topSpeed);
if (speed >= topSpeed) {
speed = topSpeed;
} else {
isSoundCarLoop = false;
}
} else if (Key.isDown(40)) {
}
currp = currp + speed;
updateMobil();
updateEnemy();
updateBonus();
checkCollisions();
} else if (isFinish == true) {
mobilKabur();
}
};
mainmenu.onRelease = function () {
onExit();
delete _root.onEnterFrame;
gotoAndStop (3);
};
input.btn_ok.onRelease = function () {
nama = String(input.isi);
if (score > lowestScore) {
topTen();
}
};
input.btn_cancel.onRelease = function () {
onExit();
delete _root.onEnterFrame;
gotoAndStop (3);
};
input.onKeyDown = function () {
if (Key.isDown(13)) {
nama = String(input.isi);
if (score > lowestScore) {
topTen();
}
} else if (Key.isDown(27)) {
onExit();
delete _root.onEnterFrame;
gotoAndStop (3);
}
};
Frame 5
stop();
function pindah() {
if (idPindah) {
clearInterval(idPindah);
delete idPindah;
gotoAndStop (6);
}
}
stop();
stopAllSounds();
clearInterval(idPindah);
idPindah = setInterval(pindah, 100);
Frame 6
function playBeginSound(string) {
if (firstSound == "") {
delete f_sound;
firstSound = string;
f_sound = new Sound();
f_sound.attachSound(string);
f_sound.start();
f_sound.onSoundComplete = function () {
firstSound = "";
delete f_sound;
};
}
}
stop();
stopAllSounds();
firstSound = "";
znama = new Array();
zskor = new Array();
myData = new LoadVars();
xKata = 0;
xKata2 = 0;
banyakTop = 10;
i = 0;
while (i <= banyakTop) {
znama[i] = "";
zskor[i] = "";
i++;
}
myData.load("scores.txt?" + (random(999999) + 1), myData, "POST");
myData.onLoad = function () {
kalimat = new String(myData.players);
kalimat2 = new String(myData.scores);
i = 0;
while (i <= kalimat.length) {
subKata = kalimat.substr(i, 1);
if (subKata == ";") {
xKata++;
} else {
znama[xKata] = znama[xKata] + subKata;
}
i++;
}
i = 0;
while (i <= kalimat2.length) {
subKata2 = kalimat2.substr(i, 1);
if (subKata2 == ";") {
xKata2++;
} else {
zskor[xKata2] = zskor[xKata2] + subKata2;
}
i++;
}
i = 0;
while (i <= banyakTop) {
_root["sName" + (i + 1)] = znama[i];
_root["sScore" + (i + 1)] = zskor[i];
i++;
}
};
attachMovie("btn_mainmenu", "btn_mainmenu", 1);
btn_mainmenu._x = 320;
btn_mainmenu._y = 430;
this.onEnterFrame = function () {
playBeginSound("sEnd");
};
btn_mainmenu.onRelease = function () {
removeMovieClip(btn_mainmenu);
gotoAndStop (3);
};
Frame 7
function exitTut() {
removeMovieClip(btn_mainmenu);
removeMovieClip(tut_mc);
removeMovieClip(tut_bg);
}
function playBeginSound(string) {
if (firstSound == "") {
delete f_sound;
firstSound = string;
f_sound = new Sound();
f_sound.attachSound(string);
f_sound.start();
f_sound.onSoundComplete = function () {
firstSound = "";
delete f_sound;
};
}
}
stopAllSounds();
firstSound = "";
attachMovie("tut_bg", "tut_bg", 1);
tut_bg._alpha = 50;
attachMovie("tut_mc", "tut_mc", 2);
tut_mc._x = 320;
tut_mc._y = 240;
attachMovie("btn_mainmenu", "btn_mainmenu", 3);
btn_mainmenu._x = 320;
btn_mainmenu._y = 430;
this.onEnterFrame = function () {
playBeginSound("sIdle1");
};
btn_mainmenu.onRelease = function () {
exitTut();
gotoAndStop (3);
};
Symbol 25 MovieClip [bg_mc] Frame 3
gotoAndPlay (1);
Symbol 25 MovieClip [bg_mc] Frame 4
stop();
Symbol 25 MovieClip [bg_mc] Frame 5
stop();
Symbol 36 MovieClip [mobil_mc] Frame 1
stop();
Symbol 36 MovieClip [mobil_mc] Frame 2
stop();
Symbol 58 MovieClip [orang_mc1] Frame 20
gotoAndPlay (1);
Symbol 58 MovieClip [orang_mc1] Frame 50
gotoAndPlay (31);
Symbol 68 MovieClip [orang_mc2] Frame 30
gotoAndPlay (1);
Symbol 68 MovieClip [orang_mc2] Frame 60
gotoAndPlay (31);
Symbol 410 MovieClip Frame 35
stop();
Symbol 413 MovieClip Frame 1
this._visible = false;
Symbol 417 MovieClip Frame 1
_root.stop();
Symbol 417 MovieClip Frame 3
xyb1 = _root.getBytesLoaded();
xyb2 = _root.getBytesTotal();
xytgFrame = Math.round((xyb1 / xyb2) * 100) + 1;
prelbar.gotoAndStop(xytgFrame);
Symbol 417 MovieClip Frame 5
if ((xyb1 >= xyb2) && (xyb2 > 50)) {
stop();
_root.play();
} else {
gotoAndPlay ("xloop1");
}
Symbol 426 Button
on (release) {
getURL ("http://dailyfreegames.com", "_blank");
}
Symbol 427 Button
on (release) {
getURL ("http://www.dailyfreegames.com/games/action-games/escaping-paris.html", "_blank");
}
Symbol 428 Button
on (release) {
getURL ("http://www.dailyfreegames.com/games/puzzle-games/deal-or-no-deal-game.html", "_blank");
}
Symbol 429 Button
on (release) {
getURL ("http://www.dailyfreegames.com/games/arcade-games/superman-game.html", "_blank");
}
Symbol 430 Button
on (release) {
getURL ("http://www.dailyfreegames.com/games/action-games/kane-the-ninja.html", "_blank");
}
Symbol 431 Button
on (release) {
getURL ("http://www.dailyfreegames.com/games/sports-games/dx-hockey.html", "_blank");
}
Symbol 436 Button
on (press) {
clean();
gotoAndStop (7);
}
Symbol 442 MovieClip Frame 12
stop();
Symbol 443 Button
on (release) {
getURL ("http://www.dailyfreegames.com", "_blank");
}
Symbol 445 Button
on (release) {
getURL ("http://www.dailyfreegames.com/free-games.html", "_blank");
}