From 6ecd78dc625850683f8388ea9ae653838d71ae94 Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Mon, 12 Apr 2021 13:41:57 -0600 Subject: fix reset button --- src/_posts/2021-04-11-ripple-v2.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/_posts/2021-04-11-ripple-v2.md') diff --git a/src/_posts/2021-04-11-ripple-v2.md b/src/_posts/2021-04-11-ripple-v2.md index 4f628a6..cbde032 100644 --- a/src/_posts/2021-04-11-ripple-v2.md +++ b/src/_posts/2021-04-11-ripple-v2.md @@ -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 pretty cool, well done! - + Score: 0 @@ -396,10 +396,12 @@ const requestAnimationFrame = let game = new Game(canvas, document.getElementById("score")); +function reset() { + game = new Game(canvas, document.getElementById("score")); +} + function nextFrame() { - if (game.shouldReset()) { - game = new Game(canvas, document.getElementById("score")); - } + if (game.shouldReset()) reset(); game.update() game.draw() -- cgit v1.2.3