home *** CD-ROM | disk | FTP | other *** search
- timer.gameStartTime = getTimer();
- timer.gameDuration = 60000;
- timer.gameTimerStarted = false;
- timer.display = 60;
- timer.onEnterFrame = function()
- {
- gameTimeLeft = this.gameDuration - (getTimer() - this.gameStartTime);
- if(gameTimeLeft <= 0)
- {
- timer.display = 0;
- this._xscale = 0;
- _root.timer.onEnterFrame = null;
- _root.game.player.onEnterFrame = null;
- _root.gotoAndPlay("game_over");
- }
- else
- {
- secondsleft = Math.ceil(gameTimeLeft / 1000);
- timer.display = secondsleft;
- this._xscale = secondsleft * 1000 / this.gameDuration * 100;
- }
- };
- game.player.onEnterFrame = function()
- {
- if(Key.isDown(38))
- {
- this.speed = Math.min(this.maxspeed,this.speed + this.accelrate);
- }
- else if(Key.isDown(40))
- {
- this.speed = Math.max(- this.maxspeed,this.speed - this.accelrate);
- }
- else if(Math.abs(this.speed) <= 0.1)
- {
- this.speed = 0;
- }
- else
- {
- this.speed *= this.decelrate;
- }
- if(this.car_tile.effects.drag)
- {
- this.speed -= this.speed * this.car_tile.effects.drag;
- }
- if(Key.isDown(39) && this.allowturns == true)
- {
- this.speedpercent = this.speed / this.maxspeed;
- this.anglechange = Math.min(this.maxanglechange,this.maxanglechange * this.speedpercent);
- this.angle += this.anglechange;
- }
- else if(Key.isDown(37) && this.allowturns == true)
- {
- this.speedpercent = this.speed / this.maxspeed;
- this.anglechange = Math.max(- this.maxanglechange,(- this.maxanglechange) * this.speedpercent);
- this.angle += this.anglechange;
- }
- if(this.angle < 0)
- {
- this.angle = 360 + this.angle;
- }
- this.angle %= 360;
- this.stepfactor_x = Math.sin(this.angle * 3.141592653589793 / 180);
- this.stepfactor_z = Math.cos(this.angle * 3.141592653589793 / 180);
- this.t_car_x = this.car_x + this.speed * this.stepfactor_x;
- this.t_car_z = this.car_z + this.speed * this.stepfactor_z;
- if(this.speed >= 0)
- {
- this.t_bumper_x = this.t_car_x + 6 * this.stepfactor_x;
- this.t_bumper_z = this.t_car_z + 6 * this.stepfactor_z;
- }
- else
- {
- this.t_bumper_x = this.t_car_x + -6 * this.stepfactor_x;
- this.t_bumper_z = this.t_car_z + -6 * this.stepfactor_z;
- }
- this.t_car_row = Math.floor(this.t_car_z / _root.world.tile_height);
- this.t_car_col = Math.floor(this.t_car_x / _root.world.tile_width);
- this.t_car_tile = _root.game["tile_" + this.t_car_row + "_" + this.t_car_col];
- this.t_bumper_row = Math.floor(this.t_bumper_z / _root.world.tile_height);
- this.t_bumper_col = Math.floor(this.t_bumper_x / _root.world.tile_width);
- this.t_bumper_tile = _root.game["tile_" + this.t_bumper_row + "_" + this.t_bumper_col];
- this.t_bumper_object = this.t_bumper_tile.object;
- if(!this.t_bumper_tile.oktodrive)
- {
- this.speed = - this.speed * 0.8;
- this.allowturns = false;
- clearInterval(intervalID);
- var intervalID = setInterval(function()
- {
- _root.game.player.allowturns = true;
- clearInterval(intervalID);
- }
- ,250);
- return undefined;
- }
- this.car_x = this.t_car_x;
- this.car_z = this.t_car_z;
- this.bumper_x = this.t_bumper_x;
- this.bumper_z = this.t_bumper_z;
- this.car_row = this.t_car_row;
- this.car_col = this.t_car_col;
- this.car_tile = this.t_car_tile;
- this.bumper_row = this.t_bumper_row;
- this.bumper_col = this.t_bumper_col;
- this.bumper_tile = this.t_bumper_tile;
- this.bumper_object = this.t_bumper_object;
- this.bumper_local_x = this.bumper_x % _root.world.tile_width;
- this.bumper_local_z = this.bumper_z % _root.world.tile_height;
- if(this.bumper_object)
- {
- var _loc3_ = WorldToScreen(this.bumper_object.pos_x,0,this.bumper_object.pos_z);
- if(this.car_collider.hitTest(_loc3_[0] + _root.game._x,_loc3_[1] + _root.game._y,true))
- {
- this.bumper_object.doWhenHit(this.speed,this.angle,this.bumper_tile);
- }
- }
- this.pan_pos_x = this.car_x + 7 * this.speed * this.stepfactor_x;
- this.pan_pos_z = this.car_z + 7 * this.speed * this.stepfactor_z;
- _loc3_ = WorldToScreen(this.pan_pos_x,0,this.pan_pos_z);
- _root.focus_x = _loc3_[0];
- _root.focus_y = _loc3_[1];
- _loc3_ = WorldToScreen(this.car_x,this.car_y,this.car_z);
- var _loc5_ = Math.floor((world.totaldepth - this.car_z) * 1000 + this.car_x);
- this.swapDepths(_loc5_);
- var _loc4_ = Math.round(this.angle * 0.1) + 1;
- this.gotoAndStop(_loc4_);
- this.car_collider.gotoAndStop(_loc4_);
- this._x = _loc3_[0];
- this._y = _loc3_[1] + random(this.car_tile.effects.bumpy * Math.abs(this.speed));
- };
- stop();
-