diff --git a/index.html b/index.html index dd8ca7d..49c49c9 100644 --- a/index.html +++ b/index.html @@ -36,8 +36,10 @@ Github + + \ No newline at end of file diff --git a/tetris.js b/tetris.js index 7b1aeb3..558eec8 100644 --- a/tetris.js +++ b/tetris.js @@ -308,7 +308,7 @@ document.addEventListener('keydown', event => { }); function startGame() { - arena = createMatrix(fieldSize.x, fieldSize.y) + arena = createMatrix(fieldSize.x, fieldSize.y); playerReset(); update(); updateScore(); diff --git a/touch-control.js b/touch-control.js new file mode 100644 index 0000000..f18645d --- /dev/null +++ b/touch-control.js @@ -0,0 +1,24 @@ +const hammertime = new Hammer(document.getElementById("tetris")); + +hammertime.on('swipeleft', () => { + keys.left.action(); +}); + +hammertime.on('swiperight', () => { + keys.right.action(); +}); + +hammertime.on('swipe', (e) => { + console.log(e.direction); + keys.down.action(); +}); + +hammertime.on('tap', (e) => { + if (e.tapCount >= 2) { + keys.rotateRight.action(); + } +}); + +hammertime.on('press', () => { + keys.down.action(); +}); \ No newline at end of file