Skip to content

Commit 6f02770

Browse files
committed
added touch controls
1 parent ed83d4c commit 6f02770

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

game.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,19 @@ function intit() {
9494
fighter.x -= 30
9595
}
9696
}
97+
98+
function mouseclick(e) {
99+
// console.log(e)
100+
if (e.screenX > fighter.x) {
101+
fighter.x += 30
102+
}
103+
if (e.screenX < fighter.x) {
104+
fighter.x -= 30
105+
}
106+
107+
}
97108
document.addEventListener("keydown", keypressed)
109+
document.addEventListener("click", mouseclick)
98110
}
99111

100112

0 commit comments

Comments
 (0)