2011-02-12 00:35:54 +00:00
|
|
|
var GameController = function(inputController, displayController) {
|
2011-02-12 01:43:29 +00:00
|
|
|
var that = {};
|
|
|
|
that._loopRunning = false;
|
|
|
|
that._loop = null;
|
|
|
|
that._inputController = inputController;
|
|
|
|
that._displayController = displayController;
|
|
|
|
|
|
|
|
that.start = function() {
|
|
|
|
that._loopRunning = true;
|
|
|
|
that._loop = setInterval(that.loop, 30);
|
2011-02-12 00:35:54 +00:00
|
|
|
};
|
|
|
|
|
2011-02-12 01:43:29 +00:00
|
|
|
that.stop = function() {
|
|
|
|
that._loopRunning = false;
|
2011-02-12 00:35:54 +00:00
|
|
|
};
|
|
|
|
|
2011-02-12 01:43:29 +00:00
|
|
|
that.loop = function() {
|
|
|
|
that._inputController.observe();
|
2011-02-12 00:35:54 +00:00
|
|
|
// add other stuff here
|
|
|
|
|
2011-02-12 01:43:29 +00:00
|
|
|
that._displayController.draw();
|
2011-02-12 00:35:54 +00:00
|
|
|
};
|
2011-02-12 01:43:29 +00:00
|
|
|
|
|
|
|
return that;
|
2011-02-12 00:35:54 +00:00
|
|
|
};
|