Skip to content

Commit

Permalink
Merge pull request #312 from zstenger93/tournoment
Browse files Browse the repository at this point in the history
Added Basic Layout For Tournament
  • Loading branch information
zstenger93 authored Apr 14, 2024
2 parents 666202f + 2a96313 commit e97673c
Show file tree
Hide file tree
Showing 10 changed files with 1,361 additions and 52 deletions.
7 changes: 1 addition & 6 deletions frontend/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,7 @@ function App() {
path="tournament"
element={
<PageWrapper image={Background} redirectUri={REDIRECT_URI}>
<StartScreen
Game={Tournament}
backgroundImage={backgroundimage}
WelcomeButtonStyle={WelcomeButtonStyle}
BackButton={BackButton}
/>
<Tournament />
</PageWrapper>
}
/>
Expand Down
Binary file added frontend/src/images/tournament/baby.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/src/images/tournament/balanced.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/src/images/tournament/eliminate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/src/images/tournament/insane.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/src/images/tournament/player.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/src/images/tournament/pong.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 25 additions & 24 deletions frontend/src/pages/Games/Pong3D.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ function Pong3D() {
map: textureLoader.load(venus),
reflectivity: 1,
});
const [gameOver, setGameOver] = React.useState(false);
const [returnCounter, setBounceCounter] = useState(0);
const [gameOver] = React.useState(false);
const [returnCounter] = useState(0);

const asteroidGeometry = new THREE.SphereGeometry(1, 32, 32);
const asteroids = [];
Expand All @@ -44,7 +44,7 @@ function Pong3D() {
let leftPaddlePosition = 0;
let bounceCounter = 0;
let isCodeExecuted = false;
let lifes = 7;
var lifes = 7;

class Asteroid {
constructor(x, y, radius, currentWayPoint, scene) {
Expand Down Expand Up @@ -402,11 +402,11 @@ function Pong3D() {
if (leftPaddleBoundingBox.intersectsBox(ballBoundingBox)) {
// eslint-disable-next-line react-hooks/exhaustive-deps
if (!isCodeExecuted) {
// eslint-disable-next-line react-hooks/exhaustive-deps
// eslint-disable-next-line react-hooks/exhaustive-deps
bounceCounter = bounceCounter + 1;
// eslint-disable-next-line react-hooks/exhaustive-deps
// eslint-disable-next-line react-hooks/exhaustive-deps
ballSpeed += 0.02;
// eslint-disable-next-line react-hooks/exhaustive-deps
// eslint-disable-next-line react-hooks/exhaustive-deps
leftPaddleSpeedConst += 0.005;
bounceContext.clearRect(
0,
Expand All @@ -416,7 +416,7 @@ function Pong3D() {
);
bounceContext.fillText("BOUNCE COUNT: " + bounceCounter, 6, 24);
bounceMaterialTexture.needsUpdate = true;
// eslint-disable-next-line react-hooks/exhaustive-deps
// eslint-disable-next-line react-hooks/exhaustive-deps
isCodeExecuted = true;
} else {
isCodeExecuted = false;
Expand All @@ -435,22 +435,23 @@ function Pong3D() {
ball.position.x = 0;
ball.position.y = 0;
// eslint-disable-next-line react-hooks/exhaustive-deps
lifes = orbits.length - 1;
if (orbits.length === 0) {
if (orbits.length === 0) {
setGameOver(true);
setBounceCounter(bounceCounter);
ballSpeed = 0;
}
}
if (orbits.length > 0) {
scene.remove(orbits[orbits.length - 1]);
orbits.pop();
ball.material = planetMaterials[lifes];
ball.material.needsUpdate = true;
ballSpeed = 0.3;
leftPaddleSpeedConst = 0.5;
}
// lifes = orbits.length - 1;
// if (orbits.length === 0) {
// // setGameOver(true);
// setBounceCounter(bounceCounter);
// ballSpeed = 0;
// }
// if (orbits.length > 0) {
// scene.remove(orbits[orbits.length - 1]);
// orbits.pop();

ball.material =
planetMaterials[Math.floor(Math.random() * (lifes + 1))];
ball.material.needsUpdate = true;
// ballSpeed = 0.3;
// leftPaddleSpeedConst = 0.5;
// }

pointLight.intensity += 50;
pointLight.distance += 10;
} else ballDirection.y *= -1;
Expand Down Expand Up @@ -531,7 +532,7 @@ function Pong3D() {
if (isSKeyPressed) {
leftPaddlePosition -= leftPaddleSpeedConst;
}
// eslint-disable-next-line react-hooks/exhaustive-deps
// eslint-disable-next-line react-hooks/exhaustive-deps
leftPaddlePosition = Math.max(
-wallOffsetY + paddleHeight / 2 + wallThickness / 2,
Math.min(
Expand Down
45 changes: 31 additions & 14 deletions frontend/src/pages/Games/PongAi.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ const GameCanvas = (aiDifficulty) => {
if (canvasRef.current && event.touches.length > 0) {
const rect = canvasRef.current.getBoundingClientRect();
const touchY = event.touches[0].clientY - rect.top - window.scrollY;
// eslint-disable-next-line react-hooks/exhaustive-deps
// eslint-disable-next-line react-hooks/exhaustive-deps
leftPaddleY = touchY - paddleHeight / 2;
leftPaddleY = Math.max(
0,
Expand Down Expand Up @@ -395,19 +395,36 @@ const PongAi = () => {
<button onClick={handleButtonClick} className={WelcomeButtonStyle}>
{t("Start Game")}
</button>
<div className="relative">Level: {difficulty}</div>
<div style={{ display: "flex", justifyContent: "center" }}>
<input
type="range"
min="0"
max="3"
value={difficulty}
onChange={(e) => setGameDifficulty(parseInt(e.target.value))}
style={{
width: "150px",
height: "25px",
}}
/>
<div
style={{
textAlign: "center",
marginBottom: "20px",
alignItems: "center",
justifyContent: "center",
marginLeft: "-16px",
}}
>
<div style={{ fontWeight: "bold", marginBottom: "10px" }}>
Level: {difficulty}
</div>
<div style={{ display: "flex" }}>
<input
type="range"
min="0"
max="3"
value={difficulty}
onChange={(e) => setGameDifficulty(parseInt(e.target.value))}
style={{
fontSize: "30px",
width: "200px",
height: "25px",
border: "none",
borderRadius: "5px",
outline: "none",
backgroundColor: "#444",
}}
/>
</div>
</div>
</div>
<BackButton navigate={navigate} t={t} />
Expand Down
Loading

0 comments on commit e97673c

Please sign in to comment.