diff --git a/frontend/app/pong/[id]/PongBoard.tsx b/frontend/app/pong/[id]/PongBoard.tsx index e69a3dc5..85991be3 100644 --- a/frontend/app/pong/[id]/PongBoard.tsx +++ b/frontend/app/pong/[id]/PongBoard.tsx @@ -60,10 +60,6 @@ const getLogFromStatus = (status: Status) => { }; function PongBoard({ id }: PongBoardProps) { - const [fps, setFps] = useState(0); - const [speed, setSpeed] = useState(0); - const [player1Position, setPlayer1Position] = useState(0); - const [player2Position, setPlayer2Position] = useState(0); const [logs, setLogs] = useState([]); const [userMode, setUserMode] = useUserMode(); @@ -88,8 +84,8 @@ function PongBoard({ id }: PongBoardProps) { return userMode == "player" ? setRightPlayer : playerNumber == 1 - ? setLeftPlayer - : setRightPlayer; + ? setLeftPlayer + : setRightPlayer; }, [userMode], ); @@ -100,21 +96,12 @@ function PongBoard({ id }: PongBoardProps) { throw new Error("canvas not ready"); } if (!gameRef.current) { - const game = new PongGame( - ctx, - setFps, - setSpeed, - setPlayer1Position, - setPlayer2Position, - defaultColor, - defaultColor, - userMode, - ); + const game = new PongGame(ctx, defaultColor, defaultColor, userMode); gameRef.current = game; return game; } return gameRef.current; - }, [setFps, setSpeed, setPlayer1Position, setPlayer2Position, userMode]); + }, [userMode]); const start = useCallback(() => { if (!userMode) return; @@ -341,7 +328,8 @@ function PongBoard({ id }: PongBoardProps) { ref={canvasRef} width={CANVAS_WIDTH} height={CANVAS_HEIGHT} - className="border flex-grow"> + className="border flex-grow" + >
; - setSpeed: setFunction; - setPlayer1Position: setFunction; - setPlayer2Position: setFunction; onAction: onActionType | undefined; private userMode: userModeType; constructor( ctx: CanvasRenderingContext2D, - setFps: setFunction, - setSpeed: setFunction, - setPlayer1Position: setFunction, - setPlayer2Position: setFunction, paddleColor: string, ballColor: string, userMode: userModeType, @@ -71,10 +63,6 @@ export class PongGame { this.elapsed = 0; this.frame_count = 0; this.is_playing = false; - this.setFps = setFps; - this.setSpeed = setSpeed; - this.setPlayer1Position = setPlayer1Position; - this.setPlayer2Position = setPlayer2Position; this.userMode = userMode; } @@ -88,21 +76,11 @@ export class PongGame { const fps = Math.round( this.frame_count / (elapsed_since_last_update / 1000), ); - this.setFps(fps); this.frame_count = 0; this.fps_updated_at = this.updated_at; } }; - update_speed(speed: number) { - this.setSpeed(speed); - } - - update_players() { - this.setPlayer1Position(this.player1.x); - this.setPlayer2Position(this.player2.x); - } - draw_canvas = () => { // Clear objects this.ctx.clearRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT); @@ -142,9 +120,6 @@ export class PongGame { const now = Date.now(); this.elapsed = this.updated_at === undefined ? 0 : now - this.updated_at; this.updated_at = now; - this.update_fps(); - this.update_speed(this.ball.speed()); - this.update_players(); if (this.userMode === "player") { if (this.movingDirection === "left") { this.player1.clear(this.ctx); diff --git a/frontend/app/pong/[id]/PongInformationBoard.tsx b/frontend/app/pong/[id]/PongInformationBoard.tsx index 07da83d0..ffb86598 100644 --- a/frontend/app/pong/[id]/PongInformationBoard.tsx +++ b/frontend/app/pong/[id]/PongInformationBoard.tsx @@ -4,10 +4,6 @@ import { PublicUserEntity } from "@/app/lib/dtos"; import { GameCard } from "@/app/ui/pong/GameCard"; interface PongInformationBoardProps { - fps: number; - speed: number; - player1Position: number; - player2Position: number; logs: string[]; userMode: "viewer" | "player"; leftPlayer?: PublicUserEntity; @@ -15,10 +11,6 @@ interface PongInformationBoardProps { } export default function PongInformationBoard({ - fps, - speed, - player1Position, - player2Position, logs, userMode, leftPlayer, @@ -28,14 +20,6 @@ export default function PongInformationBoard({
You are a {userMode}
-
FPS: {fps}
-
Speed: {speed}
-
- player1: {player1Position} -
-
- player2: {player2Position} -