From 6924af0bc01a0c415b2c620ec40b72d9e5efc2bc Mon Sep 17 00:00:00 2001 From: dsc Date: Sun, 21 Nov 2010 21:42:03 -0800 Subject: [PATCH] Reset globals. --- css/lttl.css | 2 +- src/tanks/config.js | 7 +++---- src/tanks/game/game.js | 2 ++ src/tanks/globals.js | 9 +++++++++ src/tanks/main.js | 2 +- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/css/lttl.css b/css/lttl.css index 4a925ee..4960efe 100644 --- a/css/lttl.css +++ b/css/lttl.css @@ -23,7 +23,7 @@ table.grid td { /* outline:1px solid rgba(255,255,255,0.1); */ margin:0; padding:0; white-space:nowrap; overflow:hidden; } .gridShowCoords table.grid td:hover { color:rgba(255,255,255,0.1); } -#viewport { position:relative; width:500px; height:500px; margin:1em auto; /* overflow:hidden; */ } +#viewport { position:relative; width:500px; height:500px; margin:1em auto; cursor:crosshair; } #overlay { position:fixed; top:0; left:0; width:100%; height:100%; background-color:#000; opacity:0.5; z-index:100; } diff --git a/src/tanks/config.js b/src/tanks/config.js index d6e2652..39b1897 100644 --- a/src/tanks/config.js +++ b/src/tanks/config.js @@ -1,12 +1,11 @@ // -*- mode: JavaScript; tab-width: 4; indent-tabs-mode: nil; -*- tanks.config = { + debug : { + gridShowCoords : false + }, pathing : { overlayPathmap : false, overlayAIPaths : false, traceTrajectories : false - }, - debug : { - gridShowCoords : false - } }; \ No newline at end of file diff --git a/src/tanks/game/game.js b/src/tanks/game/game.js index 78e25d7..a8a9950 100644 --- a/src/tanks/game/game.js +++ b/src/tanks/game/game.js @@ -3,6 +3,8 @@ tanks.Game = new Y.Class('Game', { init : function init(viewport){ Y.bindAll(this); + tanks.resetGlobals(); + this.byId = {}; this.active = new Y.YArray(); this.units = new Y.YArray(); diff --git a/src/tanks/globals.js b/src/tanks/globals.js index 0f80622..1506b90 100644 --- a/src/tanks/globals.js +++ b/src/tanks/globals.js @@ -31,6 +31,15 @@ var undefined ; +tanks.resetGlobals = function resetGlobals(){ + NOW = new Date().getTime(); + ELAPSED = MS_PER_FRAME; + TICKS = 0; + + SECONDTH = ELAPSED / 1000; + SQUARETH = REF_SIZE * SECONDTH; +} + if (!window.console) { console = { log : Y.op.nop, diff --git a/src/tanks/main.js b/src/tanks/main.js index 1211d25..b76dbaa 100644 --- a/src/tanks/main.js +++ b/src/tanks/main.js @@ -6,7 +6,7 @@ this.main = main; // Main method is only executed once, so we'll setup things // that don't change between games. function main(){ - qkv = Y(window.location.search).fromKV(); + qkv = Y(window.location.search.slice(1)).fromKV().end(); /// Debug /// if (qkv.debug) $('#debug').toggle(); -- 1.7.0.4