home *** CD-ROM | disk | FTP | other *** search
- function WorldToScreen(world_x, world_y, world_z)
- {
- x = Math.round(world_x * 7 + world_z * 5 * 1.4);
- y = Math.round(- world_z * 5 + world_x * 7 * 0.71426 - world_y * 5);
- return [x,y];
- }
- var Snd_hit = new Sound();
- Snd_hit.attachSound("hit_1");
- var Snd_hit2 = new Sound();
- Snd_hit2.attachSound("hit_2");
- var B = new Object();
- B.clip = "tile_blktop";
- B.oktodrive = true;
- B.effects = new Object();
- B.effects.bumpy = 0;
- B.effects.drag = 0;
- var P = new Object();
- P.clip = "tile_pothole";
- P.oktodrive = true;
- P.effects = new Object();
- P.effects.bumpy = 5;
- P.effects.drag = 0.08;
- var L = new Object();
- L.clip = "obj_lightpole";
- L.doWhenHit = function(speed, angle, tile)
- {
- if(Math.abs(_root.game.player.speed) >= 0.5)
- {
- _root.Snd_hit.start();
- }
- _root.game.player.car_x += (- speed) * Math.sin(angle * 3.141592653589793 / 180);
- _root.game.player.car_z += (- speed) * Math.cos(angle * 3.141592653589793 / 180);
- _root.game.player.speed = - _root.game.player.speed * 0.8;
- };
- var H = new Object();
- H.clip = "obj_hydrant";
- H.doWhenHit = function(speed, angle, tile)
- {
- _root.lives = _root.lives - 1;
- this.nextFrame();
- if(Math.abs(_root.game.player.speed) >= 0.5)
- {
- _root.Snd_hit.start();
- }
- _root.game.player.car_x += (- speed) * Math.sin(angle * 3.141592653589793 / 180);
- _root.game.player.car_z += (- speed) * Math.cos(angle * 3.141592653589793 / 180);
- _root.game.player.speed = - _root.game.player.speed * 0.8;
- tile.object = null;
- if(_root.lives <= 0)
- {
- _root.lives = 0;
- timer.display = 0;
- this._xscale = 0;
- _root.timer.onEnterFrame = null;
- _root.game.player.onEnterFrame = null;
- _root.gotoAndPlay("game_over");
- }
- };
- var S = new Object();
- S.clip = "obj_sp_cone";
- S.doWhenHit = function(speed, angle, tile)
- {
- _root.Snd_hit2.start();
- _root.score += 50;
- _root.cones_hit = _root.cones_hit + 1;
- this.speed = speed * 1.8;
- this.angle = angle + (random(30) - 15);
- if(this.angle < 0)
- {
- this.angle = 360 + this.angle;
- }
- this.angle %= 360;
- var _loc3_ = "hit_" + 45 * Math.floor(this.angle / 45);
- this.gotoAndStop(_loc3_);
- _root.game.player.speed *= 0.8;
- this.onEnterFrame = this.doAfterHit;
- tile.object = null;
- };
- S.doAfterHit = function()
- {
- if(Math.abs(this.trans_x) + Math.abs(this.trans_z) >= 0.01)
- {
- this.trans_x = this.speed * Math.sin(this.angle * 3.141592653589793 / 180);
- this.trans_z = this.speed * Math.cos(this.angle * 3.141592653589793 / 180);
- this.pos_x += this.trans_x;
- this.pos_z += this.trans_z;
- var _loc3_ = _root.WorldToScreen(this.pos_x,0,this.pos_z);
- var _loc4_ = Math.floor((world.totaldepth - (this.pos_z + 8)) * 1000 + this.pos_x);
- this.swapDepths(_loc4_);
- this._x = _loc3_[0];
- this._y = _loc3_[1];
- this.speed *= 0.8;
- this.t_row = Math.floor(this.pos_z / _root.world.tile_height);
- this.t_col = Math.floor(this.pos_x / _root.world.tile_width);
- this.t_tile = _root.game["tile_" + this.t_row + "_" + this.t_col];
- this.t_object = this.t_tile.object;
- if(this.t_object)
- {
- _loc3_ = WorldToScreen(this.t_object.pos_x,0,this.t_object.pos_z);
- if(this.hitTest(_loc3_[0] + _root.game._x,_loc3_[1] + _root.game._y,true))
- {
- this.t_object = null;
- this.t_object.doWhenHit(this.speed,this.angle,this.t_tile);
- }
- }
- }
- else
- {
- this._alpha -= 5;
- if(this._alpha <= 0)
- {
- this.removeMovieClip();
- }
- }
- };
- var C = new Object();
- C.clip = "obj_cone";
- C.doWhenHit = function(speed, angle, tile)
- {
- _root.Snd_hit2.start();
- _root.score += 10;
- _root.cones_hit = _root.cones_hit + 1;
- this.speed = speed * 1.8;
- this.angle = angle + (random(30) - 15);
- if(this.angle < 0)
- {
- this.angle = 360 + this.angle;
- }
- this.angle %= 360;
- var _loc3_ = "hit_" + 45 * Math.floor(this.angle / 45);
- this.gotoAndStop(_loc3_);
- _root.game.player.speed *= 0.8;
- this.onEnterFrame = this.doAfterHit;
- tile.object = null;
- };
- C.doAfterHit = function()
- {
- if(Math.abs(this.trans_x) + Math.abs(this.trans_z) >= 0.01)
- {
- this.trans_x = this.speed * Math.sin(this.angle * 3.141592653589793 / 180);
- this.trans_z = this.speed * Math.cos(this.angle * 3.141592653589793 / 180);
- this.pos_x += this.trans_x;
- this.pos_z += this.trans_z;
- var _loc3_ = _root.WorldToScreen(this.pos_x,0,this.pos_z);
- var _loc4_ = Math.floor((world.totaldepth - (this.pos_z + 8)) * 1000 + this.pos_x);
- this.swapDepths(_loc4_);
- this._x = _loc3_[0];
- this._y = _loc3_[1];
- this.speed *= 0.8;
- this.t_row = Math.floor(this.pos_z / _root.world.tile_height);
- this.t_col = Math.floor(this.pos_x / _root.world.tile_width);
- this.t_tile = _root.game["tile_" + this.t_row + "_" + this.t_col];
- this.t_object = this.t_tile.object;
- if(this.t_object)
- {
- _loc3_ = WorldToScreen(this.t_object.pos_x,0,this.t_object.pos_z);
- if(this.hitTest(_loc3_[0] + _root.game._x,_loc3_[1] + _root.game._y,true))
- {
- this.t_object = null;
- this.t_object.doWhenHit(this.speed,this.angle,this.t_tile);
- }
- }
- }
- else
- {
- this._alpha -= 5;
- if(this._alpha <= 0)
- {
- this.removeMovieClip();
- }
- }
- };
- var map = new Array();
- map[0] = [B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B];
- map[1] = [B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B];
- map[2] = [B,B,B,P,B,B,B,B,P,B,B,B,B,B,B,P,B,B,B,B,P,B,B,B];
- map[3] = [B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B];
- map[4] = [B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B];
- map[5] = [B,B,B,B,B,B,P,B,B,B,B,B,B,B,B,B,B,B,P,B,B,B,B,B];
- map[6] = [B,B,P,B,B,B,B,B,B,B,B,B,B,B,P,B,B,B,B,B,B,B,B,B];
- map[7] = [B,B,B,P,B,B,B,B,B,B,B,B,B,B,B,P,B,B,B,B,B,B,B,B];
- map[8] = [B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B];
- map[9] = [B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B];
- map[10] = [B,B,B,B,B,B,B,P,B,B,B,B,B,B,B,B,B,B,B,P,B,B,B,B];
- map[11] = [B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B];
- map[12] = [B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B];
- map[13] = [B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B];
- map[14] = [B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B];
- map[15] = [B,B,B,P,B,B,B,B,P,B,B,B,B,B,B,P,B,B,B,B,P,B,B,B];
- map[16] = [B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B];
- map[17] = [B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B];
- map[18] = [B,B,B,B,B,B,P,B,B,B,B,B,B,B,B,B,B,B,P,B,B,B,B,B];
- map[19] = [B,B,P,B,B,B,B,B,B,B,B,B,B,B,P,B,B,B,B,B,B,B,B,B];
- map[20] = [B,B,B,P,B,B,B,B,B,B,B,B,B,B,B,P,B,B,B,B,B,B,B,B];
- map[21] = [B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B];
- map[22] = [B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B];
- map[23] = [B,B,B,B,B,B,B,P,B,B,B,B,B,B,B,B,B,B,B,P,B,B,B,B];
- map[24] = [B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B];
- map[25] = [B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B];
- var objects = new Array();
- objects[0] = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
- objects[1] = [0,S,0,C,0,0,C,0,0,S,0,0,0,S,0,C,0,0,C,0,0,S,0,0];
- objects[2] = [0,C,0,0,0,H,0,0,C,O,0,H,0,C,0,0,0,H,0,0,C,O,0,0];
- objects[3] = [0,0,C,C,L,0,H,0,0,0,C,0,0,0,C,C,L,0,H,0,0,0,C,0];
- objects[4] = [0,0,0,0,0,0,0,0,0,0,C,0,0,0,0,0,0,0,0,0,0,0,C,0];
- objects[5] = [0,H,C,O,0,0,0,O,0,C,0,0,H,0,C,O,0,0,0,O,0,C,0,0];
- objects[6] = [0,0,0,L,0,0,C,0,0,C,0,0,0,0,0,L,0,0,C,0,0,C,0,0];
- objects[7] = [0,0,L,H,0,C,0,C,0,0,H,0,0,0,L,0,H,C,0,C,0,0,H,0];
- objects[8] = [0,0,C,O,0,0,O,0,C,0,C,0,0,0,C,O,0,0,O,0,C,0,C,0];
- objects[9] = [0,C,S,0,0,0,C,C,C,0,H,0,0,C,S,0,0,0,C,C,C,0,H,0];
- objects[10] = [0,0,0,C,H,0,C,S,C,0,0,0,0,0,0,C,0,H,C,S,C,0,0,0];
- objects[11] = [0,0,C,C,0,S,C,C,C,0,O,0,0,H,C,C,0,S,C,C,C,0,O,0];
- objects[12] = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,H,0,0,0];
- objects[13] = [0,0,C,C,0,S,C,C,C,0,H,0,0,0,C,C,0,S,C,C,C,0,O,0];
- objects[14] = [0,S,H,C,0,C,C,0,0,S,0,0,0,S,0,C,0,C,C,0,0,S,0,0];
- objects[15] = [0,C,0,0,0,0,0,0,C,L,0,0,0,C,0,0,0,H,0,0,C,L,0,0];
- objects[16] = [0,C,C,C,0,0,H,0,0,C,C,0,0,C,C,C,0,0,C,0,0,0,C,0];
- objects[17] = [0,C,0,0,C,S,0,0,0,C,H,0,0,C,0,0,C,S,0,0,0,C,C,0];
- objects[18] = [0,L,C,H,0,0,0,L,C,C,0,0,0,L,C,0,H,0,C,L,0,C,0,0];
- objects[19] = [0,0,0,S,C,C,H,C,0,0,0,0,0,0,0,S,C,C,C,C,0,C,0,0];
- objects[20] = [0,L,0,0,0,C,0,C,0,0,H,0,0,0,0,S,C,C,C,C,0,H,0,0];
- objects[21] = [0,C,C,C,L,0,C,0,C,0,C,0,0,0,C,C,C,H,C,0,C,S,C,0];
- objects[22] = [0,C,S,C,0,0,0,C,H,0,0,O,0,C,S,C,0,0,C,C,H,0,0,0];
- objects[23] = [0,H,C,C,0,0,C,S,C,0,0,0,C,C,C,C,0,0,0,C,C,0,0,0];
- objects[24] = [0,C,C,C,H,S,C,C,C,0,L,0,0,C,C,C,H,S,C,C,C,0,L,0];
- objects[25] = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
- var world = new Object();
- world.tile_width = 10;
- world.tile_height = 10;
- world.totaldepth = world.tile_height * map.length;
- world.totalwidth = world.tile_width * map[0].length;
- var screen = new Object();
- screen.scroll_x = 0;
- screen.scroll_y = 0;
- screen.keepplayerat_x = 200;
- screen.keepplayerat_y = 200;
- var player = new Object();
- player.car_x = 55;
- player.car_y = 0;
- player.car_z = 55;
- player.speed = 0;
- player.maxspeed = 2;
- player.accelrate = 0.2;
- player.decelrate = 0.9;
- player.angle = 0;
- player.anglechange = 0;
- player.maxanglechange = 10;
- player.anglechangerate = 7;
- player.allowturns = true;
- stop();
-