made 'worlds' a local variable inside init, instead of global

This commit is contained in:
Richard Harrington 2013-09-03 20:28:08 -04:00
parent 1d9f712980
commit fa7e132b71

View File

@ -8,10 +8,6 @@
var SHELL_RADIUS = 2; var SHELL_RADIUS = 2;
var SHELL_COLOR = "#ffffff"; var SHELL_COLOR = "#ffffff";
// The only real global variable.
// TODO: Get rid of this.
var worlds;
var Geom = (function() { var Geom = (function() {
var degreesToRadians = function(angle) { var degreesToRadians = function(angle) {
return angle * Math.PI / 180; return angle * Math.PI / 180;
@ -244,7 +240,7 @@
})(Date.now()); })(Date.now());
} }
function startGame(gameInfo) { function startGame(worlds, gameInfo) {
var debugAnimationCounter = 0; var debugAnimationCounter = 0;
var debugSimulationCounter = 0; var debugSimulationCounter = 0;
var debugSecondsCounter = 0; var debugSecondsCounter = 0;
@ -293,8 +289,9 @@
} }
function init() { function init() {
// Text and keyboard event listeners for sending program names to var worlds;
// server
// Text and keyboard event listeners for sending program names to server
$('#programsInput').bind('keydown', function(event) { $('#programsInput').bind('keydown', function(event) {
if (event.which === 13) { if (event.which === 13) {
@ -314,7 +311,7 @@
setTimeout(function() { setTimeout(function() {
$('#canvas').css({opacity: 1}); $('#canvas').css({opacity: 1});
setTimeout(function() { setTimeout(function() {
startGame(gameInfo); startGame(worlds, gameInfo);
}, 500); }, 500);
}, 500); }, 500);
$(this).blur(); $(this).blur();