var _gameStatus = "stop";
var _gameTime = 0;
var _gameTimerInverval;
var _gameStartTimestamp;
var _scene;
var _domGameTimer;

var Game = {};

Game.init = function(scene) {
	_scene = scene;
	_domGameTimer = document.getElementById("game-timer");
}

Game.start = function() {
	_gameTime = 0;
	_gameStartTimestamp = new Date().getTime();
	_gameStatus = "start";
	_gameTimerInverval = setInterval(function(){
		_gameTime = new Date().getTime() - _gameStartTimestamp;
		Game.updateTimer();
	}, 100);
}

Game.end = function() {
	_gameStatus = "stop";
	clearInterval(_gameTimerInverval);
}

Game.updateTimer = function(timestamp) {
	var _t = _gameTime;
	var html = "";

	var m = parseInt(_gameTime / (60 * 1000));
	_t -= (m * 60 * 1000);
	if(m < 10) {html += "0";}
	html += ""+m;
	html += ":";

	var s = parseInt(_t / 1000);
	_t -= (s * 1000);
	if(s < 10) {html += "0";}
	html += ""+s;
	html += ".";

	var ms = _t;
	html += ""+parseInt(ms/100);

	_domGameTimer.innerHTML = html;
}

module.exports = Game;