Skip to content

Commit

Permalink
UX: Replay when clicking "Start!" or "debug mode" on the popup
Browse files Browse the repository at this point in the history
This change is useful when the user wants to restart the game with different configuration because:

- He/She presses the start button by mistake before modifying the configuration

- He/She wants to slow down or speed up for the next game after game over
  • Loading branch information
igrep committed May 5, 2024
1 parent 8b68dbb commit 31f0c70
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/content.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { dragAndMoveBall, visualizeBlocks } from "~game/debug"
import { replay } from "~game/end/gameOver"
import { main } from "~game/main"
import { getBlocks } from "~game/object/blocks"
import {
Expand Down Expand Up @@ -43,6 +44,7 @@ chrome.runtime.onMessage.addListener(function(message) {

// Check and mark as started only when the message is "start" or "test".
if (started) {
replay(message.options)
return
}
started = true
Expand Down
2 changes: 1 addition & 1 deletion src/game/end/gameOver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function gameOver(blocks: Block[], options: StartOptions) {
gameOverMessage.appendChild(replayButton)
}

function replay(options: StartOptions) {
export function replay(options: StartOptions) {
chrome.runtime.onMessage.addListener((message) => {
if (isMessageReplayIsConfirmedOnBackgroundMessage(message)) {
location.reload()
Expand Down

0 comments on commit 31f0c70

Please sign in to comment.