Skip to content

Commit 041882b

Browse files
author
Neil Fraser
committed
Add shake on loss in Repeat
1 parent b264c84 commit 041882b

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

favicon.ico

1.12 KB
Binary file not shown.

index.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
<title>Beaver Games</title>
55
<link rel="stylesheet" href="common.css">
66
<style>
7+
table {
8+
margin: 2em 0;
9+
}
710
td {
811
padding: 1em;
912
}
@@ -51,6 +54,7 @@ <h1>Beaver Games</h1>
5154
</td>
5255
</tr>
5356
</table>
54-
57+
<hr>
58+
All code is <a href="https://github.com/NeilFraser/beaver-games">open source</a>.
5559
</body>
5660
</html>

repeat/index.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,25 @@
7878
#difficulty {
7979
float: right;
8080
}
81+
82+
body.fail {
83+
animation: shake 0.82s cubic-bezier(.36,.07,.19,.97) both;
84+
transform: translate(0, 0);
85+
}
86+
@keyframes shake {
87+
10%, 90% {
88+
transform: translate(-1px, 0);
89+
}
90+
20%, 80% {
91+
transform: translate(2px, -2px);
92+
}
93+
30%, 50%, 70% {
94+
transform: translate(-4px, 0);
95+
}
96+
40%, 60% {
97+
transform: translate(4px, 2px);
98+
}
99+
}
81100
</style>
82101
<script src="index.js"></script>
83102
</head>

repeat/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ function initTimeline() {
8282

8383
// Show the start button and disable the controls.
8484
function showStart() {
85+
document.body.className = '';
8586
var startButton = document.getElementById('start');
8687
startButton.style.display = '';
8788
var table = document.getElementById('controls');
@@ -160,6 +161,7 @@ function startHuman() {
160161

161162
// Human pressed the wrong note. End game, show start button.
162163
function fail() {
164+
document.body.className = 'fail';
163165
document.getElementById('fail').play();
164166
mode = modes.START;
165167
setTimeout(showStart, 1000);

0 commit comments

Comments
 (0)