forked from slobdell/joystick
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
65 lines (53 loc) · 1.92 KB
/
index.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
61
62
63
64
65
<html>
<head>
<script type="text/javascript" src="js/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="js/underscore-min.js"></script>
<script type="text/javascript" src="js/backbone-min.js"></script>
<script type="text/javascript" src="js/joystick_view.js"></script>
<script src="https://cdn.pubnub.com/pubnub-dev.js"></script>
</head>
<body>
<script type="text/html" id="joystick-view">
<canvas id="joystickCanvas" width="<%= squareSize %>" height="<%= squareSize %>" style="width: <%= squareSize %>px; height: <%= squareSize %>px;">
</canvas>
</script>
<div id="joystickContent">
</div>
<div>
x: <span id="xVal"></span><br/>
y: <span id="yVal"></span><br/>
</div>
<script type="text/javascript">
$(document).ready(function(){
var joystickView = new JoystickView(150, function(callbackView){
$("#joystickContent").append(callbackView.render().el);
setTimeout(function(){
callbackView.renderSprite();
}, 0);
});
joystickView.bind("verticalMove", function(y){
$("#yVal").html(y);
});
joystickView.bind("horizontalMove", function(x){
$("#xVal").html(x);
});
});
</script>
<script type="text/javascript">
var PUBNUB_demo = PUBNUB.init({
publish_key: 'pub-c-08f167b9-9f7c-4836-817a-dc1aec9c406b',
subscribe_key: 'sub-c-23afba32-6a44-11e5-a5be-02ee2ddab7fe'
});
// Subscribe to the demo_tutorial channel
PUBNUB_demo.subscribe({
channel: 'OmniBot',
message: function(m){console.log(m)}
});
// Publish a simple message to the demo_tutorial channel
PUBNUB_demo.publish({
channel: 'OmniBot',
message: {"Hello Omni"}
});
</script>
</body>
</html>