Demo cleanup/enhance
This commit is contained in:
parent
cc3fdf3723
commit
6bf172bf47
2 changed files with 100 additions and 57 deletions
35
css/demo.css
35
css/demo.css
|
|
@ -18,8 +18,35 @@ blockquote, q { quotes: "" ""; }
|
||||||
|
|
||||||
html {
|
html {
|
||||||
color: #333;
|
color: #333;
|
||||||
font: normal 30px/34px helvetica, arial, sans-serif;
|
font: normal 24px/28px helvetica, arial, sans-serif;
|
||||||
padding: 0px;
|
padding: 0px;
|
||||||
text-align: center;
|
background: #fff;
|
||||||
background: #f9f9f9;
|
overflow: hidden !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
body { overflow: hidden !important; padding: 20px; }
|
||||||
|
|
||||||
|
h1 { background-color: #42a2cc; color: #f9f9f9; font-size: 50px; padding: 10px; }
|
||||||
|
|
||||||
|
a, a:visited {
|
||||||
|
background-color: #42a2cc;
|
||||||
|
color: #f9f9f9;
|
||||||
|
padding: 3px 5px;
|
||||||
|
text-decoration: none;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:hover { background-color: #147ba8; }
|
||||||
|
|
||||||
|
p {
|
||||||
|
padding: 10px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* "Players". ;) */
|
||||||
|
.player { position: absolute; top: 740; width: 46px; height: 46px; border: 2px solid #010101; padding: 10px; }
|
||||||
|
.player span { background-color: #f9f9f9; padding: 5px; font-weight: bold; }
|
||||||
|
#player_1 { background-color: #ef1419; color: #ef1419; left: 500px; }
|
||||||
|
#player_2 { background-color: #13c32c; color: #13c32c; left: 580px; }
|
||||||
|
#player_3 { background-color: #e6d01a; color: #e6d01a; left: 660px; }
|
||||||
|
#player_4 { background-color: #af0bb1; color: #af0bb1; left: 740px; }
|
||||||
122
index.html
122
index.html
|
|
@ -14,9 +14,9 @@
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
This demo is really simple, and works best with two Wii remotes (Wiimotes). Hold either Wiimote #1 or #2 horizontal (sideways), and use
|
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 the box floating in the bottom right corner around. Wiimote #1 will turn the box red and fill it with a "1",
|
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.
|
||||||
and Wiimote #2 will turn the box green and fill it with a "2". Have fun!
|
Have fun!
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -29,69 +29,85 @@
|
||||||
- Ryan McGrath
|
- Ryan McGrath
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div id="x" style="border: 5px solid #010101; position: absolute; top: 300px; left: 300px; width: 100px; height: 100px; padding: 10px; color: #010101;">x</div>
|
<div id="player_1" class="player">1</div>
|
||||||
|
<div id="player_2" class="player">2</div>
|
||||||
|
<div id="player_3" class="player">3</div>
|
||||||
|
<div id="player_4" class="player">4</div>
|
||||||
|
|
||||||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
|
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
|
||||||
<script src="js/wii.js"></script>
|
<script src="js/wii.js"></script>
|
||||||
<script>
|
<script>
|
||||||
var wiimote = new Wii.Remote(1, {horizontal: true}),
|
var wiimote = new Wii.Remote(1, {horizontal: true}),
|
||||||
wiimote2 = new Wii.Remote(2, {horizontal: true}),
|
wiimote2 = new Wii.Remote(2, {horizontal: true}),
|
||||||
x = $("#x");
|
wiimote3 = new Wii.Remote(3, {horizontal: true}),
|
||||||
|
wiimote4 = new Wii.Remote(4, {horizontal: true}),
|
||||||
wiimote2.when('pressed_up', function() {
|
p1 = $('#player_1'),
|
||||||
x.html('2').css({
|
p2 = $('#player_2'),
|
||||||
'background-color': 'green',
|
p3 = $('#player_3'),
|
||||||
'top': parseInt(x[0].style.top) - 50
|
p4 = $('#player_4');
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
wiimote2.when('pressed_down', function() {
|
|
||||||
x.html('2').css({
|
|
||||||
'background-color': 'green',
|
|
||||||
'top': parseInt(x[0].style.top) + 50
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
wiimote2.when('pressed_right', function() {
|
|
||||||
x.html('2').css({
|
|
||||||
'background-color': 'green',
|
|
||||||
'left': parseInt(x[0].style.left) + 50
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
wiimote2.when('pressed_left', function() {
|
|
||||||
x.html('2').css({
|
|
||||||
'background-color': 'green',
|
|
||||||
'left': parseInt(x[0].style.left) - 50
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
wiimote.when('pressed_up', function() {
|
|
||||||
x.html('1').css({
|
|
||||||
'background-color': 'red',
|
|
||||||
'top': parseInt(x[0].style.top) - 50
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
wiimote.when('pressed_down', function() {
|
wiimote.when('pressed_down', function() {
|
||||||
x.html('1').css({
|
p1.css({'top': parseInt(x[0].style.top) + 50});
|
||||||
'background-color': 'red',
|
|
||||||
'top': parseInt(x[0].style.top) + 50
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
wiimote.when('pressed_right', function() {
|
wiimote.when('pressed_right', function() {
|
||||||
x.html('1').css({
|
p1.css({'left': parseInt(x[0].style.left) + 50});
|
||||||
'background-color': 'red',
|
});
|
||||||
'left': parseInt(x[0].style.left) + 50
|
|
||||||
});
|
wiimote.when('pressed_left', function() {
|
||||||
|
p1.css({'left': parseInt(x[0].style.left) - 50});
|
||||||
});
|
});
|
||||||
|
|
||||||
wiimote.when('pressed_left', function() {
|
wiimote.when('pressed_up', function() {
|
||||||
x.html('1').css({
|
p1.css({'top': parseInt(x[0].style.top) - 50});
|
||||||
'background-color': 'red',
|
});
|
||||||
'left': parseInt(x[0].style.left) - 50
|
|
||||||
});
|
wiimote2.when('pressed_down', function() {
|
||||||
|
p2.css({'top': parseInt(x[0].style.top) + 50});
|
||||||
|
});
|
||||||
|
|
||||||
|
wiimote2.when('pressed_right', function() {
|
||||||
|
p2.css({'left': parseInt(x[0].style.left) + 50});
|
||||||
|
});
|
||||||
|
|
||||||
|
wiimote2.when('pressed_left', function() {
|
||||||
|
p2.css({'left': parseInt(x[0].style.left) - 50});
|
||||||
|
});
|
||||||
|
|
||||||
|
wiimote2.when('pressed_up', function() {
|
||||||
|
p2.css({'top': parseInt(x[0].style.top) - 50});
|
||||||
|
});
|
||||||
|
|
||||||
|
wiimote3.when('pressed_down', function() {
|
||||||
|
p3.css({'top': parseInt(x[0].style.top) + 50});
|
||||||
|
});
|
||||||
|
|
||||||
|
wiimote3.when('pressed_right', function() {
|
||||||
|
p3.css({'left': parseInt(x[0].style.left) + 50});
|
||||||
|
});
|
||||||
|
|
||||||
|
wiimote3.when('pressed_left', function() {
|
||||||
|
p3.css({'left': parseInt(x[0].style.left) - 50});
|
||||||
|
});
|
||||||
|
|
||||||
|
wiimote3.when('pressed_up', function() {
|
||||||
|
p3.css({'top': parseInt(x[0].style.top) - 50});
|
||||||
|
});
|
||||||
|
|
||||||
|
wiimote4.when('pressed_down', function() {
|
||||||
|
p4.css({'top': parseInt(x[0].style.top) + 50});
|
||||||
|
});
|
||||||
|
|
||||||
|
wiimote4.when('pressed_right', function() {
|
||||||
|
p4.css({'left': parseInt(x[0].style.left) + 50});
|
||||||
|
});
|
||||||
|
|
||||||
|
wiimote4.when('pressed_left', function() {
|
||||||
|
p4.css({'left': parseInt(x[0].style.left) - 50});
|
||||||
|
});
|
||||||
|
|
||||||
|
wiimote4.when('pressed_up', function() {
|
||||||
|
p4.css({'top': parseInt(x[0].style.top) - 50});
|
||||||
});
|
});
|
||||||
|
|
||||||
Wii.listen();
|
Wii.listen();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue