Skip to content

Commit 2aef870

Browse files
authored
Merge pull request #48 from Treevyy/feature/react-fe
Main Menu and Play Again Btns on Victory and Game Over pgs
2 parents 6ab192e + 2d22db9 commit 2aef870

File tree

3 files changed

+117
-5
lines changed

3 files changed

+117
-5
lines changed

client/src/components/screens/GameOver.tsx

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,28 @@
1+
import { useNavigate } from 'react-router-dom';
12
import "../../styles/codezilla.css";
23

34
const GameOverPage = ({
45
backgroundUrl = 'client/background/codezilla_bkgd.png',
56
avatarUrl = 'client/avatars/avatar4.png',
67
codezillaUrl = 'client/minions/codezilla2.png',
78
}) => {
9+
const navigate = useNavigate();
10+
11+
const handlePlayAgain = () => {
12+
// navigate to your game-start route
13+
navigate('/game');
14+
};
15+
16+
const handleMainMenu = () => {
17+
// navigate back to your main menu/home route
18+
navigate('/');
19+
};
20+
821
return (
922
<div
1023
className="game-over-page"
1124
style={{ backgroundImage: `url(${backgroundUrl})` }}
1225
>
13-
1426
<div className="game-over-container">
1527
<h1 className="game-over-title">Game Over!</h1>
1628

@@ -34,9 +46,25 @@ const GameOverPage = ({
3446
<p className="game-over-cta">
3547
Try again to become a code master
3648
</p>
49+
50+
<div className="game-over-actions">
51+
<button
52+
className="btn play-again-btn"
53+
onClick={handlePlayAgain}
54+
>
55+
Play Again!
56+
</button>
57+
58+
<button
59+
className="btn main-menu-btn"
60+
onClick={handleMainMenu}
61+
>
62+
Main Menu
63+
</button>
64+
</div>
3765
</div>
3866
</div>
3967
);
4068
};
4169

42-
export default GameOverPage;
70+
export default GameOverPage;

client/src/components/screens/Victory.tsx

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
1+
import { useNavigate } from 'react-router-dom';
12
import "../../styles/codezilla.css";
23

34
export default function VictoryPage({
45
backgroundUrl = 'client/background/codezilla_bkgd.png',
56
avatarUrl = 'client/avatars/avatar4.png',
67
confettiUrl = 'client/background/confetti_image.jpg',
78
}) {
9+
const navigate = useNavigate();
10+
11+
const handlePlayAgain = () => {
12+
navigate('/game');
13+
};
14+
15+
const handleMainMenu = () => {
16+
navigate('/');
17+
};
18+
819
return (
920
<div
1021
className="victory-page"
1122
style={{ backgroundImage: `url(${backgroundUrl})` }}
1223
>
13-
1424
<div className="victory-container">
1525
{/* Confetti overlay */}
1626
<div
@@ -31,10 +41,24 @@ export default function VictoryPage({
3141
</h2>
3242

3343
<p className="victory-cta">
34-
you are a coding master!
44+
You are a coding master!
3545
</p>
46+
47+
<div className="victory-actions">
48+
<button
49+
className="btn play-again-btn"
50+
onClick={handlePlayAgain}
51+
>
52+
Play Again!
53+
</button>
54+
<button
55+
className="btn main-menu-btn"
56+
onClick={handleMainMenu}
57+
>
58+
Main Menu
59+
</button>
60+
</div>
3661
</div>
3762
</div>
3863
);
3964
}
40-

client/src/styles/codezilla.css

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,36 @@ body,
168168
font-size: 1.25rem;
169169
margin: 0;
170170
}
171+
172+
.game-over-actions {
173+
margin-top: 1.5rem;
174+
display: flex;
175+
gap: 1rem;
176+
justify-content: center;
177+
}
178+
179+
.game-over-actions .btn {
180+
padding: 0.75rem 1.5rem;
181+
font-size: 1rem;
182+
border: none;
183+
border-radius: 0.5rem;
184+
cursor: pointer;
185+
transition: transform 0.1s ease;
186+
}
187+
188+
.play-again-btn:hover {
189+
transform: scale(1.05);
190+
}
191+
192+
.main-menu-btn {
193+
background-color: #555;
194+
color: #fff;
195+
}
196+
197+
.main-menu-btn:hover {
198+
background-color: #333;
199+
}
200+
171201
/* Victory Page Styling */
172202
/* Full-screen rainy night background */
173203
.victory-page {
@@ -249,6 +279,36 @@ body,
249279
z-index: 1;
250280
}
251281

282+
.victory-actions {
283+
margin-top: 1.5rem;
284+
display: flex;
285+
gap: 1rem;
286+
justify-content: center;
287+
}
288+
289+
.victory-actions .btn {
290+
padding: 0.75rem 1.5rem;
291+
font-size: 1rem;
292+
border: none;
293+
border-radius: 0.5rem;
294+
cursor: pointer;
295+
transition: transform 0.1s ease;
296+
}
297+
298+
.play-again-btn:hover,
299+
.main-menu-btn:hover {
300+
transform: scale(1.05);
301+
}
302+
303+
.main-menu-btn {
304+
background-color: #555;
305+
color: #fff;
306+
}
307+
308+
.main-menu-btn:hover {
309+
background-color: #333;
310+
}
311+
252312
/* GAME MAP */
253313
.game-map {
254314
position: relative;

0 commit comments

Comments
 (0)