Oops. Left debug logging in.
authordsc <david.schoonover@gmail.com>
Sun, 2 Jan 2011 01:14:48 +0000 (17:14 -0800)
committerdsc <david.schoonover@gmail.com>
Sun, 2 Jan 2011 01:14:48 +0000 (17:14 -0800)
src/Y/core.cjs
src/tanks/index.js
src/tanks/map/level.cjs
src/tanks/thing/thing.cjs
src/tanks/ui/main.cjs
src/tanks/util/utils.cjs

index 1c237cd..706755e 100644 (file)
@@ -181,6 +181,7 @@ function descriptors(A, B){
     if (arguments.length < 2)
         return reduce(A, _getDescriptors, {});
     
+    // FIXME: This is busted
     var desc = slice.call(arguments,1).reduce(_copyDescriptors, {});
     Object.defineProperties(A, desc);
     return A;
index 455172d..f2abafe 100644 (file)
@@ -13,7 +13,7 @@ tanks = {
     'ui'     : require('tanks/ui'),
     'Game'   : require('tanks/game').Game,
     
-    'currentGame' : null,
+    'game' : null,
     
 };
 
index 2877b92..d45bde0 100644 (file)
@@ -45,36 +45,36 @@ Rect.subclass('Level', {
         game.player = game.addThing(new PlayerTank(1), 3,9);
         // game.addThing(new Tank(1).colors('#4596FF', '#182B53', '#F25522'), 3,9);
         
-        // E = 
-        // game.addThing(new Tank(2), 0,7);
-        // game.addThing(new Tank(2), 1,0);
-        // game.addThing(new Tank(2), 8,1);
+        E = 
+        game.addThing(new Tank(2), 0,7);
+        game.addThing(new Tank(2), 1,0);
+        game.addThing(new Tank(2), 8,1);
         
-        // I = game.addThing(new Item(), 8,8);
+        I = game.addThing(new Item(), 8,8);
         
-        DATA = $('<pre id="data" style="position:absolute;top:0;left:0;width:200px;"></pre>').appendTo('body');
-        E = game.addThing(new Thing(2), 0,0);
-        var i = 0;
-        function testBulletSpeed(){
-            B = P.shoot(0,475);
-            var start = new Date().getTime()
-            ,   startClock = NOW
-            ,   startX = B.loc.x;
-            B.bounces = 1;
-            console.log(i+' B.movePerMs='+B.movePerMs+', move='+B.stats.move);
-            
-            B.addEventListener('destroy', function(evt){
-                var elapsed = (new Date().getTime() - start)/1000
-                ,   clock = (NOW - startClock)/1000
-                ,   distance = startX - B.loc.x ;
-                DATA.text(DATA.text()+elapsed.toFixed(3)+'\t'+clock.toFixed(3)+'\t'+distance.toFixed(3)+'\t'+(distance/elapsed).toFixed(3)+'\n');
-                if (++i < 20) testBulletSpeed();
-            });
-        }
-        game.addEventListener('start', function(evt){
-            DATA.text('elapsed\tclock\tpx\tpx/s\n');
-            testBulletSpeed();
-        });
+        // DATA = $('<pre id="data" style="position:absolute;top:0;left:0;width:200px;"></pre>').appendTo('body');
+        // E = game.addThing(new Thing(2), 0,0);
+        // var i = 0;
+        // function testBulletSpeed(){
+        //     B = P.shoot(0,475);
+        //     var start = new Date().getTime()
+        //     ,   startClock = NOW
+        //     ,   startX = B.loc.x;
+        //     B.bounces = 1;
+        //     console.log(i+' B.movePerMs='+B.movePerMs+', move='+B.stats.move);
+        //     
+        //     B.addEventListener('destroy', function(evt){
+        //         var elapsed = (new Date().getTime() - start)/1000
+        //         ,   clock = (NOW - startClock)/1000
+        //         ,   distance = startX - B.loc.x ;
+        //         DATA.text(DATA.text()+elapsed.toFixed(3)+'\t'+clock.toFixed(3)+'\t'+distance.toFixed(3)+'\t'+(distance/elapsed).toFixed(3)+'\n');
+        //         if (++i < 20) testBulletSpeed();
+        //     });
+        // }
+        // game.addEventListener('start', function(evt){
+        //     DATA.text('elapsed\tclock\tpx\tpx/s\n');
+        //     testBulletSpeed();
+        // });
     },
     
     addWall : function addWall(x,y, w,h, isBoundary){
index b82b7d0..ad36be2 100644 (file)
@@ -93,11 +93,8 @@ exports['Thing'] = new evt.Class('Thing', {
     'attr' : op.attr.methodize(),
     
     get movePerMs(){
-        var stat = this.stats.move
-        ,   move = (typeof stat === "number" ? stat : stat.val);
-        var r = move*REF_SIZE/1000;
-        console.log(this+'.movePerMs = '+move+'*'+REF_SIZE+'/1000 = '+r);
-        return r;
+        var stat = this.stats.move;
+        return (typeof stat === "number" ? stat : stat.val)*REF_SIZE/1000;
     },
     
     
index dbdcb8a..23aa750 100644 (file)
@@ -11,6 +11,7 @@ var Y            = require('Y').Y
 ,   config       = require('tanks/config').config
 
 ,   updateTimer  = null
+,   LBT = null
 ;
 function stopProp(evt){ evt.stopPropagation(); }
 
@@ -86,12 +87,12 @@ function main(){
     // $('#overlay').hide();
 }
 
-function gameExists(){ return !!tanks.currentGame; }
+function gameExists(){ return !!tanks.game; }
 
 function setupGame(){
     if ( gameExists() ) teardownGame();
     
-    LBT = tanks.currentGame = new Game();
+    LBT = tanks.game = new Game();
     
     LBT.addEventListener('win',  gameover('You Win!', 'Play Again', ''));
     LBT.addEventListener('lose', gameover('You Lose :(', 'Try Again', ''));
@@ -153,7 +154,7 @@ function startGame(evt){
 }
 
 function pauseGame(evt){
-    // $('#overlay').toggle();
+    $('#overlay').toggle();
     $('#pause').toggle();
     toggleGame();
 }
index 04c1494..86f52a1 100644 (file)
@@ -6,7 +6,7 @@ Object.dump = function(o){
 };
 
 function dumpPathmap(){
-    var pm = LBT.pathmap;
+    var pm = tanks.game.pathmap;
     console.warn(new Date(), pm);
     pm.collect(pm.x1,pm.y1, pm.x2,pm.y2, function(acc, v, r){
         console.log(r+'');