From 5e19ed3ed9357ca0c8e6083af473115a541f404f Mon Sep 17 00:00:00 2001 From: bgoulard Date: Wed, 7 Jan 2026 14:41:56 +0100 Subject: [PATCH] pong pro-tips / how-to-play added --- frontend/src/pages/pong/pong.css | 35 +++++++++++++++++++++++++++++++ frontend/src/pages/pong/pong.html | 13 +++++++++--- frontend/src/pages/pong/pong.ts | 15 +++++++++++-- 3 files changed, 58 insertions(+), 5 deletions(-) diff --git a/frontend/src/pages/pong/pong.css b/frontend/src/pages/pong/pong.css index c464060..bf7f5a8 100644 --- a/frontend/src/pages/pong/pong.css +++ b/frontend/src/pages/pong/pong.css @@ -154,4 +154,39 @@ text-base bg-white z-50 +} + +.pong-protips-box { + @apply + justify-center + absolute + bg-white + + border-10 + rounded-3xl + border-white + + text-center + text-2xl + text-black +} + +.pong-protips-key { + @apply + inline-flex + items-center + justify-center + min-w-[2rem] h-8 px-2 + rounded-md border border-gray-300 + bg-gray-100 text-gray-800 + font-mono text-sm font-medium + shadow-sm + select-none +} + +.pong-how-to-play { + @apply + inline-flex items-center justify-center + rounded-full w-8 h-8 bg-blue-500 + border-10 border-blue-500 } \ No newline at end of file diff --git a/frontend/src/pages/pong/pong.html b/frontend/src/pages/pong/pong.html index 0b63dcf..3ef8190 100644 --- a/frontend/src/pages/pong/pong.html +++ b/frontend/src/pages/pong/pong.html @@ -2,14 +2,13 @@
- ?👤 ?⏳ ?▮•▮ + ?👤 ?⏳ ?▮•▮ +

Pong Box


- -

@@ -20,6 +19,14 @@
+
diff --git a/frontend/src/pages/pong/pong.ts b/frontend/src/pages/pong/pong.ts index edebfb2..a03423f 100644 --- a/frontend/src/pages/pong/pong.ts +++ b/frontend/src/pages/pong/pong.ts @@ -66,6 +66,8 @@ function pongClient(_url: string, _args: RouteHandlerParams): RouteHandlerReturn const LocalGameBtn = document.querySelector("#LocalBtn"); const gameBoard = document.querySelector("#pongbox"); const queue_infos = document.querySelector("#queue-info"); + const how_to_play_btn = document.querySelector("#play-info"); + const protips = document.querySelector("#protips-box"); let socket = getSocket(); @@ -75,16 +77,27 @@ function pongClient(_url: string, _args: RouteHandlerParams): RouteHandlerReturn } if (!batLeft || !batRight || !ball || !score || !queueBtn || !playerL || !playerR || !gameBoard || !queue_infos || !LocalGameBtn || !rdy_btn) // sanity check return showError('fatal error'); + if (!how_to_play_btn || !protips) + showError('missing protips'); // not a fatal error // --- // keys handler // --- const keys: Record = {}; + if (how_to_play_btn && protips) + how_to_play_btn.addEventListener("click", ()=>{ + protips.classList.toggle("hidden"); + how_to_play_btn.innerText = how_to_play_btn.innerText === '?' ? 'x' : '?'; + }); document.addEventListener("keydown", (e) => {keys[e.key.toLowerCase()] = true;}); document.addEventListener("keyup", (e) => {keys[e.key.toLowerCase()] = false;}); setInterval(() => { // key sender + if (keys['escape'] === true && protips && how_to_play_btn) { + protips.classList.add("hidden"); + how_to_play_btn.innerText = '?'; + } if (queueBtn.innerText !== QueueState.InGame)//we're in game ? continue | gtfo return ; if (currentGame === null) return; @@ -150,8 +163,6 @@ function pongClient(_url: string, _args: RouteHandlerParams): RouteHandlerReturn score.innerText = `${state.left.score} | ${state.right.score}` } socket.on('gameUpdate', (state: GameUpdate) => { - // if (rdy_btn) - // rdy_btn.classList.add('hidden'); render(state);}); // --- // position logic (client) end