-
Notifications
You must be signed in to change notification settings - Fork 13
/
index.html
108 lines (88 loc) · 3.48 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Wii.js Demo</title>
<link rel="stylesheet" type="text/css" media="screen" href="css/demo.css">
</head>
<body>
<h1>Wii.js Demo</h1>
<p>
This is a demo page meant to show how easy it is to interact with the Nintendo Wii remotes using Javascript. It's
powered by <a href="http://github.com/ryanmcgrath/wii-js/">wii-js</a>, a Javascript library that abstracts the differences
and pain points associated with using the Wii remotes.
</p>
<p>
This demo is really simple, and works best with all Wii remotes (Wiimotes). Hold a Wiimote horizontal (sideways), and use
the directional pad to move a box floating in the bottom right corner around. Wiimote #1 is red, #2 is green, #3 is yellow, #4 is purple.
Have fun!
</p>
<div id="player_1" class="player"><span>1</span></div>
<div id="player_2" class="player"><span>2</span></div>
<div id="player_3" class="player"><span>3</span></div>
<div id="player_4" class="player"><span>4</span></div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
<script src="js/wii.js"></script>
<script>
var wiimote = new Wii.Remote(1, {horizontal: true}),
wiimote2 = new Wii.Remote(2, {horizontal: true}),
wiimote3 = new Wii.Remote(3, {horizontal: true}),
wiimote4 = new Wii.Remote(4, {horizontal: true}),
p1 = $('#player_1'),
p2 = $('#player_2'),
p3 = $('#player_3'),
p4 = $('#player_4');
wiimote.when('pressed_down', function() {
Wii.util.debug({'message': 'You gone and done it now boy!'});
throw new Error('LOL');
p1.css({'top': p1.position().top + 50});
});
wiimote.when('pressed_right', function() {
p1.css({'left': p1.position().left + 50});
});
wiimote.when('pressed_left', function() {
p1.css({'left': p1.position().left - 50});
});
wiimote.when('pressed_up', function() {
p1.css({'top': p1.position().top - 50});
});
wiimote2.when('pressed_down', function() {
p2.css({'top': p2.position().top + 50});
});
wiimote2.when('pressed_right', function() {
p2.css({'left': p2.position().left + 50});
});
wiimote2.when('pressed_left', function() {
p2.css({'left': p2.position().left - 50});
});
wiimote2.when('pressed_up', function() {
p2.css({'top': p2.position().top - 50});
});
wiimote3.when('pressed_down', function() {
p3.css({'top': p3.position().top + 50});
});
wiimote3.when('pressed_right', function() {
p3.css({'left': p3.position().left + 50});
});
wiimote3.when('pressed_left', function() {
p3.css({'left': p3.position().left - 50});
});
wiimote3.when('pressed_up', function() {
p3.css({'top': p3.position().top - 50});
});
wiimote4.when('pressed_down', function() {
p4.css({'top': p4.position().top + 50});
});
wiimote4.when('pressed_right', function() {
p4.css({'left': p4.position().left + 50});
});
wiimote4.when('pressed_left', function() {
p4.css({'left': p4.position().left - 50});
});
wiimote4.when('pressed_up', function() {
p4.css({'top': p4.position().top - 50});
});
Wii.listen({'debug': true});
</script>
</body>
</html>