--- a/assets/js/script.js +++ b/assets/js/script.js @@ -43,6 +43,21 @@ event.preventDefault(); app.state.input('end', 0, 0); }, false); + // FredyGames: mouse as well as touch, so the game also plays on a computer. + var held = false; + window.addEventListener('mousedown', function(event){ + if (event.button !== 0) return; + held = true; + app.state.input('start', event.pageX, event.pageY); + }, false); + window.addEventListener('mousemove', function(event){ + if (held) app.state.input('move', event.pageX, event.pageY); + }, false); + window.addEventListener('mouseup', function(event){ + if (!held) return; + held = false; + app.state.input('end', 0, 0); + }, false); }, loop: function(){ @@ -450,9 +465,9 @@ init: function(){ app.state = app.score; - app.score.highscore = localStorage.getItem('highscore') || 0; + app.score.highscore = localStorage.getItem('connect2:highscore') || 0; if (app.game.score > app.score.highscore){ - localStorage.setItem('highscore', app.game.score); + localStorage.setItem('connect2:highscore', app.game.score); app.score.highscore = app.game.score; } if (!app.score.initialised){