home *** CD-ROM | disk | FTP | other *** search
- function teclas()
- {
- keyListener = new Object();
- keyListener.onKeyDown = function()
- {
- var _loc2_ = Key.getCode();
- if(_loc2_ == 80)
- {
- _root.Pause = true;
- }
- if(_loc2_ == 87 || _loc2_ == 38)
- {
- tacelerando = true;
- }
- if(_loc2_ == 83 || _loc2_ == 40)
- {
- tfrenando = true;
- }
- if(_loc2_ == 65 || _loc2_ == 37)
- {
- tgizkierda = true;
- }
- if(_loc2_ == 68 || _loc2_ == 39)
- {
- tgderexa = true;
- }
- };
- keyListener.onKeyUp = function()
- {
- switch(Key.getCode())
- {
- case 76:
- if(lfaro == true)
- {
- lfaro = false;
- }
- else
- {
- lfaro = true;
- }
- break;
- case 87:
- tacelerando = false;
- break;
- case 38:
- tacelerando = false;
- break;
- case 83:
- tfrenando = false;
- break;
- case 40:
- tfrenando = false;
- break;
- case 65:
- tgizkierda = false;
- break;
- case 37:
- tgizkierda = false;
- break;
- case 68:
- tgderexa = false;
- break;
- case 39:
- tgderexa = false;
- }
- };
- if(listening == false)
- {
- Key.addListener(keyListener);
- listening = true;
- }
- }
- function luces()
- {
- if(lfaro == true)
- {
- this.luzmc.gotoAndStop(1);
- this.coxemc.faros_mc.gotoAndStop(2);
- }
- else
- {
- this.luzmc.gotoAndStop(2);
- this.coxemc.faros_mc.gotoAndStop(1);
- }
- if(lfrenando == true)
- {
- _root.coxemc.lfrenomc.gotoAndStop(2);
- }
- else if(lmarxatras == true)
- {
- _root.coxemc.lfrenomc.gotoAndStop(3);
- }
- else
- {
- _root.coxemc.lfrenomc.gotoAndStop(1);
- }
- }
- function cCamera(obj)
- {
- _root.luzmc._rotation = this.coxemc._rotation;
- _root.luzmc._x = this.coxemc._x;
- _root.luzmc._y = this.coxemc._y;
- _root.panelmc._x = Stage.width / 2 - (_root._x - 275);
- _root.panelmc._y = Stage.height / 2 - (_root._y - 200);
- }
- function detectKeys(tacel, maxspd)
- {
- if(tacelerando == true)
- {
- lfrenando = false;
- lmarxatras = false;
- if(speed > - maxspd)
- {
- speed -= tacel;
- }
- }
- else if(tfrenando == true)
- {
- if(speed < 0)
- {
- speed += tfreno;
- lfrenando = true;
- if(speed > 0)
- {
- speed = 0;
- lfrenando = true;
- lmarxatras = false;
- }
- }
- else
- {
- lfrenando = false;
- }
- if(speed > -0.05)
- {
- if(speed < maxspd / 2)
- {
- speed += tacel / 2;
- lmarxatras = true;
- }
- }
- }
- else if(speed < 0)
- {
- if(speed > -0.05)
- {
- speed = 0;
- lfrenando = true;
- lmarxatras = false;
- }
- else
- {
- speed += friction;
- }
- }
- else if(speed < 0.05)
- {
- speed = 0;
- lfrenando = true;
- lmarxatras = false;
- }
- else
- {
- speed -= friction;
- }
- if(tgizkierda == true)
- {
- this.coxemc._rotation += speed * tmani;
- }
- if(tgderexa == true)
- {
- this.coxemc._rotation -= speed * tmani;
- }
- if(this.coxemc._rotation > 180)
- {
- _root.pistamc._y -= speed * Math.cos(0.017453292519943295 * this.coxemc._rotation);
- _root.pistamc._x += speed * Math.sin(0.017453292519943295 * this.coxemc._rotation);
- }
- else
- {
- _root.pistamc._y -= speed * Math.cos(0.017453292519943295 * this.coxemc._rotation);
- _root.pistamc._x += speed * Math.sin(0.017453292519943295 * this.coxemc._rotation);
- }
- }
- stop();
- _root.coxemc.gotoAndStop(_global.coxe);
- _root.pistamc.gotoAndStop(_global.pista);
- _root.minimapmc.minimap1.gotoAndStop(_global.pista);
- switch(_global.coxe)
- {
- case 1:
- friction = 0.1;
- tfreno = 0.2;
- acel = 0.1;
- tmaxspd = 8;
- tmani = 0.3;
- break;
- case 2:
- friction = 0.1;
- tfreno = 0.2;
- acel = 0.05;
- tmaxspd = 9;
- tmani = 0.2;
- break;
- case 3:
- friction = 0.1;
- tfreno = 0.2;
- acel = 0.07;
- tmaxspd = 7;
- tmani = 0.4;
- break;
- case 4:
- friction = 0.2;
- tfreno = 0.1;
- acel = 0.02;
- tmaxspd = 7;
- tmani = 0.4;
- }
- switch(_global.pista)
- {
- case 1:
- _root.pistamc._x = -323;
- _root.pistamc._y = 251;
- break;
- case 2:
- _root.pistamc._x = -846;
- _root.pistamc._y = -29;
- break;
- case 3:
- _root.pistamc._x = -545;
- _root.pistamc._y = -41;
- }
- Pause = false;
- speed = 0;
- rstart = false;
- cp1 = false;
- cp2 = false;
- v1 = 0;
- v2 = 0;
- v3 = 0;
- lfrenando = false;
- lnoxe = false;
- lmarxatras = false;
- lfaro = true;
- timer = 0;
- timer2 = 0;
- listening = false;
- tacelerando = false;
- tfrenando = false;
- tgderexa = false;
- tgizkierda = false;
- accel = new Sound();
- accel.attachSound("accel");
- decel = new Sound();
- decel.attachSound("decel");
- hi_loop = new Sound();
- hi_loop.attachSound("hi_loop");
- low_loop = new Sound();
- low_loop.attachSound("low_loop");
- accel = new Sound();
- accel.attachSound("accel");
- decel = new Sound();
- decel.attachSound("decel");
- vol = 100;
- this.onEnterFrame = function()
- {
- this.minimapmc.minimap1._x = _root.pistamc._x / 10 + 35;
- this.minimapmc.minimap1._y = _root.pistamc._y / 10 - 15;
- if(Pause == true)
- {
- _root.pausemc._x = 0;
- }
- else
- {
- _root.pausemc._x = 600;
- if(rstart == true)
- {
- timer++;
- }
- if(rstart == false && _root.coxemc.hitTest(this.pistamc.salida))
- {
- rstart = true;
- }
- if(rstart == true && cp1 == false && cp2 == false && _root.coxemc.hitTest(this.pistamc.cp1))
- {
- cp1 = true;
- }
- if(rstart == true && cp1 == true && cp2 == false && _root.coxemc.hitTest(this.pistamc.cp2))
- {
- cp2 = true;
- }
- if(rstart == true && cp1 == true && cp2 == true && _root.coxemc.hitTest(this.pistamc.salida))
- {
- if(v1 == 0)
- {
- v1 = timer2;
- _root.panelmc.v1t.text = v1;
- cp1 = false;
- cp2 = false;
- }
- else if(v2 == 0)
- {
- v2 = timer2 - v1;
- _root.panelmc.v2t.text = v2;
- cp1 = false;
- cp2 = false;
- }
- else if(v3 == 0)
- {
- v3 = timer2 - (v1 + v2);
- _root.panelmc.v3t.text = v3;
- cp1 = false;
- cp2 = false;
- if(v1 < v2 && v1 < v3)
- {
- _root.panelmc.bestt.text = "Best: " + v1;
- }
- else if(v2 < v3 && v2 < v1)
- {
- _root.panelmc.bestt.text = "Best: " + v2;
- }
- else
- {
- _root.panelmc.bestt.text = "Best: " + v3;
- }
- _root.panelmc.totalt.text = "Total: " + (v1 + v2 + v3);
- switch(_global.pista)
- {
- case 1:
- _global.t1 = v1 + v2 + v3;
- break;
- case 2:
- _global.t2 = v1 + v2 + v3;
- break;
- case 3:
- _global.t3 = v1 + v2 + v3;
- }
- _root.Pause = true;
- }
- }
- timer2 = timer;
- this.panelmc.timermc.timer.text = timer2;
- this.panelmc.ckil.ckilnum.ckilltr.text = Math.abs(Math.round(speed * 12));
- teclas();
- if(CollisionDetection.checkForCollision(_root.coxemc,_root.pistamc.lapista))
- {
- detectKeys(acel,tmaxspd);
- }
- else
- {
- detectKeys(acel / 5,tmaxspd / 5);
- if(speed < -2)
- {
- speed += friction * 2;
- }
- }
- _root.panelmc.ckil.gotoAndStop(Math.abs(Math.round(speed * 100 / tmaxspd)));
- cCamera(coxemc);
- luces();
- }
- };
-