From cb5ffe47c9ea05308b8ec8d71b12b41b77c0e2f5 Mon Sep 17 00:00:00 2001 From: Arian Glander Date: Sat, 12 Feb 2011 01:47:22 +0100 Subject: [PATCH 1/3] rename --- js/wyrian.js | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 js/wyrian.js diff --git a/js/wyrian.js b/js/wyrian.js deleted file mode 100644 index b79ea38..0000000 --- a/js/wyrian.js +++ /dev/null @@ -1,9 +0,0 @@ -var Wyrian = function() { - // do basic initializations - - var inputController = new InputController(), - displayController = new DisplayController(), - gameController = new GameController(inputController, displayController); - - gameController.start(); -}(); \ No newline at end of file From caac0638068ac1edece6ff19d7ba2f88abcd9ccf Mon Sep 17 00:00:00 2001 From: Arian Glander Date: Sat, 12 Feb 2011 01:48:30 +0100 Subject: [PATCH 2/3] rename --- js/DisplayController.js | 2 +- js/Wyrian.js | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 js/Wyrian.js diff --git a/js/DisplayController.js b/js/DisplayController.js index 7d10e59..38ea739 100644 --- a/js/DisplayController.js +++ b/js/DisplayController.js @@ -2,6 +2,6 @@ var DisplayController = function() { this.draw = function() { - + }; }; \ No newline at end of file diff --git a/js/Wyrian.js b/js/Wyrian.js new file mode 100644 index 0000000..9089c90 --- /dev/null +++ b/js/Wyrian.js @@ -0,0 +1,9 @@ +var Wyrian = function() { + // do basic initializations + + var inputController = new InputController(), + displayController = new DisplayController(), + gameController = new GameController(inputController, displayController); + + gameController.start(); +}(); \ No newline at end of file From 3818496faaa2d55856c2ae1c63f9c355b5fb717d Mon Sep 17 00:00:00 2001 From: Arian Glander Date: Sat, 12 Feb 2011 02:43:29 +0100 Subject: [PATCH 3/3] 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