fix reset button
This commit is contained in:
parent
9556472df5
commit
6ecd78dc62
@ -24,7 +24,7 @@ Let it be still, and it will gradually become clear._
|
|||||||
Your browser doesn't support canvas. At this point in the world that's actually
|
Your browser doesn't support canvas. At this point in the world that's actually
|
||||||
pretty cool, well done!
|
pretty cool, well done!
|
||||||
</canvas>
|
</canvas>
|
||||||
<button onclick="resetGame()">(R)eset</button>
|
<button onclick="reset()">(R)eset</button>
|
||||||
<span style="font-size: 2rem; margin-left: 1rem;">Score:
|
<span style="font-size: 2rem; margin-left: 1rem;">Score:
|
||||||
<span style="font-weight: bold" id="score">0</span>
|
<span style="font-weight: bold" id="score">0</span>
|
||||||
</span>
|
</span>
|
||||||
@ -396,10 +396,12 @@ const requestAnimationFrame =
|
|||||||
|
|
||||||
let game = new Game(canvas, document.getElementById("score"));
|
let game = new Game(canvas, document.getElementById("score"));
|
||||||
|
|
||||||
function nextFrame() {
|
function reset() {
|
||||||
if (game.shouldReset()) {
|
|
||||||
game = new Game(canvas, document.getElementById("score"));
|
game = new Game(canvas, document.getElementById("score"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function nextFrame() {
|
||||||
|
if (game.shouldReset()) reset();
|
||||||
|
|
||||||
game.update()
|
game.update()
|
||||||
game.draw()
|
game.draw()
|
||||||
|
Loading…
Reference in New Issue
Block a user