forked from npike/Pong
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoutput.html
34 lines (31 loc) · 1015 Bytes
/
output.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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>PONG Output</title>
<link rel="stylesheet" href="main.css">
</head>
<body>
<div class="paddle" id="player1"></div>
<div class="paddle" id="player2"></div>
<canvas>Your browser needs to support canvas to play Color Dots on the web!</canvas>
<script src="game.js"></script>
<script src="/socket.io/socket.io.js"></script>
<script>
var player1 = document.getElementById('player1');
var socket = io.connect('http://ec2-54-227-130-117.compute-1.amazonaws.com/');
// var socket = io.connect('http://localhost');
socket.on('news', function (data) {
console.log(data);
// socket.emit('my other event', { my: 'data' });
});
socket.on('updatePlayer', function (data) {
console.log(data);
var player = document.getElementById(data.player);
var docHeight = document.body.offsetHeight;
player.style.top = data.y* docHeight+"px";
// socket.emit('my other event', { my: 'data' });
});
</script>
</body>
</html>