diff --git a/frontend/src/components/OriginalPong.js b/frontend/src/components/OriginalPong.js index d9f366255..73628f831 100644 --- a/frontend/src/components/OriginalPong.js +++ b/frontend/src/components/OriginalPong.js @@ -1,8 +1,10 @@ import React, { useEffect, useRef, useState } from "react"; import backgroundImage from "../images/pongCover.png"; +import settings from "../images/settings.png"; const GameCanvas = () => { // Default Parameters + let resize = true; const defaultSpeedX = 300; const winScore = 2; const defaultSpeedY = 20; @@ -142,7 +144,8 @@ const GameCanvas = () => { const handleResize = () => { if (canvasRef.current) { const screenWidth = window.innerWidth; - const canvasWidth = 0.8 * screenWidth; + let canvasWidth = screenWidth; + if (resize === true) canvasWidth = 0.8 * screenWidth; const canvasHeight = (canvasWidth / 16) * 9; canvasRef.current.width = canvasWidth; canvasRef.current.height = canvasHeight; @@ -276,6 +279,12 @@ const GameCanvas = () => { }; }, [canvasRef]); + const handleButtonClick = () => { + resize = !resize; + handleResize(); + console.log("Something should have happened"); + }; + return (
{scoreLeftReact === winScore || scoreRightReact === winScore ? ( @@ -285,11 +294,23 @@ const GameCanvas = () => { ) ) : ( - + <> + + + )}
); diff --git a/frontend/src/components/PongAi.js b/frontend/src/components/PongAi.js index 3f09716a4..32d229097 100644 --- a/frontend/src/components/PongAi.js +++ b/frontend/src/components/PongAi.js @@ -1,9 +1,11 @@ import React, { useEffect, useRef, useState } from "react"; import backgroundImage from "../images/pongCover.png"; +import settings from "../images/settings.png"; const GameCanvas = () => { // Default Parameters const defaultSpeedX = 300; + let resize = true; const winScore = 2; const defaultSpeedY = 20; const [scoreLeftReact, setScoreLeft] = useState(0); @@ -142,7 +144,8 @@ const GameCanvas = () => { const handleResize = () => { if (canvasRef.current) { const screenWidth = window.innerWidth; - const canvasWidth = 0.8 * screenWidth; + let canvasWidth = screenWidth; + if (resize === true) canvasWidth = 0.8 * screenWidth; const canvasHeight = (canvasWidth / 16) * 9; canvasRef.current.width = canvasWidth; canvasRef.current.height = canvasHeight; @@ -232,6 +235,12 @@ const GameCanvas = () => { }; }, [canvasRef]); + const handleButtonClick = () => { + resize = !resize; + handleResize(); + console.log("Something should have happened"); + }; + return (
{scoreLeftReact === winScore || scoreRightReact === winScore ? ( @@ -248,10 +257,14 @@ const GameCanvas = () => { style={{ backgroundColor: "#0F0F0F" }} > )} @@ -274,7 +287,7 @@ const WinScreen = () => {
Background
@@ -307,7 +320,7 @@ const LoseScreen = () => {
Background
diff --git a/frontend/src/images/settings.png b/frontend/src/images/settings.png new file mode 100644 index 000000000..bb556a787 Binary files /dev/null and b/frontend/src/images/settings.png differ