Permalink
Browse files

Added some sounds!!

  • Loading branch information...
1 parent 7b47d3e commit 7c471ed58d489c3501386e0da341177745b6b146 @wailqill committed Nov 29, 2010
Showing with 9 additions and 7 deletions.
  1. +2 −4 index.html
  2. +7 −3 ludo.js
  3. BIN sound/in.mp3
  4. BIN sound/winning.mp3
View
@@ -10,11 +10,9 @@
</head>
<body>
<button id="dice">Roll</button>
+ <audio id="soundIn" src="sound/in.mp3"></audio>
+ <audio id="soundWinning" src="sound/winning.mp3"></audio>
<div id="board">
- <!-- <div role="piece" data-x="1" data-y="1" data-color="g"></div>
- <div role="piece" data-x="3" data-y="1" data-color="y"></div>
- <div role="piece" data-x="1" data-y="3" data-color="r"></div>
- <div role="piece" data-x="3" data-y="3" data-color="b"></div> -->
<div role="goal" data-x="7" data-y="7"></div>
</div>
<script type="text/javascript" src="board.js"></script>
View
10 ludo.js
@@ -21,7 +21,7 @@
function diceHandler() {
if (movesLeft > 0) return;
- movesLeft = Math.ceil(Math.random() * 6);
+ movesLeft = 62//Math.ceil(Math.random() * 6);
dice.innerText = movesLeft;
dice.setAttribute('data-rolled', movesLeft);
};
@@ -49,9 +49,9 @@
var tile = getItem('tile', x, y);
var nx, ny, state;
var rules = tile ? (tile.getAttribute("data-direction") || "").split('') : [];
+ var color = piece.getAttribute('data-color');
if (!tile || rules.length === 0) {
// Piece at home base.
- var color = piece.getAttribute('data-color');
var start = document.querySelector("#board div[role='tile'][data-start='" + color + "']");
nx = start.getAttribute('data-x');
ny = start.getAttribute('data-y');
@@ -70,7 +70,11 @@
break;
} else if (state === PieceMovability.GOAL) {
piece.parentNode.removeChild(piece);
- alert("IN!")
+ if (!document.querySelector("#board div[role='piece'][data-color='" + color + "']")) {
+ document.getElementById('soundWinning').play();
+ } else {
+ document.getElementById('soundIn').play();
+ }
break;
}
}
View
Binary file not shown.
View
Binary file not shown.

0 comments on commit 7c471ed

Please sign in to comment.