Skip to content

Commit

Permalink
remove hammer, small js changes
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielecirulli committed Mar 11, 2014
1 parent db82cf4 commit f251f5c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
1 change: 0 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ <h1 class="title">2048</h1>
</div>

<script src="js/animframe_polyfill.js"></script>
<script src="js/hammer.min.js"></script>
<script src="js/keyboard_input_manager.js"></script>
<script src="js/html_actuator.js"></script>
<script src="js/grid.js"></script>
Expand Down
13 changes: 7 additions & 6 deletions js/keyboard_input_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,10 @@ KeyboardInputManager.prototype.listen = function () {
var touchStartClientX, touchStartClientY;
var gameContainer = document.getElementsByClassName("game-container")[0];
gameContainer.addEventListener("touchstart", function(event) {
if (event.touches.length > 1) {
return;
}
if (event.touches.length > 1) return;

touchStartClientX = event.touches[0].clientX;
touchStartClientY = event.touches[0].clientY
touchStartClientY = event.touches[0].clientY;
event.preventDefault();
});
gameContainer.addEventListener("touchmove", function(event) {
Expand All @@ -76,11 +75,13 @@ KeyboardInputManager.prototype.listen = function () {
}
var dx = event.changedTouches[0].clientX - touchStartClientX;
var absDx = Math.abs(dx);

var dy = event.changedTouches[0].clientY - touchStartClientY;
var absDy = Math.abs(dy);

if (Math.max(absDx, absDy) > 10) {
self.emit("move", absDx > absDy ? (dx > 0 ? 1 : 3) :
(dy > 0 ? 2 : 0)); // (right : left) : (down : up)
// (right : left) : (down : up)
self.emit("move", absDx > absDy ? (dx > 0 ? 1 : 3) : (dy > 0 ? 2 : 0));
}
});
};
Expand Down

0 comments on commit f251f5c

Please sign in to comment.