-
Notifications
You must be signed in to change notification settings - Fork 1
/
weapon.html
40 lines (30 loc) · 861 Bytes
/
weapon.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<html>
<head>
<meta name="viewport" content="user-scalable=0">
</head>
<body>
orientation : <span id="orient"></span>
<script src="/socket.io/socket.io.js"></script>
<script>
var socket = io.connect('/weapon');
var xOrientation = null ;
var fireStart = null ;
window.addEventListener("deviceorientation", function(event) {
document.getElementById("orient").innerHTML = Math.round(event.beta) ;
xOrientation = Math.round(event.beta) ;
}, true);
window.onload = function() {
document.ontouchstart = function()
{
fireStart = new Date().getTime() ;
}
document.ontouchend = function(){
socket.emit('fire', {
orientation : xOrientation ,
power : (new Date().getTime() - fireStart)
});
}
}
</script>
</body>
</html>