From 343f2a4afab5584fc4116b0aacae835cb4796c14 Mon Sep 17 00:00:00 2001 From: dinesh-58 <86787475+dinesh-58@users.noreply.github.com> Date: Thu, 23 Nov 2023 07:24:26 +0545 Subject: [PATCH] add modal text; declare constant variables outside comp f'n --- src/App.jsx | 26 ++++++++++++++++++++++---- src/components/Modal.jsx | 2 +- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index bf23b3b..dd067e7 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -3,6 +3,9 @@ import Board from './components/Board.jsx' import Modal from './components/Modal.jsx' import './App.css' +const [GAME_INITIAL, GAME_RUNNING, GAME_OVER] = [0,1,2] +const INTERVAL_TIME_MS = 1500; + export default function App() { /* NOTE: * Pad refers to the squares that change color @@ -27,7 +30,6 @@ export default function App() { const [botSequenceState, setBotSequenceState] = useState([]) const [score, setScore] = useState(0) const [lives, setLives] = useState(3) - const [GAME_INITIAL, GAME_RUNNING, GAME_OVER] = [0,1,2] const [gameState, setGameState] = useState(GAME_INITIAL) /* ref is used to store latest Board state. @@ -122,7 +124,7 @@ export default function App() { // generates new sequence every second. // setInterval returns id which is used to stop loop (using clearInteral) in generateBotSequence - const intervalId = setInterval(generateBotSequence, 1500); + const intervalId = setInterval(generateBotSequence, INTERVAL_TIME_MS); console.log("intervalId: " + intervalId) sequenceIntervalId.current = intervalId } @@ -135,6 +137,22 @@ export default function App() { ) }) + const tutorialElements = ( + <> +

How to Play?

+ + + ) + return (
@@ -149,8 +167,8 @@ export default function App() {
- {gameState == GAME_INITIAL && } - {gameState == GAME_OVER && } + {gameState == GAME_INITIAL && } + {gameState == GAME_OVER && }
) /* TODO: diff --git a/src/components/Modal.jsx b/src/components/Modal.jsx index c26a986..b6b5b86 100644 --- a/src/components/Modal.jsx +++ b/src/components/Modal.jsx @@ -4,7 +4,7 @@ export default function Modal(props) {
{props.description}
- +