Skip to content

Commit cf7a4a4

Browse files
committed
Adding GameState enum and barebones pre-game screen
1 parent f6e7bfc commit cf7a4a4

File tree

1 file changed

+19
-0
lines changed
  • workspaces/simon-game/src/app/components

1 file changed

+19
-0
lines changed

workspaces/simon-game/src/app/components/App.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,27 @@ import { Box } from "./Box.tsx";
44
import { playNote } from "../util/playNote.ts";
55
import { config } from "../constants.ts";
66

7+
type GameState = "pre-game" | "game-over" | "player-turn" | "cpu-turn";
8+
79
export function App() {
810
const [playerMoves, setPlayerMoves] = useState<readonly number[]>([]);
11+
const [gameState, setGameState] = useState<GameState>("pre-game");
12+
13+
if (gameState === "pre-game") {
14+
return (
15+
<div style={{ display: "flex", gap: 10 }}>
16+
<button
17+
onClick={() => {
18+
setGameState("cpu-turn");
19+
}}
20+
>
21+
Start Game
22+
</button>
23+
Simon Game
24+
</div>
25+
);
26+
}
27+
928
return (
1029
<>
1130
<div style={{ display: "flex", gap: 10 }}>

0 commit comments

Comments
 (0)