aboutsummaryrefslogtreecommitdiff
path: root/src/components/App.js
diff options
context:
space:
mode:
authorMikunoNaka <bokuwakanojogahoshii@yahoo.com>2021-07-23 17:57:49 +0530
committerMikunoNaka <bokuwakanojogahoshii@yahoo.com>2021-07-23 17:57:49 +0530
commitb204876cfd803fc115029ac6501c67657dcec19e (patch)
tree9a42571ab48d4290d2639187979724fe41d16d5a /src/components/App.js
parent63abebc72240de13aa015739e2a9952ae588e4ca (diff)
added menu to switch single/multiplayer
Diffstat (limited to 'src/components/App.js')
-rw-r--r--src/components/App.js27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/components/App.js b/src/components/App.js
index 353e464..f10b5eb 100644
--- a/src/components/App.js
+++ b/src/components/App.js
@@ -24,13 +24,15 @@ import Footer from './Footer';
import './style.css';
const App = () => {
+ const [gameStarted, setGameStarted] = useState(false);
+ const [multiplayer, setMultiplayer] = useState(false);
const [scoreX, setScoreX] = useState(0);
const [scoreO, setScoreO] = useState(0);
const [turn, setTurn] = useState(1);
const [showMessageBox, setShowMessageBox] = useState(false);
const [message, setMessage] = useState("");
- const mp = true;
- return (
+
+ return gameStarted ? (
<>
{showMessageBox &&
<MessageBox
@@ -45,7 +47,7 @@ const App = () => {
scoreO={scoreO}
/>
- {mp ? <MultiplayerGrid
+ {multiplayer ? <MultiplayerGrid
turn={turn}
setTurn={setTurn}
scoreX={scoreX}
@@ -66,6 +68,25 @@ const App = () => {
<Footer/>
</>
+ ) : (
+ <>
+ <div className={"GamemodeChooser"}>
+ <div className={"GamemodeButton"} onClick={() => {
+ setGameStarted(true);
+ setMultiplayer(false);
+ }}>
+ SINGLE PLAYER
+ </div>
+
+ <div className={"GamemodeButton"} onClick={() => {
+ setGameStarted(true);
+ setMultiplayer(true);
+ }}>
+ MULTIPLAYER
+ </div>
+ </div>
+ <Footer/>
+ </>
);
}