-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #219 from zstenger93/3dpong
Refactor game end screens and add score display
- Loading branch information
Showing
4 changed files
with
96 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,50 @@ | ||
import React, { useState } from 'react'; | ||
import React, { useState } from "react"; | ||
import { useTranslation } from "react-i18next"; | ||
import { useNavigate } from "react-router-dom"; | ||
|
||
const LoseScreen = ({ GameCanvas, backgroundImage, WelcomeButtonStyle, BackButton }) => { | ||
const [gameStarted, setGameStarted] = useState(false); | ||
const { t } = useTranslation(); | ||
const navigate = useNavigate(); | ||
const LoseScreen = ({ | ||
GameCanvas, | ||
backgroundImage, | ||
WelcomeButtonStyle, | ||
BackButton, | ||
}) => { | ||
const [gameStarted, setGameStarted] = useState(false); | ||
const { t } = useTranslation(); | ||
const navigate = useNavigate(); | ||
|
||
const handleButtonClick = () => { | ||
setGameStarted(true); | ||
}; | ||
const handleButtonClick = () => { | ||
setGameStarted(true); | ||
}; | ||
|
||
return ( | ||
<div className="flex justify-center items-center h-screen"> | ||
{gameStarted ? ( | ||
<GameCanvas /> | ||
) : ( | ||
<div className="relative"> | ||
<img | ||
src={backgroundImage} | ||
style={{ width: "80vw", height: "100%", objectFit: "cover" }} | ||
alt="Background" | ||
className="rounded-xl shadow-lg" | ||
/> | ||
<div | ||
className="absolute top-1/2 left-1/2 transform -translate-x-1/2 | ||
return ( | ||
<div className="flex justify-center items-center h-screen"> | ||
{gameStarted ? ( | ||
<GameCanvas /> | ||
) : ( | ||
<div className="relative"> | ||
<img | ||
src={backgroundImage} | ||
style={{ width: "80vw", height: "100%", objectFit: "cover" }} | ||
alt="Background" | ||
className="rounded-xl shadow-lg" | ||
/> | ||
<div | ||
className="absolute top-1/2 left-1/2 transform -translate-x-1/2 | ||
-translate-y-1/2 text-center font-bold font-nosifer" | ||
> | ||
<p>{t("YOU LOST!")}</p> | ||
<button | ||
onClick={handleButtonClick} | ||
className={`mt-10 ${WelcomeButtonStyle}`} | ||
> | ||
{t("Play Again")} | ||
</button> | ||
</div> | ||
<BackButton navigate={navigate} t={t} /> | ||
</div> | ||
)} | ||
> | ||
<p>{t("PLAYER 2 WON!")}</p> | ||
<button | ||
onClick={handleButtonClick} | ||
className={`mt-10 ${WelcomeButtonStyle}`} | ||
> | ||
{t("Play Again")} | ||
</button> | ||
</div> | ||
<BackButton navigate={navigate} t={t} /> | ||
</div> | ||
); | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default LoseScreen; | ||
export default LoseScreen; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,50 @@ | ||
import React, { useState } from 'react'; | ||
import React, { useState } from "react"; | ||
import { useTranslation } from "react-i18next"; | ||
import { useNavigate } from "react-router-dom"; | ||
|
||
const WinScreen = ({ | ||
GameCanvas, | ||
backgroundImage, | ||
WelcomeButtonStyle, | ||
BackButton, | ||
}) => { | ||
const [gameStarted, setGameStarted] = useState(false); | ||
const { t } = useTranslation(); | ||
const navigate = useNavigate(); | ||
|
||
const handleButtonClick = () => { | ||
setGameStarted(true); | ||
}; | ||
|
||
const WinScreen = ({GameCanvas, backgroundImage, WelcomeButtonStyle, BackButton }) => { | ||
const [gameStarted, setGameStarted] = useState(false); | ||
const { t } = useTranslation(); | ||
const navigate = useNavigate(); | ||
|
||
const handleButtonClick = () => { | ||
setGameStarted(true); | ||
}; | ||
|
||
return ( | ||
<div className="flex justify-center items-center h-screen"> | ||
{gameStarted ? ( | ||
<GameCanvas /> | ||
) : ( | ||
<div className="relative"> | ||
<img | ||
src={backgroundImage} | ||
style={{ width: "80vw", height: "100%", objectFit: "cover" }} | ||
alt="Background" | ||
className="rounded-xl shadow-lg" | ||
/> | ||
<div | ||
className="absolute top-1/2 left-1/2 transform -translate-x-1/2 | ||
return ( | ||
<div className="flex justify-center items-center h-screen"> | ||
{gameStarted ? ( | ||
<GameCanvas /> | ||
) : ( | ||
<div className="relative"> | ||
<img | ||
src={backgroundImage} | ||
style={{ width: "80vw", height: "100%", objectFit: "cover" }} | ||
alt="Background" | ||
className="rounded-xl shadow-lg" | ||
/> | ||
<div | ||
className="absolute top-1/2 left-1/2 transform -translate-x-1/2 | ||
-translate-y-1/2 text-center font-bold font-nosifer" | ||
> | ||
<p>{t("YOU WON!")}</p> | ||
<button | ||
onClick={handleButtonClick} | ||
className={`mt-10 ${WelcomeButtonStyle}`} | ||
> | ||
{t("Play Again")} | ||
</button> | ||
</div> | ||
<BackButton navigate={navigate} t={t} /> | ||
</div> | ||
)} | ||
> | ||
<p>{t("PLAYER 1 WON!")}</p> | ||
<button | ||
onClick={handleButtonClick} | ||
className={`mt-10 ${WelcomeButtonStyle}`} | ||
> | ||
{t("Play Again")} | ||
</button> | ||
</div> | ||
<BackButton navigate={navigate} t={t} /> | ||
</div> | ||
); | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default WinScreen; | ||
export default WinScreen; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters