42Seoul ์น ๊ธฐ๋ฐ Pong ๊ฒ์ ์๋น์ค ํ๋ก์ ํธ
ft_transcendence๋ ๋ธ๋ผ์ฐ์ ์์ Pong ๊ฒ์์ ํ๋ ์ดํ๊ณ , ์ฌ์ฉ์ ๊ธฐ๋ก์ ๊ด๋ฆฌํ ์ ์๋ ์น ์๋น์ค์
๋๋ค.| ํญ๋ชฉ | ๋ด์ฉ |
|---|---|
| ์คํ | JavaScript Django PostgreSQL Three.js |
| ํ | 5์ธ |
| ๋ด๋น | Frontend |
sessionStorage ๊ธฐ๋ฐ ํ ๋๋จผํธ ์งํ ์ํ ๊ด๋ฆฌ#login, #profile, #gameplay/option, #gameplay/tournament, #gameplay/play-<id> ๊ธฐ๋ฐ SPA ๋ผ์ฐํ
en, ko, fn ์ธ์ด ๋ฐ์ดํฐ ๊ธฐ๋ฐ UI ํ
์คํธ ์ ํ
index.html์ด ๊ณตํต ์ง์
์ ์ด๋ฉฐ, router.js๊ฐ URL hash๋ฅผ ๊ธฐ์ค์ผ๋ก ํ์ด์ง ์ปดํฌ๋ํธ๋ฅผ ๋ ๋๋งํฉ๋๋ค.https://localhost/api/... ๊ฒฝ๋ก๋ก ์ ์ก๋๊ณ , nginx๊ฐ backend ์ปจํ
์ด๋๋ก reverse proxyํฉ๋๋ค.sessionStorage์ ์ ์ฅํฉ๋๋ค.router.js์์ window.location.hash๋ฅผ ์ฝ์ด route key๋ก ๋ณํinnerHTML, DOM element๋ฅผ ๋ฐํํ๋ฉด replaceChildren()์ผ๋ก ๋ ๋๋ง/oauth-callback/ ๊ฒฝ๋ก๋ฅผ hash route๋ก ๋ณํํด ์ฒ๋ฆฌgameplay/play-<id> ํ์์ผ๋ก ๋์ ์ฒ๋ฆฌisProtectedRoute()๋ก ๋ณดํธ ๋์ route ๊ตฌ๋ถcheckCookie()๋ก JWT ์ฟ ํค ์ํ ํ์ธsessionStorage์ tournament_in_progress, game_option, playerList, matches, currentMatch, finishedGames ์ ์ฅvalidateTournamentSession()์ผ๋ก player list, game option, match data ๊ฒ์ฆplay-<id>๊ฐ ๋ค๋ฅด๋ฉด ์ ๊ทผ ์ฐจ๋จfinishedGames์ ์ ์ฅํด ์ฌ์ง์
๋ฐฉ์งGamePlayPage์์ Three.js CDN์ ๋์ ์ผ๋ก ๋ก๋initializePingPongGame()์์ scene, camera, renderer, paddle, ball, obstacle ์์ฑsessionStorage์ game_option์ ์ฝ์ด ๊ณต ์๋, ํจ๋ค ํฌ๊ธฐ, ์ฅ์ ๋ฌผ ์์ ๋ฐ์requestAnimationFrame()์ผ๋ก ๊ฒ์ ๋ฃจํ ์คํW/S, I/K ํค ์
๋ ฅ์ผ๋ก ์์ชฝ paddle ์ด๋cleanup()์์ animation frame๊ณผ keyboard listener ์ ๊ฑฐ