From 3818496faaa2d55856c2ae1c63f9c355b5fb717d Mon Sep 17 00:00:00 2001 From: Arian Glander Date: Sat, 12 Feb 2011 02:43:29 +0100 Subject: [PATCH] using that instead of this -> fixing scope problems --- js/DisplayController.js | 7 ++++--- js/GameController.js | 31 +++++++++++++++---------------- js/InputController.js | 7 ++++--- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/js/DisplayController.js b/js/DisplayController.js index 38ea739..609e92c 100644 --- a/js/DisplayController.js +++ b/js/DisplayController.js @@ -1,7 +1,8 @@ var DisplayController = function() { + var that = {}; - - this.draw = function() { - + that.draw = function() { + console.log("draw"); }; + return that; }; \ No newline at end of file diff --git a/js/GameController.js b/js/GameController.js index 0ad8a85..651e37d 100644 --- a/js/GameController.js +++ b/js/GameController.js @@ -1,26 +1,25 @@ var GameController = function(inputController, displayController) { + var that = {}; + that._loopRunning = false; + that._loop = null; + that._inputController = inputController; + that._displayController = displayController; - this._loopRunning = false; - this._loop = null; - this._inputController = inputController; - this._displayController = displayController; - - this.start = function() { - this._loopRunning = true; - this._loop = setInterval(this.loop, 30); + that.start = function() { + that._loopRunning = true; + that._loop = setInterval(that.loop, 30); }; - this.stop = function() { - this._loopRunning = false; + that.stop = function() { + that._loopRunning = false; }; - this.loop = function() { - this._inputController.observe(); - + that.loop = function() { + that._inputController.observe(); // add other stuff here - this._displayController.draw(); + that._displayController.draw(); }; - - + + return that; }; \ No newline at end of file diff --git a/js/InputController.js b/js/InputController.js index 913a85b..73aa104 100644 --- a/js/InputController.js +++ b/js/InputController.js @@ -1,7 +1,8 @@ var InputController = function() { - + var that = {}; - this.observe = function() { - + that.observe = function() { + console.log("input"); }; + return that; }; \ No newline at end of file