Frame 1
function InitTerrain() {
var _local7 = 0;
var _local3 = 0;
var _local8 = 2;
arrLineStripData[0] = {x:0, y:_root.maxHeightWorld / 2};
arrLineStripData[1] = {x:600, y:_root.maxHeightWorld / 2};
arrLineStripData[2] = {x:1100, y:360};
arrLineStripData[3] = {x:1150, y:320};
arrLineStripData[4] = {x:1190, y:280};
arrLineStripData[5] = {x:1220, y:240};
arrLineStripData[6] = {x:5000, y:400};
_local7 = 600;
_local3 = _root.maxHeightWorld / 2;
while (_local7 < (maxLengthWorld - 600)) {
var _local9 = random(randomWidth) + 40;
newX = _local7 + _local9;
var _local2 = random(randomHeight) + 40;
if (random(2) == 0) {
_local2 = -_local2;
}
if (((_local3 + _local2) > _root.maxHeightWorld) || ((_local3 + _local2) < 0)) {
_local2 = -_local2;
}
newY = _local3 + _local2;
if (Math.abs(newY - _local3) > 200) {
var _local6 = 0;
while (_local6 < 3) {
var _local5 = _local7 + Math.ceil(_local9 / 5);
var _local4 = _local3 + Math.ceil(_local2 / 5);
arrLineStripData[_local8] = {x:_local5, y:_local4};
_local7 = _local5;
_local3 = _local4;
_local8++;
_local6++;
}
}
arrLineStripData[_local8] = {x:newX, y:newY};
_local8++;
_local7 = newX;
_local3 = newY;
}
arrLineStripData[_local8] = {x:maxLengthWorld, y:_local3};
_local8++;
jumTitik = _local8;
}
function UpdateView() {
var _local3;
var _local4;
var _local1 = 0;
while ((arrLineStripData[_local1].x < posCamX) && (arrLineStripData[_local1 + 1].x <= posCamX)) {
_local1++;
}
_local3 = _local1;
while (arrLineStripData[_local1].x < (posCamX + viewWidth)) {
_local1++;
}
_local4 = _local1;
_local1 = 0;
var _local2 = _local3;
while (_local2 <= _local4) {
arrLineStrip[_local1] = arrLineStripData[_local2].x - posCamX;
arrLineStripToTest[_local1] = arrLineStripData[_local2].x;
_local1++;
arrLineStrip[_local1] = arrLineStripData[_local2].y - posCamY;
arrLineStripToTest[_local1] = arrLineStripData[_local2].y;
_local1++;
_local2++;
}
arrLineStrip[_local1] = arrLineStrip[_local1 - 2];
arrLineStripToTest[_local1] = arrLineStripToTest[_local1 - 2];
_local1++;
arrLineStrip[_local1] = viewHeight;
arrLineStripToTest[_local1] = maxHeightWorld;
_local1++;
arrLineStrip[_local1] = arrLineStrip[0];
arrLineStripToTest[_local1] = arrLineStripToTest[0];
_local1++;
arrLineStrip[_local1] = viewHeight;
arrLineStripToTest[_local1] = maxHeightWorld;
_local1++;
arrLineStrip[_local1] = arrLineStrip[0];
arrLineStripToTest[_local1] = arrLineStripToTest[0];
_local1++;
arrLineStrip[_local1] = arrLineStrip[1];
arrLineStripToTest[_local1] = arrLineStripToTest[1];
_local1++;
jumTitikDraw = _local1 / 2;
}
function SetTerrainType() {
}
function DrawTerrain(mc) {
var _local7;
var _local6;
var _local4;
var _local3;
mc.clear();
mc.lineStyle(1, TERRAINCOLOR[_root.mapType]);
mc.beginFill(TERRAINCOLOR[_root.mapType], 100);
_local7 = arrLineStrip[0];
_local6 = arrLineStrip[1];
mc.moveTo(_local7, _local6);
var _local2 = 1;
while (_local2 < jumTitikDraw) {
_local4 = arrLineStrip[(_local2 * 2) + 0];
_local3 = arrLineStrip[(_local2 * 2) + 1];
mc.lineTo(_local4, _local3);
_local2++;
}
mc.endFill();
}
function DrawTerrainPreview(mc) {
var _local13;
var _local12;
var _local7;
var _local6;
var _local8 = 564 / _root.maxLengthWorld;
var _local11 = 100 / _root.maxHeightWorld;
mc.clear();
var _local10 = _root.maxLengthWorld / 1000;
var _local5 = 564 / _local10;
var _local9 = _root.maxHeightWorld / 1000;
var _local4 = 100 / _local9;
mc.lineStyle(0, "0xFFFFFF", 50);
var _local2 = 0;
while (_local2 < _local10) {
mc.moveTo(_local2 * _local5, 0);
mc.lineTo(_local2 * _local5, 110);
_local2++;
}
_local2 = 0;
while (_local2 < _local9) {
mc.moveTo(0, _local2 * _local4);
mc.lineTo(564, _local2 * _local4);
_local2++;
}
mc.lineStyle(2, "0x00FF00");
_local13 = arrLineStripData[0].x * _local8;
_local12 = arrLineStripData[0].y * _local11;
mc.moveTo(_local13, _local12);
_local2 = 1;
while (_local2 < _root.jumTitik) {
_local7 = arrLineStripData[_local2].x * _local8;
_local6 = arrLineStripData[_local2].y * _local11;
mc.lineTo(_local7, _local6);
_local2++;
}
}
function ResetTerrain() {
_root.randomWidth = 100 + ((11 - randomWidthFactor) * 150);
_root.randomHeight = 75 + (randomHeightFactor * 30);
InitTerrain();
DrawTerrainPreview(_root.preview.terraindrawing);
}
function InsidePolygon(polygon, N, p) {
var _local10 = 0;
var _local3;
var _local7;
var _local1;
var _local2;
_local1 = {x:polygon[0], y:polygon[1]};
_local3 = 1;
while (_local3 <= N) {
_local2 = {x:polygon[(_local3 % N) * 2], y:polygon[((_local3 % N) * 2) + 1]};
if (p.y > Math.min(_local1.y, _local2.y)) {
if (p.y <= Math.max(_local1.y, _local2.y)) {
if (p.x <= Math.max(_local1.x, _local2.x)) {
if (_local1.y != _local2.y) {
_local7 = (((p.y - _local1.y) * (_local2.x - _local1.x)) / (_local2.y - _local1.y)) + _local1.x;
if ((_local1.x == _local2.x) || (p.x <= _local7)) {
_local10++;
}
}
}
}
}
_local1 = _local2;
_local3++;
}
if ((_local10 % 2) == 0) {
return(false);
}
return(true);
}
function Crashed() {
_root.attachMovie("argh", "argh", 1001);
_root.argh._visible = true;
_root.argh.play();
_root.argh._x = _root.headpoint.x;
_root.argh._y = _root.headpoint.y;
}
function ClearAll() {
_root.argh.removeMovieClip();
_root.tryagain.removeMovieClip();
stopAllSounds();
}
function LineSegIntersection(x1, y1, x2, y2, MAXVAL, axis, PInt) {
var _local2 = -(x2 - x1);
var _local4 = y2 - y1;
var _local1 = (y1 * x2) - (x1 * y2);
if (axis == "y") {
PInt.x = MAXVAL;
PInt.y = (((-_local4) * MAXVAL) - _local1) / _local2;
}
if (axis == "x") {
PInt.y = MAXVAL;
PInt.x = (((-_local2) * MAXVAL) - _local1) / _local4;
}
}
function ClipPoly(Poly, N, ArrRes) {
var _local14 = new Array();
var _local40 = 0;
var _local41 = new Array();
_local14[0] = Poly;
_local40++;
var _local27 = false;
for (var _local39 in _local14) {
var _local8;
var _local2 = 0;
var _local1 = new Array();
_local8 = _local14[_local39];
var _local9 = _local8.length;
var _local15 = {x:0, y:0};
var _local3 = 0;
_local3 = 0;
while (_local3 < _local9) {
if (_local8[_local3].y >= YMAX) {
if (_local8[(_local3 + 1) % _local9].y >= YMAX) {
_local1[_local2] = {x:_local8[(_local3 + 1) % _local9].x, y:_local8[(_local3 + 1) % _local9].y, flag:0};
_local2++;
_local27 = true;
} else {
var _local25;
var _local28;
var _local24;
var _local23;
var _local38;
var _local36;
var _local37;
var _local35;
_local25 = _local8[_local3 % _local9].x;
_local28 = _local8[_local3 % _local9].y;
_local24 = _local8[(_local3 + 1) % _local9].x;
_local23 = _local8[(_local3 + 1) % _local9].y;
LineSegIntersection(_local25, _local28, _local24, _local23, YMAX, "x", _local15);
_local1[_local2] = {x:_local15.x, y:_local15.y, flag:2};
_local2++;
_local27 = true;
}
} else if (_local8[(_local3 + 1) % _local9].y >= YMAX) {
var _local25 = _local8[_local3 % _local9].x;
var _local28 = _local8[_local3 % _local9].y;
var _local24 = _local8[(_local3 + 1) % _local9].x;
var _local23 = _local8[(_local3 + 1) % _local9].y;
LineSegIntersection(_local25, _local28, _local24, _local23, YMAX, "x", _local15);
_local1[_local2] = {x:_local15.x, y:_local15.y, flag:1};
_local2++;
_local27 = true;
_local1[_local2] = {x:_local24, y:_local23, flag:0};
_local2++;
}
_local3++;
}
var _local22 = 0;
var _local26 = 0;
var _local19 = 0;
var _local33 = 0;
var _local13 = 0;
var _local18 = 0;
while ((_local22 < _local2) && (_local1[_local22].flag == 0)) {
_local22++;
}
if (_local22 < _local2) {
var _local25 = _local1[_local22].x;
_local18 = _local22;
_local22++;
while (_local1[_local22].flag == 0) {
_local22++;
}
var _local24 = _local1[_local22].x;
_local13 = _local22;
_local22++;
_local19 = (_local24 - _local25) / Math.abs(_local24 - _local25);
_local26 = _local19;
}
while ((_local22 < _local2) && (_local26 == _local19)) {
while (_local1[_local22].flag == 0) {
_local22++;
}
var _local25 = _local1[_local22].x;
_local22++;
while (_local1[_local22].flag == 0) {
_local22++;
}
var _local24 = _local1[_local22].x;
_local22++;
_local19 = (_local24 - _local25) / Math.abs(_local24 - _local25);
}
if (_local22 < _local2) {
_local22 = 0;
var _local25 = _local1[_local13].x;
_local18 = _local13;
_local22++;
while ((_local22 < _local2) && (_local1[(_local22 + _local13) % N].flag == 0)) {
_local22++;
}
var _local24 = _local1[(_local22 + _local13) % _local2].x;
_local19 = (_local24 - _local25) / Math.abs(_local24 - _local25);
_local26 = _local19;
while ((_local22 < _local2) && (_local26 == _local19)) {
while (_local1[(_local22 + _local13) % _local2].flag == 0) {
_local22++;
}
_local25 = _local1[(_local22 + _local13) % _local2].x;
_local22++;
while (_local1[(_local22 + _local13) % _local2].flag == 0) {
_local22++;
}
_local24 = _local1[(_local22 + _local13) % _local2].x;
_local22++;
_local19 = (_local24 - _local25) / Math.abs(_local24 - _local25);
}
if (_local22 < _local2) {
_local22 = 0;
jumPolyBuff = 0;
while (_local22 < _local2) {
while ((_local22 < _local2) && (_local1[_local22].flag != 1)) {
_local22++;
}
var _local5 = _local22;
_local22++;
var _local11 = _local22 % _local2;
while ((_local11 != _local5) && (_local1[_local11].flag != 2)) {
_local11++;
_local11 = _local11 % _local2;
}
var _local10 = _local11;
var _local6 = 0;
var _local16 = false;
var _local31 = false;
if (_local5 < _local2) {
while ((_local6 < _local2) && (!_local16)) {
while (((_local6 < _local2) && (_local1[_local6].flag != 1)) || (_local6 == _local5)) {
_local6++;
}
var _local12 = _local6;
_local6++;
var _local4 = _local6 % _local2;
while (((_local4 != _local12) && (_local1[_local4].flag != 2)) || (_local4 == _local10)) {
_local4++;
_local4 = _local4 % _local2;
}
var _local20 = _local4;
if ((Math.min(_local1[_local5].x, _local1[_local10].x) > Math.min(_local1[_local12].x, _local1[_local20].x)) && (Math.max(_local1[_local5].x, _local1[_local10].x) < Math.max(_local1[_local12].x, _local1[_local20].x))) {
_local16 = true;
}
}
}
if ((!_local16) && (_local5 < _local2)) {
var _local17 = 0;
var _local7 = _local5;
var _local21 = new Array();
while (_local1[_local7].flag != 2) {
_local21[_local17] = {x:_local1[_local7].x, y:_local1[_local7].y};
_local17++;
_local7++;
if (_local7 >= _local2) {
_local7 = 0;
}
}
_local21[_local17] = {x:_local1[_local7].x, y:_local1[_local7].y};
_local17++;
_local6 = 0;
_local31 = false;
while (_local6 < _local2) {
while (((_local6 < _local2) && (_local1[_local6].flag != 1)) || (_local6 == _local5)) {
_local6++;
}
var _local12 = _local6;
_local6++;
var _local4 = _local6 % _local2;
while (((_local4 != _local12) && (_local1[_local4].flag != 2)) || (_local4 == _local10)) {
_local4++;
_local4 = _local4 % _local2;
}
var _local20 = _local4;
if ((Math.min(_local1[_local5].x, _local1[_local10].x) < Math.min(_local1[_local12].x, _local1[_local20].x)) && (Math.max(_local1[_local5].x, _local1[_local10].x) > Math.max(_local1[_local12].x, _local1[_local20].x))) {
_local7 = _local12;
while (_local1[_local7].flag != 2) {
_local21[_local17] = {x:_local1[_local7].x, y:_local1[_local7].y};
_local17++;
_local7++;
if (_local7 >= _local2) {
_local7 = 0;
}
}
_local21[_local17] = {x:_local1[_local7].x, y:_local1[_local7].y};
_local17++;
}
}
_local14[jumPolyBuff] = _local21;
jumPolyBuff++;
}
}
} else {
if (_local1[_local18].flag == 2) {
_local22 = 0;
var _local17 = 0;
var _local21 = new Array();
var _local7 = _local18;
while (_local22 < _local2) {
_local21[_local17] = {x:_local1[_local7].x, y:_local1[_local7].y};
_local17++;
_local7++;
if (_local7 >= _local2) {
_local7 = 0;
}
_local22++;
}
jumPolyBuff = 0;
_local14[0] = _local21;
jumPolyBuff++;
}
if (_local1[_local18].flag == 1) {
jumPolyBuff = 0;
_local22 = 0;
var _local7 = _local18;
while (_local22 < _local2) {
var _local17 = 0;
var _local21 = new Array();
while (_local1[_local7].flag != 2) {
_local21[_local17] = {x:_local1[_local7].x, y:_local1[_local7].y};
_local17++;
_local7++;
if (_local7 >= _local2) {
_local7 = 0;
}
_local22++;
}
_local21[_local17] = {x:_local1[_local7].x, y:_local1[_local7].y};
_local7++;
if (_local7 >= _local2) {
_local7 = 0;
}
_local22++;
_local14[jumPolyBuff] = _local21;
jumPolyBuff++;
}
}
}
} else {
if (_local1[_local18].flag == 2) {
_local22 = 0;
var _local17 = 0;
var _local21 = new Array();
var _local7 = _local18;
while (_local22 < _local2) {
_local21[_local17] = {x:_local1[_local7].x, y:_local1[_local7].y};
_local17++;
_local7++;
if (_local7 >= _local2) {
_local7 = 0;
}
_local22++;
}
jumPolyBuff = 0;
_local14[0] = _local21;
jumPolyBuff++;
}
if (_local1[_local18].flag == 1) {
jumPolyBuff = 0;
_local22 = 0;
var _local7 = _local18;
while (_local22 < _local2) {
var _local17 = 0;
var _local21 = new Array();
while (_local1[_local7].flag != 2) {
_local21[_local17] = {x:_local1[_local7].x, y:_local1[_local7].y};
_local17++;
_local7++;
if (_local7 >= _local2) {
_local7 = 0;
}
_local22++;
}
_local21[_local17] = {x:_local1[_local7].x, y:_local1[_local7].y};
_local7++;
if (_local7 >= _local2) {
_local7 = 0;
}
_local22++;
_local14[jumPolyBuff] = _local21;
jumPolyBuff++;
}
}
}
}
}
var arrLineStrip = new Array();
var arrLineStripToTest = new Array();
var limitMoveXMax = 130;
var limitMoveYMin = 150;
var limitMoveYMax = 200;
var arrLineStripData = new Array();
var TERRAINCOLOR = new Array();
TERRAINCOLOR.desert = "0xEDC274";
TERRAINCOLOR.jungle = "0x885B00";
var randomWidthFactor = 5;
var randomHeightFactor = 5;
var randomWidth = (100 + (randomWidthFactor * 50));
var randomHeight = (75 + (randomHeightFactor * 30));
var defaultWidth = 100;
var maxLengthWorld = 25000;
var maxHeightWorld = 4464.28571428571;
var jumTitik = 0;
var jumTitikDraw = 0;
var maxHeight = 400;
var posScreenX;
var posScreenY;
var viewWidth = 600;
var viewHeight = 400;
var posCamX = 0;
var posCamY = 0;
var mapType = 0;
InitTerrain();
var ArrResPoly;
var YMAX = 150;
Frame 5
stop();
_root.ResetTerrain();
_root.mapType = "jungle";
var recordTime = "99999";
ClearAll();
Frame 6
function CreateTimeString(time) {
var _local3 = Math.floor(time / 60000);
var _local1 = Math.floor(time / 1000) % 60;
var _local4 = time % 1000;
return((((_local3 + ":") + _local1) + ":") + _local4);
}
var soundBikeLands = new Sound();
soundBikeLands.attachSound("bikelands");
var startTime = getTimer();
stop();
ClearAll();
_root.argh._visible = false;
_root.skybg.gotoAndStop(_root.mapType);
var SPEEDBALIK = 4;
_root.background.Init(_root.mapType);
_root.enginesound.gotoAndStop("idlemachine");
bike = new CBikeObject();
debugMC = _root.createEmptyMovieClip("debugMC", 100);
var elapsedtime = "0:0:0";
posScreenX = bike.GetPosX() - posCamX;
posScreenY = bike.GetPosY() - posCamY;
bodyOX = bike.GetOX() - bike.GetPosX();
bodyOY = bike.GetOY() - bike.GetPosY();
if (posScreenX > limitMoveXMax) {
var dx = (limitMoveXMax - posScreenX);
posCamX = posCamX - dx;
}
if (posScreenX < 50) {
var dx = (50 - posScreenX);
posCamX = posCamX - dx;
}
if (posScreenY < limitMoveYMin) {
var dy = (posScreenY - limitMoveYMin);
posCamY = posCamY + dy;
if (posCamY < -3500) {
posCamY = -3500;
}
}
if (posScreenY > limitMoveYMax) {
var dy = (posScreenY - limitMoveYMax);
posCamY = posCamY + dy;
if (posCamY > _root.maxHeightWorld) {
posCamY = _root.maxHeightWorld;
}
}
UpdateView();
bike.Tick(arrLineStripToTest, jumTitikDraw - 3, 0, 0);
_root.bike1.racer.YankPivotFoot(0, 0);
onEnterFrame = function () {
var _local6 = 0;
var _local7 = 0;
fps = Math.floor(1000 / (getTimer() - startTime));
elapsedtime = CreateTimeString(0);
var _local3;
var _local2;
var _local8 = 0.5;
var _local9 = 0;
var _local10 = 0;
debugMC.clear();
_root.bike1.racer.ReturnPivot();
DrawTerrain(debugMC);
bike.Draw(debugMC, posCamX, posCamY);
_local3 = bike.GetPosX() - posCamX;
_local2 = bike.GetPosY() - posCamY;
bodyOX = bike.GetOX() - bike.GetPosX();
bodyOY = bike.GetOY() - bike.GetPosY();
if (_local3 > limitMoveXMax) {
var _local5 = limitMoveXMax - _local3;
posCamX = posCamX - _local5;
}
if (_local3 < 50) {
var _local5 = 50 - _local3;
posCamX = posCamX - _local5;
}
if (_local2 < limitMoveYMin) {
var _local4 = _local2 - limitMoveYMin;
posCamY = posCamY + _local4;
if (posCamY < -3500) {
posCamY = -3500;
}
}
if (_local2 > limitMoveYMax) {
var _local4 = _local2 - limitMoveYMax;
posCamY = posCamY + _local4;
if (posCamY > _root.maxHeightWorld) {
posCamY = _root.maxHeightWorld;
}
}
UpdateView();
_root.background.Draw(posCamX, posCamY);
whel2.text = bike.GetPosX();
if (Key.isDown(8)) {
bike.PushBack(0, -4);
}
};
Frame 8
var startTime = getTimer();
stop();
var headpoint = new Object();
headpoint.x = 0;
headpoint.y = 0;
var timeElapsed = 0;
onEnterFrame = function () {
var _local5 = 0;
var _local6 = 0;
if (InsidePolygon(arrLineStrip, jumTitikDraw, _root.headpoint)) {
gotoAndStop ("died");
}
fps = Math.floor(1000 / (getTimer() - startTime));
timeElapsed = getTimer() - startTime;
elapsedtime = CreateTimeString(timeElapsed);
var _local4;
var _local3;
var _local8 = 0.5;
var _local7 = 0;
var _local2 = 0;
debugMC.clear();
if (!Key.isDown(16)) {
if (Key.isDown(40)) {
_local7 = _local7 - _local8;
}
if (Key.isDown(38)) {
_local7 = _local7 + _local8;
_root.enginesound.gotoAndStop("idlegas");
} else {
_root.enginesound.gotoAndStop("idlemachine");
}
if (Key.isDown(39)) {
_local2 = _local2 + 0.014;
}
if (Key.isDown(37)) {
_local2 = _local2 - 0.014;
}
_root.bike1.racer.ReturnPivot();
} else {
if (Key.isDown(38)) {
_local5 = -6.5;
}
if (Key.isDown(40)) {
_local5 = 6.5;
}
if (Key.isDown(37)) {
_local6 = -6.5;
_local2 = _local2 - 0.007;
}
if (Key.isDown(39)) {
_local6 = 6.5;
_local2 = _local2 + 0.007;
}
}
DrawTerrain(debugMC);
bike.Draw(debugMC, posCamX, posCamY);
bike.Tick(arrLineStripToTest, jumTitikDraw - 3, _local7, _local2);
_root.bike1.racer.YankPivotFoot(_local6, _local5);
_local4 = bike.GetPosX() - posCamX;
_local3 = bike.GetPosY() - posCamY;
bodyOX = bike.GetOX() - bike.GetPosX();
bodyOY = bike.GetOY() - bike.GetPosY();
if (_local4 > limitMoveXMax) {
var _local10 = limitMoveXMax - _local4;
posCamX = posCamX - _local10;
if (posCamX > (_root.maxLengthWorld - 600)) {
posCamX = _root.maxLengthWorld - 600;
}
}
if (_local4 < 50) {
var _local10 = 50 - _local4;
posCamX = posCamX - _local10;
}
if (_local3 < limitMoveYMin) {
var _local9 = _local3 - limitMoveYMin;
posCamY = posCamY + _local9;
if (posCamY < -3500) {
posCamY = -3500;
}
}
if (_local3 > limitMoveYMax) {
var _local9 = _local3 - limitMoveYMax;
posCamY = posCamY + _local9;
if (posCamY > _root.maxHeightWorld) {
posCamY = _root.maxHeightWorld;
}
}
UpdateView();
_root.background.Draw(posCamX, posCamY);
whel2.text = bike.GetPosX();
if (Key.isDown(8)) {
bike.PushBack(0, -4);
}
if (bike.GetPosX() > _root.maxLengthWorld) {
_root.gotoAndStop("endlevel");
}
};
Frame 15
var startTime = getTimer();
stop();
var SPEEDBALIK = 4;
Crashed();
onEnterFrame = function () {
var _local6 = 0;
var _local7 = 0;
fps = Math.floor(1000 / (getTimer() - startTime));
var _local3;
var _local2;
var _local8 = 0.5;
var _local9 = 0;
var _local10 = 0;
debugMC.clear();
_root.bike1.racer.ReturnPivot();
DrawTerrain(debugMC);
bike.Draw(debugMC, posCamX, posCamY);
_local3 = bike.GetPosX() - posCamX;
_local2 = bike.GetPosY() - posCamY;
bodyOX = bike.GetOX() - bike.GetPosX();
bodyOY = bike.GetOY() - bike.GetPosY();
if (_local3 > limitMoveXMax) {
var _local5 = limitMoveXMax - _local3;
posCamX = posCamX - _local5;
}
if (_local3 < 50) {
var _local5 = 50 - _local3;
posCamX = posCamX - _local5;
}
if (_local2 < limitMoveYMin) {
var _local4 = _local2 - limitMoveYMin;
posCamY = posCamY + _local4;
if (posCamY < -3500) {
posCamY = -3500;
}
}
if (_local2 > limitMoveYMax) {
var _local4 = _local2 - limitMoveYMax;
posCamY = posCamY + _local4;
if (posCamY > _root.maxHeightWorld) {
posCamY = _root.maxHeightWorld;
}
}
UpdateView();
_root.background.Draw(posCamX, posCamY);
whel2.text = bike.GetPosX();
if (Key.isDown(8)) {
bike.PushBack(0, -4);
}
};
Frame 20
_root.attachMovie("tryagain", "tryagain", 1002);
_root.tryagain._x = 300;
_root.tryagain._y = 200;
stop();
Frame 24
var startTime = getTimer();
stop();
var SPEEDBALIK = 4;
onEnterFrame = function () {
var _local3 = 0;
var _local5 = 0;
fps = Math.floor(1000 / (getTimer() - startTime));
var _local4;
var _local2;
var _local6 = 0.5;
var _local7 = 0;
var _local8 = 0;
debugMC.clear();
_root.bike1.racer.ReturnPivot();
DrawTerrain(debugMC);
bike.Draw(debugMC, posCamX, posCamY);
_local4 = bike.GetPosX() - posCamX;
_local2 = bike.GetPosY() - posCamY;
bodyOX = bike.GetOX() - bike.GetPosX();
bodyOY = bike.GetOY() - bike.GetPosY();
UpdateView();
_root.background.Draw(posCamX, posCamY);
whel2.text = bike.GetPosX();
if (Key.isDown(8)) {
bike.PushBack(0, -4);
}
};
Frame 32
stop();
_root.debugMC.removeMovieClip();
onEnterFrame = null;
ClearAll();
if (recordTime > timeElapsed) {
recordTime = timeElapsed;
elapsedtime = CreateTimeString(timeElapsed);
elapsedtimerecord = CreateTimeString(timeElapsed);
}
Frame 34
ClearAll();
_root.debugMC.removeMovieClip();
stop();
Symbol 28 MovieClip [argh] Frame 1
Symbol 28 MovieClip [argh] Frame 30
stop();
_root.play();
Symbol 47 Button
on (release) {
_root.gotoAndStop("startlevel");
}
Symbol 50 Button
on (release) {
_root.gotoAndStop("endscreendied");
}
Instance of Symbol 60 MovieClip "head" in Symbol 61 MovieClip Frame 1
onClipEvent (enterFrame) {
this._x = _parent.headjoin._x;
this._y = _parent.headjoin._y;
}
Symbol 80 MovieClip [racer] Frame 1
#initclip 6
Object.registerClass("racer", CRacerBody);
#endinitclip
Symbol 81 MovieClip [background] Frame 1
#initclip 5
Object.registerClass("background", CBackground);
#endinitclip
Symbol 108 Button
on (release) {
_root.getURL("http://www.motoramagame.com", "_blank");
}
Symbol 114 Button
on (release) {
_root.play();
}
Symbol 115 MovieClip Frame 1
_root.stop();
PercentLoaded = (_root.getBytesLoaded() / _root.getBytesTotal()) * 100;
if (PercentLoaded != 100) {
bar._xscale = PercentLoaded;
} else {
gotoAndStop ("loaded");
}
Symbol 115 MovieClip Frame 2
gotoAndPlay (1);
Symbol 239 MovieClip [__Packages.CBackground] Frame 0
class CBackground extends MovieClip
{
var limitPosCamY, bgcoll, fgcoll, attachMovie;
function CBackground () {
super();
}
function Init(mapType) {
limitPosCamY = _root.maxHeightWorld - 400;
bgcoll = new Array();
fgcoll = new Array();
var _local3 = 1;
while (_local3 < 7) {
attachMovie(("bg" + mapType) + (((_local3 - 1) % 3) + 1), ("bg" + mapType) + _local3, _local3);
bgcoll[_local3 - 1] = this[("bg" + mapType) + _local3];
bgcoll[_local3 - 1]._visible = false;
_local3++;
}
_local3 = 1;
while (_local3 < 7) {
attachMovie(("fg" + mapType) + (((_local3 - 1) % 3) + 1), ("fg" + mapType) + _local3, _local3 + 10);
fgcoll[_local3 - 1] = this[("fg" + mapType) + _local3];
fgcoll[_local3 - 1]._visible = false;
_local3++;
}
}
function Draw(posCamX, posCamY) {
var _local2;
var _local7;
var _local9;
var _local4;
var _local5;
_local2 = Math.floor((posCamX * 0.2) / 200) % 3;
_local4 = -(Math.floor(posCamX * 0.2) % 200);
_local5 = -112 - ((posCamY - limitPosCamY) * 0.1);
var _local3 = 0;
while (_local3 < 4) {
bgcoll[_local2]._visible = true;
bgcoll[_local2]._x = _local4 + (_local3 * 200);
bgcoll[_local2]._y = 0;
_local2 = _local2 + 1;
_local3++;
}
_local3 = _local2;
while (_local3 < 7) {
bgcoll[_local3]._visible = false;
_local3++;
}
}
}
Symbol 240 MovieClip [__Packages.CRacerBody] Frame 0
class CRacerBody extends MovieClip
{
var IKChainLeg, IKChainArm, dot1, dot0, dot2, dot4, dot3, dot5, initdx, bodyjoin1, bodyjoin2, bodymc, limit, headjoin, pvleg, centermass, localToGlobal, tangan, lengan, leg, paha;
function CRacerBody () {
super();
IKChainLeg = new CIKChain();
IKChainArm = new CIKChain();
var _local4 = dot0._x - dot1._x;
var _local3 = dot0._y - dot1._y;
var _local5 = Math.sqrt((_local4 * _local4) + (_local3 * _local3));
IKChainArm.CreateBone(dot0._x, dot0._y, _local5, Math.atan2(_local3, _local4));
_local4 = dot1._x - dot2._x;
_local3 = dot1._y - dot2._y;
_local5 = Math.sqrt((_local4 * _local4) + (_local3 * _local3));
IKChainArm.CreateBone(dot1._x, dot1._y, _local5, Math.atan2(_local3, _local4));
var _local6 = new Array(0, 1);
IKChainArm.CreateChain(_local6);
IKChainArm.SetFlip(false);
_local4 = dot3._x - dot4._x;
_local3 = dot3._y - dot4._y;
_local5 = Math.sqrt((_local4 * _local4) + (_local3 * _local3));
IKChainLeg.CreateBone(dot3._x, dot3._y, _local5, Math.atan2(_local3, _local4));
_local4 = dot4._x - dot5._x;
_local3 = dot4._y - dot5._y;
_local5 = Math.sqrt((_local4 * _local4) + (_local3 * _local3));
IKChainLeg.CreateBone(dot4._x, dot4._y, _local5, Math.atan2(_local3, _local4));
_local6 = new Array(0, 1);
IKChainLeg.CreateChain(_local6);
IKChainLeg.SetFlip(true);
initdx = bodyjoin2._x - bodyjoin1._x;
initdy = bodyjoin2._y - bodyjoin1._y;
bodyrotation = 0;
var _local7 = bodymc;
_local7.argh._visible = false;
}
function vectmag(x, y) {
return(Math.sqrt((x * x) + (y * y)));
}
function Crashed() {
}
function CekValidYank(code, d) {
var _local3;
var _local2;
var _local5;
var _local4;
_local3 = bodyjoin1._x;
_local2 = bodyjoin1._y;
if (code == "x") {
_local3 = _local3 + d;
} else if (code == "y") {
_local2 = _local2 + d;
}
_local5 = IKChainArm.getBone(0).xdraw - _local3;
_local4 = IKChainArm.getBone(0).ydraw - _local2;
if ((vectmag(_local5, _local4) >= IKChainArm.getMaxLength()) || (limit._y < _local2)) {
return(false);
}
_local3 = bodyjoin2._x;
_local2 = bodyjoin2._y;
if (code == "x") {
_local3 = _local3 + d;
} else if (code == "y") {
_local2 = _local2 + d;
}
_local5 = IKChainLeg.getBone(0).xdraw - _local3;
_local4 = IKChainLeg.getBone(0).ydraw - _local2;
if (vectmag(_local5, _local4) >= IKChainLeg.getMaxLength()) {
return(false);
}
return(true);
}
function CekValidRotate() {
var _local10;
var _local9;
var _local12;
var _local11;
var _local8;
var _local7;
_local10 = bodyjoin1._x;
_local9 = bodyjoin1._y;
_local12 = bodyjoin2._x;
_local11 = bodyjoin2._y;
var _local4 = initdx;
var _local3 = initdy;
var _local2 = bodyrotation + DROTATION;
var _local6 = (Math.cos(_local2) * _local4) - (Math.sin(_local2) * _local3);
var _local5 = (Math.sin(_local2) * _local4) + (Math.cos(_local2) * _local3);
_local6 = _local6 + _local10;
_local5 = _local5 + _local9;
_local8 = IKChainLeg.getBone(0).xdraw - _local6;
_local7 = IKChainLeg.getBone(0).ydraw - _local5;
if (vectmag(_local8, _local7) >= IKChainLeg.getMaxLength()) {
return(0);
}
return(DROTATION);
}
function Yank(dx_, dy_, drot_) {
var _local3 = 0;
var _local2 = 0;
var _local9;
var _local8;
_local9 = CekValidYank("x", dx_);
if (_local9) {
_local3 = dx_;
}
_local8 = CekValidYank("y", dy_);
if (_local8) {
_local2 = dy_;
}
var _local7 = 0;
if (!(_local9 && (_local8))) {
_local7 = CekValidRotate();
}
bodyrotation = bodyrotation + (_local7 + drot_);
var _local13;
var _local12;
var _local16;
var _local15;
var _local20;
var _local19;
_local13 = bodyjoin1._x;
_local12 = bodyjoin1._y;
_local16 = bodyjoin2._x;
_local15 = bodyjoin2._y;
var _local6 = initdx;
var _local5 = initdy;
var _local4 = bodyrotation;
var _local11 = (Math.cos(_local4) * _local6) - (Math.sin(_local4) * _local5);
var _local10 = (Math.sin(_local4) * _local6) + (Math.cos(_local4) * _local5);
bodyjoin2._x = _local11 + _local13;
bodyjoin2._y = _local10 + _local12;
bodymc._rotation = (bodyrotation * 180) / Math.PI;
bodymc._x = bodymc._x + _local3;
bodymc._y = bodymc._y + _local2;
bodyjoin2._x = bodyjoin2._x + _local3;
bodyjoin2._y = bodyjoin2._y + _local2;
bodyjoin1._x = bodyjoin1._x + _local3;
bodyjoin1._y = bodyjoin1._y + _local2;
headjoin._x = headjoin._x + _local3;
headjoin._y = headjoin._y + _local2;
UpdateAll();
}
function ReturnPivot() {
var _local4;
var _local3;
_local3 = pvleg._y - IKChainLeg.getBone(0).ydraw;
_local4 = pvleg._x - IKChainLeg.getBone(0).xdraw;
if (Math.abs(_local4) > _root.SPEEDBALIK) {
if (_local4 < 0) {
_local4 = -_root.SPEEDBALIK;
} else {
_local4 = _root.SPEEDBALIK;
}
}
if (Math.abs(_local3) > _root.SPEEDBALIK) {
if (_local3 < 0) {
_local3 = -_root.SPEEDBALIK;
} else {
_local3 = _root.SPEEDBALIK;
}
}
YankPivotFoot(_local4, _local3);
}
function Tick(dyfrombike, dxyank, dyyank) {
var _local3;
var _local4;
var _local5 = (centermass._y - bodyjoin1._y) / 20;
var _local6 = (centermass._x - bodyjoin1._x) / 20;
var _local2 = -(bodyrotation / 20);
_local3 = (dyfrombike + _local5) + dyyank;
_local4 = _local6 + dxyank;
if ((dxyank != 0) || (dyyank != 0)) {
_local2 = 0;
}
Yank(_local4, _local3, _local2);
}
function YankPivotFoot(dx, dy) {
var _local7 = false;
var _local6 = false;
var _local3 = 0;
var _local2 = 0;
_local3 = (IKChainLeg.getBone(0).xdraw + dx) - bodyjoin2._x;
_local2 = (IKChainLeg.getBone(0).ydraw + dy) - bodyjoin2._y;
if (vectmag(_local3, _local2) <= IKChainLeg.getMaxLength()) {
IKChainLeg.MovePivot(dx, dy);
}
}
function GetHeadPos() {
_root.headpoint.x = bodymc.head._x;
_root.headpoint.y = bodymc.head._y;
localToGlobal(_root.headpoint);
}
function GetHeadPosY() {
}
function UpdateAll() {
IKChainArm.moveIKChain(1, bodyjoin1._x, bodyjoin1._y);
IKChainArm.UpdateViewIK();
tangan._x = IKChainArm.getBone(0).xdraw;
tangan._y = IKChainArm.getBone(0).ydraw;
tangan._rotation = (IKChainArm.getBone(0).degrot * 180) / Math.PI;
lengan._x = IKChainArm.getBone(1).xdraw;
lengan._y = IKChainArm.getBone(1).ydraw;
lengan._rotation = ((IKChainArm.getBone(1).degrot + IKChainArm.getBone(0).degrot) * 180) / Math.PI;
IKChainLeg.moveIKChain(1, bodyjoin2._x, bodyjoin2._y);
IKChainLeg.UpdateViewIK();
leg._x = IKChainLeg.getBone(0).xdraw;
leg._y = IKChainLeg.getBone(0).ydraw;
leg._rotation = (IKChainLeg.getBone(0).degrot * 180) / Math.PI;
paha._x = IKChainLeg.getBone(1).xdraw;
paha._y = IKChainLeg.getBone(1).ydraw;
paha._rotation = ((IKChainLeg.getBone(1).degrot + IKChainLeg.getBone(0).degrot) * 180) / Math.PI;
}
var DROTATION = 0.05;
var bodyrotation = 0;
var initdy = 0;
}
Symbol 241 MovieClip [__Packages.CIKChain] Frame 0
class CIKChain
{
var IKChain, BoneArr, jumBone, flip;
function CIKChain () {
IKChain = new Array();
BoneArr = new Array();
jumBone = 0;
flip = false;
}
function RADTODEG(rad) {
return((rad * 180) / Math.PI);
}
function SetFlip(val) {
flip = val;
}
function square(f) {
return(f * f);
}
function getMaxLength() {
var _local3 = 0;
var _local2 = 0;
while (_local2 < BoneArr.length) {
_local3 = _local3 + BoneArr[_local2].dlength;
_local2++;
}
return(_local3);
}
function vectmag(x, y) {
return(Math.sqrt(square(x) + square(y)));
}
function getBone(idx) {
return(BoneArr[idx]);
}
function CreateBone(xpos, ypos, length_, rotangle) {
BoneArr[jumBone] = {x:xpos, y:ypos, xdraw:xpos, ydraw:ypos, dlength:length_, degrot:rotangle};
jumBone++;
}
function CreateChain(arrBoneIdx) {
var _local2 = 0;
while (_local2 < arrBoneIdx.length) {
IKChain[_local2] = BoneArr[arrBoneIdx[_local2]];
_local2++;
}
}
function MovePivot(dx, dy) {
for (var _local4 in IKChain) {
IKChain[_local4].x = IKChain[_local4].x + dx;
IKChain[_local4].y = IKChain[_local4].y + dy;
IKChain[_local4].xdraw = IKChain[_local4].xdraw + dx;
IKChain[_local4].ydraw = IKChain[_local4].ydraw + dy;
}
}
function moveIKChain(idxaff, newposx, newposy) {
var _local3 = IKChain;
var _local5;
var _local2;
_local5 = _local3[idxaff - 1].dlength;
_local2 = _local3[idxaff].dlength;
if (flip) {
_local2 = -_local2;
}
var _local9 = newposx - _local3[idxaff - 1].x;
var _local8 = newposy - _local3[idxaff - 1].y;
var _local7 = ((square(_local9) + square(_local8)) - square(_local5)) - square(_local2);
var _local6 = (2 * _local5) * _local2;
var _local11 = _local7 / _local6;
var _local10 = Math.acos(_local7 / _local6);
var _local12 = Math.sin(_local10);
_local3[idxaff].degrot = _local10;
_local7 = (-((_local2 * _local12) * _local9)) + ((_local5 + (_local2 * _local11)) * _local8);
_local6 = ((_local2 * _local12) * _local8) + ((_local5 + (_local2 * _local11)) * _local9);
var _local13 = Math.atan(_local7 / _local6);
_local3[idxaff - 1].degrot = _local13;
if (_local6 < 0) {
_local3[idxaff - 1].degrot = _local3[idxaff - 1].degrot + Math.PI;
}
if (flip) {
_local3[idxaff].degrot = _local3[idxaff].degrot - Math.PI;
}
}
function Rotate(centX, centY, ikbone, angle) {
var _local1 = ikbone;
var _local3 = _local1.x - centX;
var _local2 = centY - _local1.y;
var _local6 = (Math.cos(angle) * _local3) - (Math.sin(angle) * _local2);
var _local5 = (Math.sin(angle) * _local3) + (Math.cos(angle) * _local2);
_local1.xdraw = _local6 + centX;
_local1.ydraw = _local5 + centY;
}
function UpdateViewIK() {
var _local2 = 0;
while (_local2 < IKChain.length) {
if (_local2 > 0) {
Rotate(IKChain[_local2 - 1].xdraw, IKChain[_local2 - 1].ydraw, IKChain[_local2], IKChain[_local2 - 1].degrot);
}
_local2++;
}
}
}
Symbol 242 MovieClip [__Packages.CBikeObject] Frame 0
class CBikeObject
{
var bwidth, bheight, dx, dy, posX, posY, bodyPList, bodySList, wheelPList, dx0, dy0, len0, dx1, dy1, len1, dx2, dy2, len2, wheelSList, rimPList, pos, nx, ny, npushx, npushy, xi, wheel1coll, wheel2coll, tembus;
function CBikeObject () {
bwidth = 30;
bheight = 25;
dx = bwidth * 0.5;
dy = bheight;
templen = Math.sqrt((dx * dx) + (dy * dy));
posX = 200;
posY = (_root.maxHeightWorld / 2) - 67;
bodyPList = new Array();
bodyPList[0] = {x:0 + posX, y:0 + posY, ox:1 + posX, oy:0 + posY, xbef:0 + posX, ybef:0 + posY};
bodyPList[1] = {x:dx + posX, y:bheight + posY, ox:(dx + 1) + posX, oy:bheight + posY, xbef:dx + posX, ybef:bheight + posY};
bodyPList[2] = {x:bwidth + posX, y:0 + posY, ox:(bwidth + 1) + posX, oy:0 + posY, xbef:bwidth + posX, ybef:0 + posY};
bodySList = new Array();
bodySList[0] = {p0:bodyPList[0], p1:bodyPList[1], w0:0.5, w1:0.5, rlen:templen, e:1};
bodySList[1] = {p0:bodyPList[1], p1:bodyPList[2], w0:0.5, w1:0.5, rlen:templen, e:1};
bodySList[2] = {p0:bodyPList[2], p1:bodyPList[0], w0:0.5, w1:0.5, rlen:bwidth, e:1};
wheelPList = new Array();
wheelPList[0] = {x:bodyPList[0].x - wOut, y:(bheight + wDown) + posY, ox:bodyPList[0].x - wOut, oy:(bheight + wDown) + posY, r:wRad};
wheelPList[1] = {x:bodyPList[2].x + wOut, y:(bheight + wDown) + posY, ox:bodyPList[2].x + wOut, oy:(bheight + wDown) + posY, r:wRad};
dx0 = wheelPList[0].x - bodyPList[0].x;
dy0 = wheelPList[0].y - bodyPList[0].y;
len0 = Math.sqrt((dx0 * dx0) + (dy0 * dy0));
dx1 = wheelPList[0].x - bodyPList[1].x;
dy1 = wheelPList[0].y - bodyPList[1].y;
len1 = Math.sqrt((dx1 * dx1) + (dy1 * dy1));
dx2 = wheelPList[0].x - bodyPList[2].x;
dy2 = wheelPList[0].y - bodyPList[2].y;
len2 = Math.sqrt((dx2 * dx2) + (dy2 * dy2));
var _local4 = wheelPList[0].x - wheelPList[1].x;
var _local3 = wheelPList[0].y - wheelPList[1].y;
var _local5 = Math.sqrt((_local4 * _local4) + (_local3 * _local3));
wheelSList = new Array();
wheelSList[0] = {p0:wheelPList[0], p1:bodyPList[0], w0:0.5, w1:0.5, rlen:len0, e:1};
wheelSList[1] = {p0:wheelPList[0], p1:bodyPList[1], w0:0.5, w1:0.5, rlen:len1, e:1};
wheelSList[2] = {p0:wheelPList[0], p1:bodyPList[2], w0:0.5, w1:0.5, rlen:len2, e:1};
wheelSList[3] = {p0:wheelPList[1], p1:bodyPList[0], w0:0.5, w1:0.5, rlen:len2, e:1};
wheelSList[4] = {p0:wheelPList[1], p1:bodyPList[1], w0:0.5, w1:0.5, rlen:len1, e:1};
wheelSList[5] = {p0:wheelPList[1], p1:bodyPList[2], w0:0.5, w1:0.5, rlen:len0, e:1};
wheelSList[6] = {p0:wheelPList[0], p1:wheelPList[1], w0:0.5, w1:0.5, rlen:_local5, e:1};
wheelSList[7] = {p0:wheelPList[1], p1:wheelPList[0], w0:0.5, w1:0.5, rlen:_local5, e:1};
rimPList = new Array();
rimPList[0] = {x:wRad, y:0, ox:0, oy:0, len:wRad, s:-1, w:0.7};
rimPList[1] = {x:wRad, y:0, ox:0, oy:0, len:wRad, s:-1, w:0.7};
maxS = 4;
pos = new Array();
}
function square(f) {
return(f * f);
}
function vectmag(x, y) {
return(Math.sqrt(square(x) + square(y)));
}
function inSegment(x1, y1, x2, y2, x3, y3) {
var _local4 = ((x3 - x1) * (x2 - x1)) + ((y3 - y1) * (y2 - y1));
var _local7 = ((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1));
var _local6 = _local4 / _local7;
return(_local6);
}
function InsidePolygon(polygon, N, p) {
var _local10 = 0;
var _local3;
var _local7;
var _local1;
var _local2;
_local1 = {x:polygon[0], y:polygon[1]};
_local3 = 1;
while (_local3 <= N) {
_local2 = {x:polygon[(_local3 % N) * 2], y:polygon[((_local3 % N) * 2) + 1]};
if (p.y > Math.min(_local1.y, _local2.y)) {
if (p.y <= Math.max(_local1.y, _local2.y)) {
if (p.x <= Math.max(_local1.x, _local2.x)) {
if (_local1.y != _local2.y) {
_local7 = (((p.y - _local1.y) * (_local2.x - _local1.x)) / (_local2.y - _local1.y)) + _local1.x;
if ((_local1.x == _local2.x) || (p.x <= _local7)) {
_local10++;
}
}
}
}
}
_local1 = _local2;
_local3++;
}
if ((_local10 % 2) == 0) {
return(false);
}
return(true);
}
function CheckSign(pointx, pointy, x1, y1, x2, y2) {
var _local2 = -(x2 - x1);
var _local3 = y2 - y1;
var _local1 = (y1 * x2) - (x1 * y2);
var _local4 = ((_local3 * pointx) + (_local2 * pointy)) + _local1;
if (_local4 > 0) {
return("positif");
}
return("negatif");
}
function DrawPlus(mc, x, y, r) {
mc.moveTo(x + r, y);
mc.lineTo(x - r, y);
mc.moveTo(x, y + r);
mc.lineTo(x, y - r);
}
function DrawLine(mc, x0, y0, x1, y1) {
mc.moveTo(x0, y0);
mc.lineTo(x1, y1);
}
function sphere_line_intersection(x1, y1, x2, y2, x3, y3, r) {
var _local17 = false;
var _local36;
var _local35;
var _local33;
var _local11;
var _local9;
var _local23;
var _local8;
var _local24;
_local11 = square(x2 - x1) + square(y2 - y1);
_local9 = 2 * (((x2 - x1) * (x1 - x3)) + ((y2 - y1) * (y1 - y3)));
_local23 = ((((square(x3) + square(y3)) + square(x1)) + square(y1)) - (2 * ((x3 * x1) + (y3 * y1)))) - square(r);
_local24 = (_local9 * _local9) - ((4 * _local11) * _local23);
if (_local24 < 0) {
pos[0] = 0;
_local17 = false;
return(_local17);
}
if (_local24 == 0) {
if (inSegment(x1, y1, x2, y2, x3, y3)) {
pos[0] = 1;
_local17 = true;
_local8 = (-_local9) / (2 * _local11);
pos[1] = x1 + (_local8 * (x2 - x1));
pos[2] = y1 + (_local8 * (y2 - y1));
var _local16 = x3 - pos[1];
var _local18 = y3 - pos[2];
var _local5 = vectmag(_local16, _local18);
nx = _local16 / _local5;
ny = _local18 / _local5;
npushx = 0;
npushy = 0;
return(_local17);
}
return(false);
}
if (_local24 > 0) {
var _local4 = new Array();
_local4[0] = 2;
_local17 = true;
_local8 = ((-_local9) + Math.sqrt(square(_local9) - ((4 * _local11) * _local23))) / (2 * _local11);
_local4[1] = x1 + (_local8 * (x2 - x1));
_local4[2] = y1 + (_local8 * (y2 - y1));
_local8 = ((-_local9) - Math.sqrt(square(_local9) - ((4 * _local11) * _local23))) / (2 * _local11);
_local4[3] = x1 + (_local8 * (x2 - x1));
_local4[4] = y1 + (_local8 * (y2 - y1));
var _local26 = _local4[1] + ((_local4[3] - _local4[1]) / 2);
var _local25 = _local4[2] + ((_local4[4] - _local4[2]) / 2);
var _local22 = inSegment(x1, y1, x2, y2, _local26, _local25);
var _local19;
var _local20;
if ((_local22 <= 1) && (_local22 >= 0)) {
var _local16 = x3 - _local26;
var _local18 = y3 - _local25;
var _local5 = vectmag(_local16, _local18);
nx = _local16 / _local5;
ny = _local18 / _local5;
npushx = nx * (r - _local5);
npushy = ny * (r - _local5);
return(true);
}
var _local27;
var _local30;
var _local13;
var _local12;
var _local29;
var _local28;
var _local32;
var _local31;
var _local34;
if (_local22 < 0) {
_local27 = x1;
_local30 = y1;
_local19 = x2 - x1;
_local20 = y2 - y1;
} else {
_local27 = x2;
_local30 = y2;
_local19 = x1 - x2;
_local20 = y1 - y2;
}
var _local5 = vectmag(x3 - _local27, y3 - _local30);
if (_local5 <= r) {
_local13 = x3 - _local26;
_local12 = y3 - _local25;
_local29 = vectmag(_local13, _local12);
_local13 = _local13 / _local29;
_local12 = _local12 / _local29;
_local28 = vectmag(_local19, _local20);
nx = _local19 / _local28;
ny = _local20 / _local28;
_local34 = ((_local13 * nx) + (ny * _local12)) / (vectmag(_local13, _local12) * vectmag(nx, ny));
angle = Math.atan2(ny, nx) - Math.atan2(_local12, _local13);
_local33 = (_local13 * _local20) - (_local12 * _local19);
var _local14 = (Math.PI/2);
if (_local33 > 0) {
_local14 = -_local14;
}
_local32 = (Math.cos(_local14) * nx) - (Math.sin(_local14) * ny);
_local31 = (Math.sin(_local14) * nx) + (Math.cos(_local14) * ny);
npushx = _local32 * (r - _local5);
npushy = _local31 * (r - _local5);
return(true);
}
return(false);
}
}
function LineIntersection(x1, y1, x2, y2, u1, v1, u2, v2) {
var _local2;
var _local5;
var _local14 = 0;
var _local3;
var _local7;
var _local13 = 0;
if ((x2 - x1) == 0) {
_local2 = 0;
_local5 = x1;
} else {
_local2 = (y2 - y1) / (x2 - x1);
_local5 = y1 - (_local2 * x1);
}
if ((u2 - u1) == 0) {
_local3 = 0;
_local7 = u1;
} else {
_local3 = (v2 - v1) / (u2 - u1);
_local7 = v1 - (_local3 * u1);
}
if ((_local2 == _local3) && (_local5 == _local7)) {
return(false);
}
if ((x2 - x1) == 0) {
xi = x1;
yi = _local7 + (_local3 * xi);
} else if ((u2 - u1) == 0) {
xi = u1;
yi = _local5 + (_local2 * xi);
} else if (_local2 != _local3) {
xi = (-(_local5 - _local7)) / (_local2 - _local3);
yi = _local5 + (_local2 * xi);
} else {
return(false);
}
if ((((((x1 - xi) * (xi - x2)) >= 0) && (((u1 - xi) * (xi - u2)) >= 0)) && (((y1 - yi) * (yi - y2)) >= 0)) && (((v1 - yi) * (yi - v2)) >= -0.001)) {
return(true);
}
return(false);
}
function CalcPushForce(p, x1, y1, x2, y2) {
var _local2;
npushx = xi - p.x;
npushy = yi - p.y;
_local2 = vectmag(npushx, npushy);
nx = npushx / _local2;
ny = npushy / _local2;
_local2 = _local2 + p.r;
npushx = nx * _local2;
npushy = ny * _local2;
}
function GetPosX() {
return(bodyPList[1].x);
}
function GetPosY() {
return(bodyPList[1].y);
}
function GetOX() {
return(wheelPList[1].ox);
}
function GetOY() {
return(wheelPList[1].oy);
}
function PushBack(dx, dy) {
var _local3 = wheelPList;
for (var _local10 in _local3) {
var _local2 = _local3[_local10];
var _local7 = _local2.ox;
var _local6 = _local2.oy;
var _local5 = (_local2.ox = _local2.x);
var _local4 = (_local2.oy = _local2.y);
_local2.x = _local2.x + dx;
_local2.y = _local2.y + dy;
}
}
function PushBackBody(dx, dy) {
var _local5 = bodyPList;
for (var _local10 in _local5) {
var _local2 = _local5[_local10];
var _local9 = _local2.ox;
var _local8 = _local2.oy;
var _local7 = (_local2.ox = _local2.x);
var _local6 = (_local2.oy = _local2.y);
_local2.x = _local2.x + dx;
_local2.y = _local2.y + dy;
_local2.ox = _local2.ox + dx;
_local2.oy = _local2.oy + dy;
}
_local5 = wheelPList;
for (var _local10 in _local5) {
var _local2 = _local5[_local10];
var _local9 = _local2.ox;
var _local8 = _local2.oy;
var _local7 = (_local2.ox = _local2.x);
var _local6 = (_local2.oy = _local2.y);
_local2.x = _local2.x + dx;
_local2.y = _local2.y + dy;
_local2.ox = _local2.ox + dx;
_local2.oy = _local2.oy + dy;
}
}
function Rotate(teta) {
var _local3 = bodyPList;
var _local8;
var _local7;
for (var _local9 in _local3) {
var _local2 = _local3[_local9];
_local8 = _local8 + _local2.x;
_local7 = _local7 + _local2.y;
}
_local8 = _local8 / 3;
_local7 = _local7 / 3;
_local3 = bodyPList;
for (var _local9 in _local3) {
var _local2 = _local3[_local9];
var _local5 = _local2.x - _local8;
var _local4 = _local2.y - _local7;
_local5 = Math.cos(teta) + Math.sin(teta);
_local4 = (-Math.sin(teta)) + Math.cos(teta);
_local2.ox = _local2.x;
_local2.x = _local5 + _local8;
_local2.y = _local4 + _local7;
}
}
function Tick(arrLineStrip, jumTitik, vs1, vr) {
var _local40 = 0;
if (wheel1coll || (wheel2coll)) {
_local40 = vs1;
}
if (_local40 < 0) {
_local40 = (-(wheelPList[0].x - wheelPList[0].ox)) / 2;
}
var _local45 = 0;
if ((Key.isDown(17) && (!tembus)) && (wheel1coll || (wheel2coll))) {
_local45 = 1.5;
}
var _local33 = wheelPList;
var _local44 = _local33[1].x - _local33[0].x;
var _local43 = _local33[1].y - _local33[0].y;
angle = (Math.atan2(_local43, _local44) * 180) / Math.PI;
var _local49 = (Math.cos(vr) * _local44) - (Math.sin(vr) * _local43);
var _local48 = (Math.sin(vr) * _local44) + (Math.cos(vr) * _local43);
_local33[1].x = _local49 + _local33[0].x;
_local33[1].y = _local48 + _local33[0].y;
rimPList[0].s = Math.max(-maxS, Math.min(maxS, rimPList[0].s + _local40)) + _local45;
rimPList[1].s = Math.max(-maxS, Math.min(maxS, rimPList[1].s + _local40)) + _local45;
var _local13 = 0.999995;
var _local32 = 0.28;
_local33 = rimPList;
for (var _local42 in _local33) {
var _local3 = _local33[_local42];
var _local7 = -_local3.y;
var _local6 = _local3.x;
var _local34 = Math.sqrt((_local7 * _local7) + (_local6 * _local6));
_local7 = _local7 / _local34;
_local6 = _local6 / _local34;
_local3.x = _local3.x + (_local3.s * _local7);
_local3.y = _local3.y + (_local3.s * _local6);
var _local26 = _local3.ox;
var _local25 = _local3.oy;
var _local24 = (_local3.ox = _local3.x);
var _local23 = (_local3.oy = _local3.y);
_local3.x = _local3.x + (_local13 * (_local24 - _local26));
_local3.y = _local3.y + (_local13 * (_local23 - _local25));
var _local12 = Math.sqrt((_local3.x * _local3.x) + (_local3.y * _local3.y));
var _local35 = (_local12 - _local3.len) / _local12;
_local3.x = _local3.x - (_local3.x * _local35);
_local3.y = _local3.y - (_local3.y * _local35);
}
_local33 = bodyPList;
var _local37;
var _local39;
var _local38;
_local39 = 0;
_local38 = 0;
_local37 = 0;
for (var _local42 in _local33) {
var _local3 = _local33[_local42];
var _local26 = _local3.ox;
var _local25 = _local3.oy;
var _local24 = (_local3.ox = _local3.x);
var _local23 = (_local3.oy = _local3.y);
_local3.xbef = _local3.x;
_local3.ybef = _local3.y;
_local3.x = _local3.x + (_local13 * (_local24 - _local26));
_local3.y = _local3.y + ((_local13 * (_local23 - _local25)) + _local32);
_local39 = _local39 + _local3.x;
_local38 = _local38 + _local3.y;
}
_local33 = wheelPList;
for (var _local42 in _local33) {
var _local3 = _local33[_local42];
var _local26 = _local3.ox;
var _local25 = _local3.oy;
var _local24 = (_local3.ox = _local3.x);
var _local23 = (_local3.oy = _local3.y);
_local3.x = _local3.x + ((Math.abs(_local13 * (_local24 - _local26)) < maxSPEED) ? (_local13 * (_local24 - _local26)) : (maxSPEED * ((_local13 * (_local24 - _local26)) / Math.abs(_local13 * (_local24 - _local26)))));
_local3.y = _local3.y + ((Math.abs((_local13 * (_local23 - _local25)) + _local32) < maxSPEED) ? ((_local13 * (_local23 - _local25)) + _local32) : ((maxSPEED * ((_local13 * (_local23 - _local25)) / Math.abs(_local13 * (_local23 - _local25)))) + _local32));
_local37 = _local37 + _local3.y;
}
var _local20 = bodySList;
for (var _local42 in _local20) {
var _local4 = _local20[_local42];
var _local9 = _local4.p0;
var _local8 = _local4.p1;
var _local15 = _local4.rlen;
var _local7 = _local9.x - _local8.x;
var _local6 = _local9.y - _local8.y;
var _local12 = Math.sqrt((_local7 * _local7) + (_local6 * _local6));
var _local5 = 0;
var _local10 = 0;
_local10 = (_local12 - _local15) / _local12;
_local5 = _local10;
_local5 = _local5 * (_local4.w0 * _local4.e);
_local10 = _local10 * (_local4.w1 * _local4.e);
_local9.x = _local9.x - (_local7 * _local5);
_local9.y = _local9.y - (_local6 * _local5);
_local8.x = _local8.x + (_local7 * _local10);
_local8.y = _local8.y + (_local6 * _local10);
}
_local20 = wheelSList;
for (var _local42 in _local20) {
var _local4 = _local20[_local42];
var _local9 = _local4.p0;
var _local8 = _local4.p1;
var _local15 = _local4.rlen;
var _local7 = _local9.x - _local8.x;
var _local6 = _local9.y - _local8.y;
var _local12 = Math.sqrt((_local7 * _local7) + (_local6 * _local6));
var _local5 = 0;
var _local10 = 0;
_local10 = (_local12 - _local15) / _local12;
_local5 = _local10;
_local5 = _local5 * (_local4.w0 * _local4.e);
_local10 = _local10 * (_local4.w1 * _local4.e);
if (_local42 == 6) {
if (Math.abs(_local12 - _local15) > 5) {
}
}
_local9.x = _local9.x - (_local7 * _local5);
_local9.y = _local9.y - (_local6 * _local5);
_local8.x = _local8.x + (_local7 * _local10);
_local8.y = _local8.y + (_local6 * _local10);
}
var _local51 = 400;
_local33 = wheelPList;
wheel1coll = false;
wheel2coll = false;
for (var _local42 in _local33) {
var _local3 = _local33[_local42];
var _local27 = false;
var _local22 = 0;
var _local29 = 0;
var _local31 = 0;
var _local30 = 0;
var _local28 = 0;
var _local11 = 0;
while (_local11 < (jumTitik - 1)) {
var _local19 = arrLineStrip[(_local11 * 2) + 0];
var _local17 = arrLineStrip[(_local11 * 2) + 1];
var _local18 = arrLineStrip[(_local11 * 2) + 2];
var _local16 = arrLineStrip[(_local11 * 2) + 3];
var _local14 = sphere_line_intersection(_local19, _local17, _local18, _local16, _local3.x, _local3.y, _local3.r);
tembus = false;
if (_local42 == "0") {
wheel1coll = wheel1coll | _local14;
} else {
wheel2coll = wheel2coll | _local14;
}
tembus = LineIntersection(_local3.ox, _local3.oy, _local3.x, _local3.y, _local19, _local17, _local18, _local16);
if (tembus) {
CalcPushForce(_local3, _local19, _local17, _local18, _local16);
}
if (_local14 || (tembus)) {
_local27 = _local27 | _local14;
_local29 = _local29 + npushx;
_local31 = _local31 + npushy;
if ((Math.abs(npushy) > 7) || (Math.abs(npushx) > 7)) {
_root.soundBikeLands.start();
}
if (tembus) {
_local33 = wheelPList;
_local3.x = _local3.x + npushx;
_local3.y = _local3.y + npushy;
_local3.ox = _local3.ox + npushx;
_local3.oy = _local3.oy + npushy;
_local20 = bodySList;
for (var _local42 in _local20) {
var _local4 = _local20[_local42];
var _local9 = _local4.p0;
var _local8 = _local4.p1;
var _local15 = _local4.rlen;
var _local7 = _local9.x - _local8.x;
var _local6 = _local9.y - _local8.y;
var _local12 = Math.sqrt((_local7 * _local7) + (_local6 * _local6));
var _local5 = 0;
var _local10 = 0;
_local10 = (_local12 - _local15) / _local12;
_local5 = _local10;
_local5 = _local5 * (_local4.w0 * _local4.e);
_local10 = _local10 * (_local4.w1 * _local4.e);
_local9.x = _local9.x - (_local7 * _local5);
_local9.y = _local9.y - (_local6 * _local5);
_local8.x = _local8.x + (_local7 * _local10);
_local8.y = _local8.y + (_local6 * _local10);
}
_local20 = wheelSList;
for (var _local42 in _local20) {
var _local4 = _local20[_local42];
var _local9 = _local4.p0;
var _local8 = _local4.p1;
var _local15 = _local4.rlen;
var _local7 = _local9.x - _local8.x;
var _local6 = _local9.y - _local8.y;
var _local12 = Math.sqrt((_local7 * _local7) + (_local6 * _local6));
var _local5 = 0;
var _local10 = 0;
_local10 = (_local12 - _local15) / _local12;
_local5 = _local10;
_local5 = _local5 * (_local4.w0 * _local4.e);
_local10 = _local10 * (_local4.w1 * _local4.e);
if (_local42 == 6) {
if (Math.abs(_local12 - _local15) > 5) {
}
}
_local9.x = _local9.x - (_local7 * _local5);
_local9.y = _local9.y - (_local6 * _local5);
_local8.x = _local8.x + (_local7 * _local10);
_local8.y = _local8.y + (_local6 * _local10);
}
}
_local30 = _local30 + nx;
_local28 = _local28 + ny;
_local22++;
}
_local11++;
}
if (_local27) {
_local3.x = _local3.x + (_local29 / _local22);
_local3.y = _local3.y + (_local31 / _local22);
ResolveWheel(_local42, _local30 / _local22, _local28 / _local22);
}
}
var _local46 = 0;
var _local47 = 0;
if (vr > 0) {
_local46 = 1;
_local47 = -1;
}
if (vr < 0) {
_local46 = -1;
_local47 = -0.8;
}
var _local50 = (bodyPList[1].ybef - bodyPList[1].y) / 8.5;
_root.bike1.racer.Tick(_local50, _local46, _local47);
_root.bike1.racer.GetHeadPos();
}
function ResolveWheel(i, nx, ny) {
var _local3 = wheelPList[i];
var _local2 = rimPList[i];
var _local5 = -_local2.y;
var _local4 = _local2.x;
var _local6 = Math.sqrt((_local5 * _local5) + (_local4 * _local4));
_local5 = _local5 / _local6;
_local4 = _local4 / _local6;
var _local14 = _local5 * _local2.s;
var _local12 = _local4 * _local2.s;
var _local13 = _local3.x - _local3.ox;
var _local11 = _local3.y - _local3.oy;
var _local10 = _local13 + _local14;
var _local9 = _local11 + _local12;
var _local7 = ((-ny) * _local10) + (nx * _local9);
_local2.ox = _local2.x - (_local7 * _local5);
_local2.oy = _local2.y - (_local7 * _local4);
var _local8 = 1 - _local2.w;
_local3.x = _local3.x + ((_local8 * _local2.s) * (-ny));
_local3.y = _local3.y + ((_local8 * _local2.s) * nx);
_local2.s = _local2.s * _local2.w;
}
function Draw(mc, posCamX, posCamY) {
mc.lineStyle(0, 0, 100);
_root.bike1._x = bodyPList[1].x - posCamX;
_root.bike1._y = bodyPList[1].y - posCamY;
var _local10 = (Math.atan2(wheelPList[1].y - wheelPList[0].y, wheelPList[1].x - wheelPList[0].x) * 180) / Math.PI;
_root.bike1._rotation = _local10;
for (var _local11 in bodyPList) {
var _local4 = bodyPList[_local11];
}
mc.lineStyle(0, 8947848, 100);
for (var _local11 in wheelPList) {
var _local4 = wheelPList[_local11];
_root["circ" + _local11]._x = _local4.x - posCamX;
_root["circ" + _local11]._y = _local4.y - posCamY;
}
mc.lineStyle(0, 2263074, 100);
mc.lineStyle(2, 8921736, 100);
for (var _local11 in rimPList) {
var _local5 = rimPList[_local11];
var _local3 = wheelPList[_local11];
var _local9 = ((_local5.x + _local3.x) - posCamX) - (_local3.x - posCamX);
var _local8 = ((_local5.y + _local3.y) - posCamY) - (_local3.y - posCamY);
_local10 = Math.atan2(-_local8, -_local9);
_root["circ" + _local11]._rotation = (_local10 * 180) / Math.PI;
}
}
var yi = 0;
var SKEWFACT = 5;
var SPLITFACT = 5;
var templen = 0;
var wOut = 20;
var wDown = 25;
var wRad = 17;
var maxS = 4;
var maxSPEED = 15;
var angle = 0;
}
Symbol 123 MovieClip Frame 1
stop();
_root.mapType = "jungle";
Symbol 123 MovieClip Frame 5
stop();
_root.mapType = "desert";
Symbol 154 MovieClip Frame 1
var geret = false;
Instance of Symbol 154 MovieClip in Symbol 155 MovieClip Frame 1
onClipEvent (mouseDown) {
if (this.hitTest(_root._xmouse, _root._ymouse, false)) {
this.geret = true;
}
}
onClipEvent (mouseMove) {
if (this.geret) {
this._x = _root._xmouse - this._parent._x;
if (this._x < 30) {
this._x = 30;
}
if (this._x > 345) {
this._x = 345;
}
_root.maxLengthWorld = 10000 + ((this._x / 345) * 30000);
_root.maxHeightWorld = _root.maxLengthWorld / 5.6;
_root.ResetTerrain();
}
}
onClipEvent (mouseUp) {
this.geret = false;
}
Symbol 166 Button
on (release) {
_root.terrainselect.play();
}
Symbol 168 Button
on (release) {
_root.randomWidthFactor--;
if (_root.randomWidthFactor < 1) {
_root.randomWidthFactor = 1;
}
_root.ResetTerrain();
}
Symbol 169 Button
on (release) {
_root.randomWidthFactor++;
if (_root.randomWidthFactor > 10) {
_root.randomWidthFactor = 10;
}
_root.ResetTerrain();
}
Symbol 172 Button
on (release) {
_root.randomHeightFactor--;
if (_root.randomHeightFactor < 1) {
_root.randomHeightFactor = 1;
}
_root.ResetTerrain();
}
Symbol 173 Button
on (release) {
_root.randomHeightFactor++;
if (_root.randomHeightFactor > 10) {
_root.randomHeightFactor = 10;
}
_root.ResetTerrain();
}
Symbol 178 Button
on (release) {
_root.gotoAndStop("startlevel");
}
Symbol 185 MovieClip Frame 1
stop();
Symbol 185 MovieClip Frame 10
stop();
Symbol 201 MovieClip Frame 60
_root.play();
stop();
Symbol 205 MovieClip Frame 1
stop();
Symbol 205 MovieClip Frame 40
stop();
Symbol 211 MovieClip Frame 44
_root.play();
stop();
Symbol 218 Button
on (release) {
_root.gotoAndPlay("startlevel");
}
Symbol 222 Button
on (release) {
_root.gotoAndPlay(1);
}