Skip to content

Commit a315cef

Browse files
authored
Adding GameState enum and barebones pre-game screen (#500)
1 parent f6e7bfc commit a315cef

File tree

1 file changed

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

1 file changed

+24
-0
lines changed

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,32 @@ 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+
const [_correctMoves, _setCorrectMoves] = useState<readonly number[]>([
13+
0, 1, 2, 3,
14+
]);
15+
16+
console.log(_correctMoves, _setCorrectMoves);
17+
18+
if (gameState === "pre-game") {
19+
return (
20+
<div style={{ display: "flex", gap: 10 }}>
21+
<button
22+
onClick={() => {
23+
setGameState("cpu-turn");
24+
}}
25+
>
26+
Start Game
27+
</button>
28+
Simon Game
29+
</div>
30+
);
31+
}
32+
933
return (
1034
<>
1135
<div style={{ display: "flex", gap: 10 }}>

0 commit comments

Comments
 (0)