From 1e6577a7fa72daa521dc947257466f1f3af27d9c Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Sun, 28 Jan 2024 19:43:54 +0100 Subject: [PATCH] don't fail if missed --- potain05/assets/jeu.js | 28 ++++++++++++++-------------- potain05/assets/style.css | 17 +---------------- potain05/index.html | 7 +++---- 3 files changed, 18 insertions(+), 34 deletions(-) diff --git a/potain05/assets/jeu.js b/potain05/assets/jeu.js index 0d392a1..1c51b04 100644 --- a/potain05/assets/jeu.js +++ b/potain05/assets/jeu.js @@ -21,7 +21,8 @@ const ACCELERATION = 100; const DURATION = 60_500; let score = 0; -let zonesCleared = 0; +let zonesCount = 0; +let zonesTotal = 0; let startTime = undefined; function start() { @@ -40,7 +41,7 @@ function start() { event.target.style.transition = ""; event.target.classList.remove("fade-out"); event.target.classList.add("inactive"); - increment(); + incrementScore(); } }) } @@ -63,7 +64,10 @@ function round() { let zone = zones[Math.floor(Math.random() * zones.length)]; + incrementTotal(); + zone.classList.remove("inactive", "fade-out"); + zone.style.transition = ""; if (CHEAT) { setTimeout(() => { @@ -79,15 +83,6 @@ function round() { zone.classList.add("fade-out"); }, MIN_TIME_BETWEEN / 2); - let zoneTimeout = setTimeout(() => { - if (!zone.classList.contains("inactive") && gameState === GAME_STARTED) { - console.log("lost because didn't click fast enough", zone.id); - gameState = GAME_LOST; - end(); - } - }, timeBetween); - zone.addEventListener("click", () => {clearTimeout(zoneTimeout)}) - // Recursive call, sorta timeBetween -= ACCELERATION; if (timeBetween <= MIN_TIME_BETWEEN) {timeBetween = MIN_TIME_BETWEEN;} @@ -106,9 +101,14 @@ function end() { } } -function increment() { +function incrementScore() { score += Math.floor(Math.random() * zones.length) + 1; - zonesCleared++; + zonesCount++; document.getElementById("score").innerText = score.toString(); - document.getElementById("zonesCount").innerText = zonesCleared.toString(); + document.getElementById("zonesCount").innerText = zonesCount.toString(); +} + +function incrementTotal() { + zonesTotal++; + document.getElementById("zonesTotal").innerText = zonesTotal.toString(); } diff --git a/potain05/assets/style.css b/potain05/assets/style.css index be07121..a603639 100644 --- a/potain05/assets/style.css +++ b/potain05/assets/style.css @@ -39,31 +39,16 @@ main, footer { .success.stamp { top: 110px; - left: 85px; + left: 220px; color: #0f5132; background-color: #d1e7dd; border: 3px solid #859a99; } -.failure.stamp { - top: 110px; - left: 200px; - color: #510f0f; - background-color: #e7d1d1; - border: 3px solid #9a8585; -} - .hidden { display: none; } -.failure { - color: #a71717; -} - -.success { - color: green; -} h2 { margin-top: 0; diff --git a/potain05/index.html b/potain05/index.html index 4c84e7c..2cd6da8 100644 --- a/potain05/index.html +++ b/potain05/index.html @@ -22,8 +22,8 @@

Jeu interactif

- Tu as une minute pour aider Pimpin le technicien à reboucher les fuites de fluide frigorigène !
- Score : 0 kg CO2e non rejetés dans l'atmosphère (0 fuites).
+ Tu as une minute pour aider Pimpin le technicien à reboucher un maximum de fuites de fluide frigorigène !
+ Score : 0 kg CO2e non rejetés dans l'atmosphère (0/0 fuites).
Temps écoulé : 0s.

@@ -41,8 +41,7 @@
- - +

N'hésite pas à partager ton score sur Teams 😉