forked from l-brett/virtual-stick
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.html
60 lines (55 loc) · 1.78 KB
/
example.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<html>
<head>
<title>Controller Test</title>
<meta name="viewport" content="width=device-width,height=device-height, initial-scale=1">
<style>
html, body {
margin: 0;
padding: 0;
overflow: none;
}
#container {
width:100vw;
height:100vh;
background:black;
color:grey;
text-align: center;
padding:1.2em 0;
}
</style>
<body style="overscroll-behavior-y: none;">
<div id="container">
<h1>Touch here</h1>
<p>There are two controllers, tap the left and right halves of the screen to see</p>
<p>Check the console for output for the left controller</p>
</div>
</body>
<script type="module">
import controller from './src/VirtualStick.js';
let leftControl = new controller({
container:document.getElementById('container'),
'track-stroke-color':'#0000FF',
'button-stroke-color':'#0000FF',
'button-color':null,
'width':50
});
let rightControl = new controller({
container:document.getElementById('container'),
'track-stroke-color':'#FF0000',
'button-stroke-color':'#FF0000',
'button-color':null,
'width':50,
'left':50
});
function draw() {
leftControl.draw();
rightControl.draw();
let axis = leftControl.getAxis();
if(axis.x != 0 || axis.y != 0) {
console.log(axis);
}
requestAnimationFrame(draw);
}
requestAnimationFrame(draw);
</script>
</html>