wii-js/index.html
2011-07-11 08:47:06 -04:00

108 lines
3.4 KiB
HTML

<!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('LOL');
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>