feat : confettis + vue lobby + vue error

pull/37/head
Yvan CALATAYUD 1 year ago
parent 5689be418e
commit 0429563f75

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

@ -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"]);

@ -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) {

@ -0,0 +1,9 @@
#confetti {
overflow-y: hidden;
overflow-x: hidden;
width: 100%;
margin: 0;
height: 100%;
position: absolute;
top: 0;
}

@ -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{
@ -11,3 +12,4 @@
* {
font-family: 'MenuFont';
}

@ -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';

@ -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();

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<title>Maths Educ</title>
<title>Maths'Educ</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<title>Maths Educ</title>
<title>Maths'Educ</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<title>Maths Educ</title>
<title>Maths'Educ</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<title>Maths Educ</title>
<title>Maths'Educ</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<title>Maths Educ</title>
<title>Maths'Educ</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<title>Maths Educ</title>
<title>Maths'Educ</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>Maths'Educ</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
<link rel="stylesheet" href="css/global.css">
</head>
<body id="bodyStyle">
<div class="fs-1 text-light text-center mt-5">
ERROR 404 - Page not found
</div>
</body>
</html>

@ -4,7 +4,7 @@
<head>
<meta charset=utf-8>
<title>Math'Educ</title>
<title>Maths'Educ</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
<link rel="stylesheet" href="css/global.css">
</head>

@ -2,7 +2,7 @@
<html lang="fr">
<head>
<meta charset=utf-8>
<title>Math'Educ</title>
<title>Maths'Educ</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
<link rel="stylesheet" href="/css/global.css">
</head>

@ -2,7 +2,7 @@
<html lang="fr">
<head>
<meta charset="utf-8">
<title>Math'Educ - Connexion</title>
<title>Maths'Educ - Connexion</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
<link rel="stylesheet" href="css/global.css">
</head>

@ -2,7 +2,7 @@
<html lang="fr">
<head>
<meta charset="utf-8">
<title>Math'Educ - Connexion</title>
<title>Maths'Educ - Connexion</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
<link rel="stylesheet" href="css/global.css">
</head>

@ -3,7 +3,7 @@
<head>
<meta charset=utf-8>
<title>Math'Educ</title>
<title>Maths'Educ</title>
<link rel="stylesheet" href="css/global.css">
<link rel="stylesheet" href="css/chrono.css">
<link rel="stylesheet" href="css/progressBar.css">

@ -3,7 +3,7 @@
<head>
<meta charset=utf-8>
<title>Math'Educ</title>
<title>Maths'Educ</title>
<link rel="stylesheet" href="css/global.css">
<link rel="stylesheet" href="css/chrono.css">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<title>Maths Educ</title>
<title>Maths'Educ</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="css/global.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@ -11,14 +11,17 @@
</head>
<body id="bodyStyle">
<a href="/" role="button" class="fs-4 btn btn-secondary btn-lg position-absolute end-0 me-2">
Retour
</a>
<form action="/verifySingleplayer" method="post">
<div class="text-center" style="padding-top: 6vh">
<h1 style="color: white; font-size: 50px">Difficulte :</h1>
<input type="radio" class="btn-check" name="difficulty" id="Facile" value="1">
<label class="btn btn-outline-success fs-1" for="Facile" style="margin-right: 20px">Facile</label>
<label class="btn btn-outline-success fs-1" for="Facile">Facile</label>
<input type="radio" class="btn-check" name="difficulty" id="Toutes" value="2">
<label class="btn btn-outline-warning fs-1" for="Toutes" style="margin-right: 20px">Toutes</label>
<label class="btn btn-outline-warning fs-1 mx-3" for="Toutes">Toutes</label>
<input type="radio" class="btn-check" name="difficulty" id="Difficile" value="3">
<label class="btn btn-outline-danger fs-1" for="Difficile">Difficile</label>
@ -26,10 +29,10 @@
</div>
<div class="dropdown d-flex flex-column align-items-center p-5">
<div class="container text-center p-5 col-7">
{% for chapter in chapters %}
<input type="radio" class="btn-check" name="chapter" id="{{ chapter.name }}" value="{{ chapter.id }}">
<label class="btn btn-outline-warning fs-1" for="{{ chapter.name }}">{{ chapter.name }}</label>
<label class="btn btn-outline-secondary fs-1 mx-2 my-2" for="{{ chapter.name }}">{{ chapter.name }}</label>
{% endfor %}
</div>

@ -2,34 +2,55 @@
<html lang="fr">
<head>
<title>Maths Educ</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="css/global.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
<title>Maths'Educ</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="css/global.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="css/confetti.css">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
</head>
<body id="bodyStyle">
<div class="mt-5 border border-1 border-black p-3 bg-success text-white d-flex flex-column align-items-center fs-5">
<p>🏆 Score : 🏆</p>
<p>{{ score }}</p>
</div>
<canvas id="confetti"></canvas>
<div class="d-flex flex-column align-items-center text-light fs-3">
{% for f in Final %}
<div class="mb-3 border border-1 border-black bg-success p-2 text-white fs-3">
<a href="/themeChoice" role="button" class="fs-4 btn btn-secondary btn-lg position-absolute end-0 me-2">
Retour
</a>
<div class="d-flex flex-column align-items-center">
<p>🏆 Score 🏆</p>
<p class="fs-2">{{ score }}</p>
</div>
</div>
<div class="container-fluid text-center col d-flex justify-content-center text-light fs-3 row gy-5">
{% for f in Final %}
<div class="col-4 text-center">
<p>
Question : {{ f['Question'] }}
</p>
<p>
Bonne réponse : {{ f['goodAnswer'] }}
</p>
<p>
Votre réponse : {{ f['PlayerAnswer'] }}
</p>
{% if f['goodAnswer'] == f['PlayerAnswer'] %}
<p class="text-success">
Votre réponse : {{ f['PlayerAnswer'] }}
</p>
{% else %}
<p class="text-danger">
Votre réponse : {{ f['PlayerAnswer'] }}
</p>
{% endif %}
</div>
{% endfor %}
</div>
<script src="js/confetti.js"></script>
{% endfor %}
</div>
</body>
</html>

@ -18,3 +18,4 @@ $vues["adminQuestions"]="adminQuestions.twig";
$vues["adminQuestionsModal"]="adminQuestionsModal.twig";
$vues["viewScore"]="viewScore.twig";
$vues["lobby"]="lobby.twig";
$vues["error"]="error.twig";
Loading…
Cancel
Save