-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontroller.html
More file actions
34 lines (32 loc) · 1.05 KB
/
controller.html
File metadata and controls
34 lines (32 loc) · 1.05 KB
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
<!DOCTYPE html>
<html>
<head>
<title> Smartphone Controller </title>
<script src="/socket.io/socket.io.js"></script>
<script src="//davidshimjs.github.com/qrcodejs/qrcode.min.js"></script>
<script src="https://code.createjs.com/createjs-2015.11.26.min.js"></script>
</head>
<body>
<p> CONTROLLER </p>
<button onclick='sendLeftCommand();' class='load-image'> GO LEFT </button>
<button onclick='sendRightCommand();' class='load-image'> GO RIGHT </button>
<script>
var io = io.connect();
if (window.location.href.indexOf('?id=') > 0) {
var game_ID = window.location.href.split('?id=')[1];
io.emit('controller_connect', game_ID);
io.on('controller_connected', function(data) {
console.log("Connected successfully to the game, " + game_ID);
});
function sendRightCommand() {
io.emit("move_right", game_ID);
}
function sendLeftCommand() {
io.emit("move_left", game_ID);
}
} else {
console.log("No game ID sent")
}
</script>
</body>
</html>