Permalink
Browse files

added level support

  • Loading branch information...
1 parent a813ed3 commit a3e386de23286df021f4b22d9a14ab2bf1021430 @helloluis committed Mar 3, 2012
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -140,11 +140,11 @@
</script>
<script src="javascripts/modernizr.js"></script>
+ <script src="javascripts/underscore.js"></script>
<script src="javascripts/map.js"></script>
<script src="javascripts/sound.js"></script>
<script src="javascripts/soundmanager2-nodebug-jsmin.js"></script>
<script src="javascripts/pxloader.js"></script>
- <script src="javascripts/underscore.js"></script>
<script>
PLATFORM = 'web';
@@ -172,7 +172,7 @@
<body>
<div id="fb-root"></div>
-<!-- <script src='http://connect.facebook.net/en_US/all.js'></script> -->
+<script src='http://connect.facebook.net/en_US/all.js'></script>
<div id="all">
@@ -56,23 +56,13 @@ Game = {
can_adjust_speed : false, // clicking or swiping on a car will increase its speed
enable_hotkeys : false,
+ enable_thoughtbubbles : true,
factory : false,
streets : [], // array of Street objects
barriers : {}, // hash of barrier hitboxes
intersections : [], // array of intersection hitboxes
- max_speed : MAX_SPEED,
- max_frustration : 100,
- enable_thoughtbubbles : true,
-
- maker_freq : MAKER_FREQUENCY, // how often does a Maker add a new car to the road
- max_cars_per_street : MAX_CARS_PER_STREET,
- car_types : CARS, // library of car settings and assets
- car_odds : CAR_ODDS, // the likelihood that a particular car will be added
- car_odds_levels : CAR_ODDS_LEVELS.reverse(), // modifiers for our car-creation randomness, basically making fewer cars spawn early on in the game
- car_odds_total : 0, // we populate this array with the car names based on their weights, then randomly select one to generate
- neighborhood : NEIGHBORHOOD, // graphics used for the neighborhood layers
car_sprite_layout : CAR_SPRITE_LAYOUT,
images_dir : IMAGES_DIR, // path to images
@@ -241,12 +231,12 @@ Game = {
Game.dynamically_center();
- var detect = function(){
- console.log('detecting');
- Game.detect_resolution();
- }
+ // var detect = function(){
+ // console.log('detecting');
+ // Game.detect_resolution();
+ // }
- $(window).resize(_.debounce(detect, 1000));
+ // $(window).resize(_.debounce(detect, 1000));
},
@@ -267,17 +257,17 @@ Game = {
}
- if (Game.window_height < Game.height) {
+ if (Game.window_height <= Game.height-50) {
- Game.cont.height( Game.window_height );
+ Game.cont.height( Game.window_height ).addClass('height600');
var top = -((Game.height-Game.window_height)/2);
Game.intro.css({ marginTop: top }).height( Game.height );
Game.map.css({ top : top });
console.log(top);
} else {
- Game.cont.height( Game.height );
+ Game.cont.height( Game.height ).removeClass('height600');
Game.intro.css({ marginTop : 0 }).height( Game.height );
}
@@ -306,19 +296,19 @@ Game = {
Game.initialize_buttons();
- Game.initialize_bosses();
-
Game.initialize_sounds();
- Game.initialize_intersections();
+ // Game.initialize_bosses();
+
+ // Game.initialize_intersections();
- Game.initialize_barriers();
+ // Game.initialize_barriers();
- Game.initialize_factory();
+ // Game.initialize_factory();
- Game.initialize_streets();
+ // Game.initialize_streets();
- Game.initialize_controls();
+ // Game.initialize_controls();
Game.initialize_high_score();
@@ -778,18 +768,47 @@ Game = {
},
+ initialize_level : function(level) {
+
+ this.level = level===undefined ? LEVEL_1 : level;
+
+ this.max_speed = this.level.max_speed,
+ this.max_frustration = 100,
+
+ this.maker_freq = this.level.maker_frequency, // how often does a Maker add a new car to the road
+ this.max_cars_per_street = this.level.max_cars_per_street,
+ this.car_types = this.level.cars, // library of car settings and assets
+ this.car_odds = this.level.car_odds, // the likelihood that a particular car will be added
+ 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();
+
+ this.initialize_streets();
+
+ this.initialize_barriers();
+
+ this.initialize_intersections();
+
+ this.initialize_bosses();
+
+ this.initialize_controls();
+
+ },
+
initialize_factory : function(){
Game.factory = new Factory();
- Game.factory.initialize(CARS, BOSSES);
+ Game.factory.initialize(Game.level.cars, Game.level.bosses);
},
initialize_streets : function(){
- Game.log("initializing streets", STREETS.length);
+ Game.log("initializing streets", Game.levels.streets.length);
- _.each( STREETS, function(street_data){
+ _.each( Game.levels.streets, function(street_data){
var street = new Street();
street.initialize( Game, street_data, Game.car_context );
@@ -800,11 +819,11 @@ Game = {
initialize_barriers : function(){
- Game.log("initializing barriers", BARRIERS.length);
+ Game.log("initializing barriers", Game.levels.barriers.length);
var self = this;
- _.each(BARRIERS, function(b){
+ _.each( Game.levels.barriers, function(b){
var t = b[0].match(/^([^\s]+)\_barrier[\d]$/i),
hash = { name : b[0],
top : b[1],
@@ -826,9 +845,9 @@ Game = {
initialize_intersections : function(){
- Game.log("initializing intersections", INTERSECTIONS.length);
+ Game.log("initializing intersections", Game.levels.intersections.length);
- _.each(INTERSECTIONS, function(intersection){
+ _.each( Game.levels.intersections, function(intersection){
Game.intersections.push({
name : intersection[0],
top : intersection[1],
@@ -845,7 +864,7 @@ Game = {
Game.log("initializing controls", $(".stoplight").length);
var self = this;
- self.stoplights = STOPLIGHTS;
+ self.stoplights = Game.levels.stoplights;
// prevent gray overlay when tapping in iOS?
$('body').live('touchstart', function(e){
@@ -905,6 +924,7 @@ Game = {
Game.high_score = $.jStorage.get(Game.high_score_key_full, 0);
Game.high_score_cont.text( Game.high_score );
}
+
},
store_high_score : function(new_score) {
@@ -969,10 +989,15 @@ Game = {
Game.main.show();
Game.exit_intro(function(){
+
+ Game.initialize_map();
+
Game.intro.hide();
Game.stop_sound_theme();
Game.pause_menus();
+
Game.start_countdown();
+
});
},
@@ -69,6 +69,7 @@ Help = {
_.delay(function(){
play.show();
credits.show();
+ pintsized.show();
leaders.show();
}, 2250);
@@ -194,15 +194,6 @@ var THOUGHTBUBBLES = [
'frustration_04'
];
-var FRUSTRATIONS = [
- // filename, width, height, offset top, offset left
- [ 'frustration_01.png', 40, 40, -25, -25 ],
- [ 'frustration_02.png', 40, 40, -25, -25 ],
- [ 'frustration_03.png', 40, 40, -25, -25 ],
- [ 'frustration_04.png', 40, 40, -25, -25 ]
-];
-
-
var CAR_ODDS = [
[ 'car', 20 ],
[ 'car3', 20 ],
@@ -230,35 +221,35 @@ var CAR_ODDS_LEVELS = [
[ 150, 1.0 ]
];
-var SOUNDS_DIR = "sounds/";
+var SOUNDS_DIR = "sounds/";
// all sounds and music
var SOUNDS = {
- horns_short_1 : ["horn1",2],
- horns_short_2 : ["horn2",2],
- horns_short_3 : ["horn3",2],
- horns_short_4 : ["horn4",2],
- horns_long_1 : ["horn_long1",2],
- horns_long_2 : ["horn_long2",2],
- horn_truck : ["horn_truck",1],
- countdown : ["countdown",1],
- theme : ["bg",1],
- explosion : ["explosion_short",1],
- frustration : ["frustration",1],
- arrived : ["kaching",8],
- arrived_2 : ["kaching2",2],
- arrived_3 : ["kaching3",1],
- ambulance : ["ambulance",3],
- hearse : ["hearse",1],
- police : ["police",3],
- firetruck : ["firetruck",3]
+ horns_short_1 : ["horn1",2],
+ horns_short_2 : ["horn2",2],
+ horns_short_3 : ["horn3",2],
+ horns_short_4 : ["horn4",2],
+ horns_long_1 : ["horn_long1",2],
+ horns_long_2 : ["horn_long2",2],
+ horn_truck : ["horn_truck",1],
+ countdown : ["countdown",1],
+ theme : ["bg",1],
+ explosion : ["explosion_short",1],
+ frustration : ["frustration",1],
+ arrived : ["kaching",8],
+ arrived_2 : ["kaching2",2],
+ arrived_3 : ["kaching3",1],
+ ambulance : ["ambulance",3],
+ hearse : ["hearse",1],
+ police : ["police",3],
+ firetruck : ["firetruck",3]
};
var SOUND_FORMATS = { web : "mp3", ios : "wav", pokki : "ogg" };
-var NEIGHBORHOOD = [
- "bg.jpg"
-];
+var NEIGHBORHOOD = [ "bg.jpg" ];
+
+var BUILDINGS = [ "buildings.png" ];
var COLLISION_MESSAGES = [
"Y U NO STOP THEM?",
@@ -392,7 +383,6 @@ var BOSSES = {
};
-
// var BOSS_SEQUENCE = [
// [ 'towtruck', 15 ],
// [ 'truck', 25 ],
@@ -433,9 +423,40 @@ var BOSS_SEQUENCE = [
[ 'convoy', 605 ]
];
+// TODO
var TUTORIAL = [
{ time : 1, score : 1, speed : 6, assets : CARS.car.assets[0], maker_id : 1 },
{ time : 3, score : 1, speed : 6, assets : CARS.car.assets[0], maker_id : 7 },
{ time : 5, score : 1, speed : 6, assets : CARS.car.assets[0], maker_id : 2 }
];
+
+// WIP: We're placing all the game variables into a Map object so we can easily
+// switch when we want to give people a different set of gameplay settings
+
+var LEVEL_1 = {
+ id : 'easy',
+ name : 'novice',
+ streets : STREETS,
+ cars : CARS,
+ barriers : BARRIERS,
+ bosses : BOSSES,
+ boss_sequence : BOSS_SEQUENCE,
+ intersections : INTERSECTIONS,
+ stoplights : STOPLIGHTS,
+ locked : false,
+ max_cars_per_street : MAX_CARS_PER_STREET,
+ max_speed : MAX_SPEED,
+ maker_frequency : MAKER_FREQUENCY,
+ icon : "map_level_1.png",
+ neighborhood : NEIGHBORHOOD,
+ buildings : BUILDINGS,
+ car_odds : CAR_ODDS,
+ car_odds_levels : CAR_ODDS_LEVELS
+};
+
+var LEVEL_2 = _.extend(LEVEL_1, {}, true);
+
+var LEVEL_3 = _.extend(LEVEL_1, {}, true);
+
+var LEVELS = [ LEVEL_1, LEVEL_2, LEVEL_3 ];
@@ -40,7 +40,9 @@ body {
#all.width1024 { width:1024px; min-width:800px; }
#all.height768 { height:768px; min-height:601px; }
#all.height600 { height:600px; min-height:500px; }
-
+#all.height600 #map .neighborhood, #all.height600 #map .buildings { height:600px; }
+#all.height600 #map .neighborhood { background-image:url(../images/bg600.jpg); }
+#all.height600 #map .buildings { background-image:url(../images/buildings600.png); }
h1, h2, p { color:#333; margin-bottom:0.5em;}
h1 { font-size:64px; font-family: 'Fugaz One', Helvetica, sans-serif; letter-spacing:-2px; text-shadow:0 3px 8px #333; }
@@ -277,8 +279,9 @@ div#messages { position:absolute; top:250px; left:0px; text-align:center; width:
.car.boss.hearse.horizontal { width:200px; height:20px; background:url(../images/hearse_l.png); }
.car.boss.hearse.horizontal.right { background:url(../images/hearse_r.png); }
-/******************/
-/******************/
+/**********************/
+/* END VEHICLE STYLES */
+/**********************/
.car_score { font-size:25px; position:absolute; z-index:20; opacity : 1; color:#ff0; }
@@ -305,7 +308,7 @@ div#messages { position:absolute; top:250px; left:0px; text-align:center; width:
#toggle_fullscreen { background:#000 url(../images/pokki_window_sprite.png); width:18px; height:18px; border-radius:6px; position:absolute; z-index:100;top:5px; right:5px; line-height:1; cursor:pointer; text-decoration:none; text-indent:-1000px; overflow:hidden; background-position:0px 0px; }
#toggle_fullscreen.cancel_fullscreen { background-position:-18px 0px; }
-#pintsized { width:250px; height:75px; background:url(../images/brewed_by_pintsized.png); position:absolute; bottom:-20px; left:30px; text-indent:-2000px; }
+#pintsized { width:250px; height:75px; background:url(../images/brewed_by_pintsized.png); position:absolute; bottom:-10px; left:30px; text-indent:-2000px; }
body.ios #toggle_fullscreen, body.pokki #toggle_fullscreen { display:none; }
body.pokki p a:hover {color:#fff;}

0 comments on commit a3e386d

Please sign in to comment.