Skip to content

Commit 4422baa

Browse files
committed
Show a score when the player loses
1 parent 0d78f92 commit 4422baa

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

public/scripts.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,31 @@ var sound = new Howl({
120120

121121
var frame = 0;
122122

123+
var lose = lose_dialog_shown = false;
124+
123125
var animate = function () {
124126
frame++;
125127

126128
requestAnimationFrame( animate );
127129

130+
if (lose) {
131+
if (! lose_dialog_shown) {
132+
lose_dialog_shown = true;
133+
134+
var i_concat = '';
135+
136+
for (var i = 0; i < trails.length; i++) {
137+
i_concat = i_concat + 'I';
138+
}
139+
140+
alerted = true;
141+
142+
alert('YEAH BO' + i_concat + "\nScore: " + trails.length);
143+
}
144+
145+
return;
146+
}
147+
128148
oscillateCamera();
129149

130150
for (var i = 0; i < obstacles.length; i++) {
@@ -191,7 +211,7 @@ var animate = function () {
191211
if ( collisionResults.length > 0 && collisionResults[0].distance < directionVector.length() ) {
192212
sound.pause();
193213

194-
throw Error('game over!');
214+
lose = true;
195215
}
196216
}
197217

0 commit comments

Comments
 (0)