From 0429563f755cd7dcbe2a367f2ef4e3ca987ad32a Mon Sep 17 00:00:00 2001 From: "yvan.calatayud" Date: Tue, 21 Nov 2023 14:16:53 +0100 Subject: [PATCH] feat : confettis + vue lobby + vue error --- Website/Media/background2.jpg | Bin 0 -> 11697 bytes Website/controllers/ControllerUser.php | 7 ++ Website/controllers/FrontController.php | 8 +- Website/css/confetti.css | 9 ++ Website/css/global.css | 6 +- Website/index.php | 2 + Website/js/confetti.js | 97 ++++++++++++++++++ Website/templates/adminAdministrators.twig | 2 +- .../templates/adminAdministratorsModal.twig | 2 +- Website/templates/adminChapters.twig | 2 +- Website/templates/adminChaptersModal.twig | 2 +- Website/templates/adminQuestions.twig | 2 +- Website/templates/adminQuestionsModal.twig | 2 +- Website/templates/error.twig | 14 +++ Website/templates/home.twig | 2 +- Website/templates/lobby.twig | 2 +- Website/templates/loginAdmin.twig | 2 +- Website/templates/loginPlayer.twig | 2 +- Website/templates/multiplayer.twig | 2 +- Website/templates/singleplayer.twig | 2 +- Website/templates/themeChoice.twig | 13 ++- Website/templates/viewScore.twig | 55 +++++++--- Website/usages/Config.php | 3 +- 23 files changed, 198 insertions(+), 40 deletions(-) create mode 100644 Website/Media/background2.jpg create mode 100644 Website/css/confetti.css create mode 100644 Website/js/confetti.js create mode 100644 Website/templates/error.twig diff --git a/Website/Media/background2.jpg b/Website/Media/background2.jpg new file mode 100644 index 0000000000000000000000000000000000000000..bb41488e1201fca7558fa780bd5c49bb4ee78b13 GIT binary patch literal 11697 zcmeHN3sh5Ax(*;h>#H#$iaZo=QBh!G0Oj3|JZcS48bU+}C@9EV-Vk1PI;{|D&{~xQ zAqtwn36DVxF^K_NgHcS3Aw+~EP~HRx$TJ}jxO6&qMq8_PI-NV~uDg?U);|CL@9+Em zeUiP;K4&jITlyaK-pB3--9Z`}AdtrL2ec#x{TZaKwLBWC`9`?s;&o^%WG(rErtPvsIoBmY0+Lg8HI35#d!80p^DUFI;h2EkBb1GSw%2nSHSOydK>i#{ge@#U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llers/ControllerUser.php b/Website/controllers/ControllerUser.php index 61f16a0..85d9f61 100644 --- a/Website/controllers/ControllerUser.php +++ b/Website/controllers/ControllerUser.php @@ -39,6 +39,12 @@ class ControllerUser { echo $this->twig->render($this->vues["home"]); } + + function error() + { + echo $this->twig->render($this->vues["error"]); + } + function themeChoice() { $chapters = $this->mdChapter->getChapters(); @@ -46,6 +52,7 @@ class ControllerUser 'chapters' => $chapters, ]); } + function singleplayer() { echo $this->twig->render($this->vues["singleplayer"]); diff --git a/Website/controllers/FrontController.php b/Website/controllers/FrontController.php index 4788dd5..383fa39 100755 --- a/Website/controllers/FrontController.php +++ b/Website/controllers/FrontController.php @@ -13,6 +13,7 @@ class FrontController // Define routes $router->map('GET', '/', 'ControllerUser#home'); // Route pour la page d'accueil + $router->map('GET', '/error', 'ControllerUser#error'); // Route pour la page d'erreur $router->map('GET|POST', '/[a:action]', 'ControllerUser'); //$router->map('GET', '/admin', 'ControllerAdminAdministrators'); $router->map('POST', '/login/[a:action]', 'ControllerUser'); @@ -27,6 +28,7 @@ class FrontController $router->map('GET', '/admin/questions/[a:action]/[i:id]', 'ControllerAdminQuestions'); $router->map('POST', '/user/players/[a:action]', 'ControllerAdminQuestions'); $router->map('GET', '/user/players/[a:action]/[i:id]', 'ControllerAdminQuestions'); + $router->map('GET', '/lobby', 'ControllerUserLobby'); // Match the current request $match = $router->match(); @@ -44,9 +46,9 @@ class FrontController $action = $match['params']['action']; $id = $match['params']['id']; } - $controller = new $controller; - if (is_callable(array($controller, $action))) { - call_user_func_array(array($controller, $action), array($match['params'])); + $controller = new $controller; + if (is_callable(array($controller,$action))) { + call_user_func_array(array($controller,$action), array($match['params'])); } } } catch (Exception $e) { diff --git a/Website/css/confetti.css b/Website/css/confetti.css new file mode 100644 index 0000000..dfc3824 --- /dev/null +++ b/Website/css/confetti.css @@ -0,0 +1,9 @@ +#confetti { + overflow-y: hidden; + overflow-x: hidden; + width: 100%; + margin: 0; + height: 100%; + position: absolute; + top: 0; + } \ No newline at end of file diff --git a/Website/css/global.css b/Website/css/global.css index 4074c21..d118e6f 100644 --- a/Website/css/global.css +++ b/Website/css/global.css @@ -1,5 +1,6 @@ #bodyStyle{ - background: linear-gradient(to bottom, rgba(37, 34, 71, 1), rgba(37, 35, 72, 1)); + background-image: url('../Media/background2.jpg'); + /*background: linear-gradient(to bottom, rgba(37, 34, 71, 1), rgba(37, 35, 72, 1));*/ } @font-face{ @@ -10,4 +11,5 @@ * { font-family: 'MenuFont'; -} \ No newline at end of file +} + diff --git a/Website/index.php b/Website/index.php index 76806ae..d10ed54 100755 --- a/Website/index.php +++ b/Website/index.php @@ -2,6 +2,8 @@ //chargement config require_once(__DIR__ . '/usages/Config.php'); +require_once(__DIR__ . '/usages/Config_DB.php'); + //chargement for twig require __DIR__ . '/vendor/autoload.php'; diff --git a/Website/js/confetti.js b/Website/js/confetti.js new file mode 100644 index 0000000..a700e0c --- /dev/null +++ b/Website/js/confetti.js @@ -0,0 +1,97 @@ +let W = window.innerWidth; +let H = document.getElementById('confetti').clientHeight; +const canvas = document.getElementById('confetti'); +const context = canvas.getContext("2d"); +const maxConfettis = 25; +const particles = []; + +const possibleColors = [ + "#ff7336", + "#f9e038", + "#02cca4", + "#383082", + "#fed3f5", + "#b1245a", + "#f2733f" +]; + +function randomFromTo(from, to) { + return Math.floor(Math.random() * (to - from + 1) + from); +} + +function confettiParticle() { + this.x = Math.random() * W; // x + this.y = Math.random() * H - H; // y + this.r = randomFromTo(11, 33); // radius + this.d = Math.random() * maxConfettis + 11; + this.color = + possibleColors[Math.floor(Math.random() * possibleColors.length)]; + this.tilt = Math.floor(Math.random() * 33) - 11; + this.tiltAngleIncremental = Math.random() * 0.07 + 0.05; + this.tiltAngle = 0; + + this.draw = function() { + context.beginPath(); + context.lineWidth = this.r / 2; + context.strokeStyle = this.color; + context.moveTo(this.x + this.tilt + this.r / 3, this.y); + context.lineTo(this.x + this.tilt, this.y + this.tilt + this.r / 5); + return context.stroke(); + }; +} + +function Draw() { + const results = []; + + // Magical recursive functional love + requestAnimationFrame(Draw); + + context.clearRect(0, 0, W, window.innerHeight); + + for (var i = 0; i < maxConfettis; i++) { + results.push(particles[i].draw()); + } + + let particle = {}; + let remainingFlakes = 0; + for (var i = 0; i < maxConfettis; i++) { + particle = particles[i]; + + particle.tiltAngle += particle.tiltAngleIncremental; + particle.y += (Math.cos(particle.d) + 3 + particle.r / 2) / 2; + particle.tilt = Math.sin(particle.tiltAngle - i / 3) * 15; + + if (particle.y <= H) remainingFlakes++; + + // If a confetti has fluttered out of view, + // bring it back to above the viewport and let if re-fall. + if (particle.x > W + 30 || particle.x < -30 || particle.y > H) { + particle.x = Math.random() * W; + particle.y = -30; + particle.tilt = Math.floor(Math.random() * 10) - 20; + } + } + + return results; +} + +window.addEventListener( + "resize", + function() { + W = window.innerWidth; + H = window.innerHeight; + canvas.width = window.innerWidth; + canvas.height = window.innerHeight; + }, + false +); + +// Push new confetti objects to `particles[]` +for (var i = 0; i < maxConfettis; i++) { + particles.push(new confettiParticle()); +} + +// Initialize +canvas.width = W; +canvas.height = H; +Draw(); \ No newline at end of file diff --git a/Website/templates/adminAdministrators.twig b/Website/templates/adminAdministrators.twig index 04230bf..228865d 100644 --- a/Website/templates/adminAdministrators.twig +++ b/Website/templates/adminAdministrators.twig @@ -1,7 +1,7 @@ - Maths Educ + Maths'Educ diff --git a/Website/templates/adminAdministratorsModal.twig b/Website/templates/adminAdministratorsModal.twig index bc8013e..bfa0d29 100644 --- a/Website/templates/adminAdministratorsModal.twig +++ b/Website/templates/adminAdministratorsModal.twig @@ -1,7 +1,7 @@ - Maths Educ + Maths'Educ diff --git a/Website/templates/adminChapters.twig b/Website/templates/adminChapters.twig index e25f9df..934f0aa 100644 --- a/Website/templates/adminChapters.twig +++ b/Website/templates/adminChapters.twig @@ -1,7 +1,7 @@ - Maths Educ + Maths'Educ diff --git a/Website/templates/adminChaptersModal.twig b/Website/templates/adminChaptersModal.twig index 3dd9d21..c9edc83 100644 --- a/Website/templates/adminChaptersModal.twig +++ b/Website/templates/adminChaptersModal.twig @@ -1,7 +1,7 @@ - Maths Educ + Maths'Educ diff --git a/Website/templates/adminQuestions.twig b/Website/templates/adminQuestions.twig index 4d36d1a..9faa79f 100644 --- a/Website/templates/adminQuestions.twig +++ b/Website/templates/adminQuestions.twig @@ -1,7 +1,7 @@ - Maths Educ + Maths'Educ diff --git a/Website/templates/adminQuestionsModal.twig b/Website/templates/adminQuestionsModal.twig index f62e650..f38403f 100644 --- a/Website/templates/adminQuestionsModal.twig +++ b/Website/templates/adminQuestionsModal.twig @@ -1,7 +1,7 @@ - Maths Educ + Maths'Educ diff --git a/Website/templates/error.twig b/Website/templates/error.twig new file mode 100644 index 0000000..41be582 --- /dev/null +++ b/Website/templates/error.twig @@ -0,0 +1,14 @@ + + + + + Maths'Educ + + + + +
+ ERROR 404 - Page not found +
+ + \ No newline at end of file diff --git a/Website/templates/home.twig b/Website/templates/home.twig index eb61a11..545af64 100644 --- a/Website/templates/home.twig +++ b/Website/templates/home.twig @@ -4,7 +4,7 @@ - Math'Educ + Maths'Educ diff --git a/Website/templates/lobby.twig b/Website/templates/lobby.twig index a1467af..e5cef98 100644 --- a/Website/templates/lobby.twig +++ b/Website/templates/lobby.twig @@ -2,7 +2,7 @@ - Math'Educ + Maths'Educ diff --git a/Website/templates/loginAdmin.twig b/Website/templates/loginAdmin.twig index 0410ac8..76b8f60 100644 --- a/Website/templates/loginAdmin.twig +++ b/Website/templates/loginAdmin.twig @@ -2,7 +2,7 @@ - Math'Educ - Connexion + Maths'Educ - Connexion diff --git a/Website/templates/loginPlayer.twig b/Website/templates/loginPlayer.twig index b20d194..36a56fa 100644 --- a/Website/templates/loginPlayer.twig +++ b/Website/templates/loginPlayer.twig @@ -2,7 +2,7 @@ - Math'Educ - Connexion + Maths'Educ - Connexion diff --git a/Website/templates/multiplayer.twig b/Website/templates/multiplayer.twig index 124e9fa..d58a58e 100644 --- a/Website/templates/multiplayer.twig +++ b/Website/templates/multiplayer.twig @@ -3,7 +3,7 @@ - Math'Educ + Maths'Educ diff --git a/Website/templates/singleplayer.twig b/Website/templates/singleplayer.twig index 7c3e727..2873110 100644 --- a/Website/templates/singleplayer.twig +++ b/Website/templates/singleplayer.twig @@ -3,7 +3,7 @@ - Math'Educ + Maths'Educ diff --git a/Website/templates/themeChoice.twig b/Website/templates/themeChoice.twig index 2bc6323..5d15e61 100644 --- a/Website/templates/themeChoice.twig +++ b/Website/templates/themeChoice.twig @@ -1,7 +1,7 @@ - Maths Educ + Maths'Educ @@ -11,14 +11,17 @@ + + Retour +

Difficulte :

- + - + @@ -26,10 +29,10 @@
-