From 8ba604cf771bf1348b858a7e6305d7ab7f2c14a6 Mon Sep 17 00:00:00 2001 From: agrogers Date: Mon, 7 Sep 2020 16:46:24 +1000 Subject: [PATCH 1/5] Added function explode all letters on game over and 'start again' --- typer.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/typer.js b/typer.js index f618ed9..c09ea2b 100644 --- a/typer.js +++ b/typer.js @@ -64,11 +64,16 @@ function removeLetters (frames) { for (const l of letters) { if (isIntersectingRectangleWithRectangle(l, letter.size, letter.size, center, center.radius, center.radius)) { if (--lives === 0) { - window.alert('GAME OVER!'); - window.location.reload(false); + ExplodeAllLetters(); + setTimeout(function() { + window.alert('GAME OVER!'); + window.location.reload(false); + }, 1500) } else if (lives > 0) { - window.alert('START AGAIN!'); - letters = []; + ExplodeAllLetters(); + setTimeout(function() { + window.alert('START AGAIN!'); + }, 1500) } break; } else { @@ -78,6 +83,15 @@ function removeLetters (frames) { } } +function ExplodeAllLetters() { + for (let i = letters.length - 1; i >= 0; i--) { + const l = letters[i]; + letters.splice(i, 1); + createParticles(l.x, l.y); + } + letters = []; +} + function type (i, l) { letters.splice(i, 1); score++; From ee03e509a0845cac0a9b075ce4be7b7fa7bfefc0 Mon Sep 17 00:00:00 2001 From: agrogers Date: Mon, 7 Sep 2020 16:53:31 +1000 Subject: [PATCH 2/5] Removed the 'Sttart Again' alert dialog. --- typer.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/typer.js b/typer.js index c09ea2b..f79ee3a 100644 --- a/typer.js +++ b/typer.js @@ -71,9 +71,6 @@ function removeLetters (frames) { }, 1500) } else if (lives > 0) { ExplodeAllLetters(); - setTimeout(function() { - window.alert('START AGAIN!'); - }, 1500) } break; } else { From ac5811c2dd4e46d1003c3cb5ff2697d71a962512 Mon Sep 17 00:00:00 2001 From: agrogers Date: Mon, 7 Sep 2020 17:13:01 +1000 Subject: [PATCH 3/5] Changes to insensitive. Game starts on insensitive letters. Also, if set to insensitive, it will only show lower case letters. Not really what was intended but it was a bit confusing to show upper and lower case letters but to not have to use the shift key to type them. --- typer.html | 2 +- typer.js | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/typer.html b/typer.html index dac9b71..0ff6288 100644 --- a/typer.html +++ b/typer.html @@ -22,7 +22,7 @@ - + Your browser doesn't support HTML5. diff --git a/typer.js b/typer.js index f79ee3a..0c3b520 100644 --- a/typer.js +++ b/typer.js @@ -1,7 +1,7 @@ /* global canvas ctx animation:writable gameLoop label loop paintCircle isIntersectingRectangleWithRectangle generateRandomNumber generateRandomInteger paintParticles createParticles processParticles */ let score = 0; let lives = 10; -let caseSensitive = true; +let caseSensitive = false; const center = { x: canvas.width / 2, @@ -50,10 +50,15 @@ function createLetters () { const dY = center.y - y; const norm = Math.sqrt(dX ** 2 + dY ** 2); const speed = generateRandomNumber(letter.lowestSpeed, letter.highestSpeed); + if (caseSensitive) { + newCode = Math.random() < 0.5 ? generateRandomInteger(25) + 65 : generateRandomInteger(25) + 97; + } else { + newCode = generateRandomInteger(25) + 97; + } letters.push({ x, y, - code: Math.random() < 0.5 ? generateRandomInteger(25) + 65 : generateRandomInteger(25) + 97, + code: newCode, speedX: dX / norm * speed, speedY: dY / norm * speed }); From 12e95fafc0f09a64f73502bd1ffabf1b0bb10d0b Mon Sep 17 00:00:00 2001 From: agrogers Date: Mon, 7 Sep 2020 19:12:17 +1000 Subject: [PATCH 4/5] . --- typer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typer.js b/typer.js index 0c3b520..eba7f30 100644 --- a/typer.js +++ b/typer.js @@ -1,6 +1,6 @@ /* global canvas ctx animation:writable gameLoop label loop paintCircle isIntersectingRectangleWithRectangle generateRandomNumber generateRandomInteger paintParticles createParticles processParticles */ let score = 0; -let lives = 10; +let lives = 5; let caseSensitive = false; const center = { From 5f50f274cf80f3d205e4d5629c4b104451c4c1d8 Mon Sep 17 00:00:00 2001 From: agrogers Date: Mon, 7 Sep 2020 19:14:07 +1000 Subject: [PATCH 5/5] Undo accidental change --- typer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typer.js b/typer.js index eba7f30..0c3b520 100644 --- a/typer.js +++ b/typer.js @@ -1,6 +1,6 @@ /* global canvas ctx animation:writable gameLoop label loop paintCircle isIntersectingRectangleWithRectangle generateRandomNumber generateRandomInteger paintParticles createParticles processParticles */ let score = 0; -let lives = 5; +let lives = 10; let caseSensitive = false; const center = {