Skip to content

Commit

Permalink
fixed barriers
Browse files Browse the repository at this point in the history
  • Loading branch information
Luis Buenaventura committed Mar 3, 2012
1 parent a3e386d commit b95e332
Showing 1 changed file with 37 additions and 35 deletions.
72 changes: 37 additions & 35 deletions public/javascripts/game.js
Expand Up @@ -310,23 +310,15 @@ Game = {


// Game.initialize_controls(); // Game.initialize_controls();


Game.initialize_high_score(); // Game.initialize_high_score();


Game.initialize_speed_changer(); Game.initialize_speed_changer();


Game.initialize_timer(); Game.initialize_timer();


Game.initialize_tutorial(); Game.initialize_tutorial();


Game.initialize_thoughtbubbles(); // Game.initialize_thoughtbubbles();

Game.global_car_odds = Game.difficulty_increases ? Game.car_odds_levels[Game.car_odds_levels.length-1][1] : 1;

Game.car_odds_total = 0;

_.each(Game.car_odds, function(odds){
Game.car_odds_total += odds[1];
});


if (auto_start===true) { if (auto_start===true) {
Game.start(); Game.start();
Expand Down Expand Up @@ -770,30 +762,38 @@ Game = {


initialize_level : function(level) { initialize_level : function(level) {


this.level = level===undefined ? LEVEL_1 : level; Game.level = level===undefined ? LEVEL_1 : level;

Game.max_speed = Game.level.max_speed,
Game.max_frustration = 100,


this.max_speed = this.level.max_speed, Game.maker_freq = Game.level.maker_frequency, // how often does a Maker add a new car to the road
this.max_frustration = 100, Game.max_cars_per_street = Game.level.max_cars_per_street,

Game.car_types = Game.level.cars, // library of car settings and assets
this.maker_freq = this.level.maker_frequency, // how often does a Maker add a new car to the road Game.car_odds = Game.level.car_odds, // the likelihood that a particular car will be added
this.max_cars_per_street = this.level.max_cars_per_street, Game.car_odds_levels = Game.level.car_odds_levels.reverse(), // modifiers for our car-creation randomness, basically making fewer cars spawn early on in the game
this.car_types = this.level.cars, // library of car settings and assets Game.car_odds_total = 0, // we populate this array with the car names based on their weights, then randomly select one to generate
this.car_odds = this.level.car_odds, // the likelihood that a particular car will be added Game.neighborhood = Game.level.neighborhood, // graphics used for the neighborhood layers
this.car_odds_levels = this.level.car_odds_levels.reverse(), // modifiers for our car-creation randomness, basically making fewer cars spawn early on in the game
this.car_odds_total = 0, // we populate this array with the car names based on their weights, then randomly select one to generate
this.neighborhood = this.level.neighborhood, // graphics used for the neighborhood layers


this.initialize_factory(); Game.global_car_odds = Game.difficulty_increases ? Game.car_odds_levels[Game.car_odds_levels.length-1][1] : 1;


this.initialize_streets(); Game.car_odds_total = 0;


this.initialize_barriers(); _.each(Game.car_odds, function(odds){
Game.car_odds_total += odds[1];
});


this.initialize_intersections(); Game.initialize_factory();

Game.initialize_barriers();

Game.initialize_intersections();


this.initialize_bosses(); Game.initialize_streets();


this.initialize_controls(); Game.initialize_bosses();

Game.initialize_controls();


}, },


Expand All @@ -806,9 +806,9 @@ Game = {


initialize_streets : function(){ initialize_streets : function(){


Game.log("initializing streets", Game.levels.streets.length); Game.log("initializing streets", Game.level.streets.length);


_.each( Game.levels.streets, function(street_data){ _.each( Game.level.streets, function(street_data){
var street = new Street(); var street = new Street();


street.initialize( Game, street_data, Game.car_context ); street.initialize( Game, street_data, Game.car_context );
Expand All @@ -819,11 +819,11 @@ Game = {


initialize_barriers : function(){ initialize_barriers : function(){


Game.log("initializing barriers", Game.levels.barriers.length); Game.log("initializing barriers", Game.level.barriers.length);


var self = this; var self = this;


_.each( Game.levels.barriers, function(b){ _.each( Game.level.barriers, function(b){
var t = b[0].match(/^([^\s]+)\_barrier[\d]$/i), var t = b[0].match(/^([^\s]+)\_barrier[\d]$/i),
hash = { name : b[0], hash = { name : b[0],
top : b[1], top : b[1],
Expand All @@ -841,13 +841,15 @@ Game = {
Game.barriers[t[1]] = [ hash ]; Game.barriers[t[1]] = [ hash ];
} }
}); });

console.log(Game.barriers);
}, },


initialize_intersections : function(){ initialize_intersections : function(){


Game.log("initializing intersections", Game.levels.intersections.length); Game.log("initializing intersections", Game.level.intersections.length);


_.each( Game.levels.intersections, function(intersection){ _.each( Game.level.intersections, function(intersection){
Game.intersections.push({ Game.intersections.push({
name : intersection[0], name : intersection[0],
top : intersection[1], top : intersection[1],
Expand All @@ -864,7 +866,7 @@ Game = {
Game.log("initializing controls", $(".stoplight").length); Game.log("initializing controls", $(".stoplight").length);


var self = this; var self = this;
self.stoplights = Game.levels.stoplights; self.stoplights = Game.level.stoplights;


// prevent gray overlay when tapping in iOS? // prevent gray overlay when tapping in iOS?
$('body').live('touchstart', function(e){ $('body').live('touchstart', function(e){
Expand Down Expand Up @@ -990,7 +992,7 @@ Game = {


Game.exit_intro(function(){ Game.exit_intro(function(){


Game.initialize_map(); Game.initialize_level();


Game.intro.hide(); Game.intro.hide();
Game.stop_sound_theme(); Game.stop_sound_theme();
Expand Down

0 comments on commit b95e332

Please sign in to comment.