Multiplication Challenge Game – Jeu de défi de multiplication
Update: 2025-05-19
Description
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Défi de Multiplication</title>
<style>
body {
font-family: 'Segoe UI', sans-serif;
margin: 0;
padding: 1rem;
background: #f0f4f8;
color: #2c3e50;
}
#game-container {
max-width: 600px;
margin: auto;
background: white;
padding: 2rem;
border-radius: 12px;
box-shadow: 0 8px 20px rgba(0,0,0,0.1);
}
h1, h2 {
color: #34495e;
}
input[type="number"], button {
width: 100%;
padding: 0.75rem;
margin-top: 1rem;
font-size: 1rem;
border: 2px solid #ccc;
border-radius: 8px;
box-sizing: border-box;
}
input[type="number"]:focus {
border-color: #2980b9;
outline: none;
}
button {
background-color: #2980b9;
color: white;
font-weight: bold;
border: none;
cursor: pointer;
transition: background-color 0.3s ease;
}
button:hover {
background-color: #1f6394;
}
.score-card {
margin-top: 1rem;
padding: 1rem;
background-color: #ecf0f1;
border-left: 6px solid #3498db;
font-size: 1.25rem;
border-radius: 6px;
}
#timer {
font-weight: bold;
color: #e67e22;
margin-bottom: 1rem;
}
@media (max-width: 600px) {
body {
padding: 1rem;
}
#game-container {
padding: 1rem;
}
}
</style>
</head>
<body>
<label>
Choisissez le temps (en minutes) :
<input type="number" id="timeInput" min="1" max="10" value="5">
</label>
<button onclick="startGame()">
Démarrer</button>
<input type="number" id="answerInput" placeholder="✍ Votre réponse" />
<button onclick="submitAnswer()">
Soumettre</button>
<button onclick="restartGame()">
Rejouer</button>
<script>
let question = {}, score = 0, timeLeft = 0, timerInterval;
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function generateQuestion() {
const a = getRandomInt(2, 12);
const b = getRandomInt(2, 12);
question = { a, b, answer: a * b };
document.getElementById('question').textContent = `Combien font ${a} × ${b} ?`;
}
function startGame() {
score = 0;
document.getElementById('scoreCard').textContent = `Score : ${score}`;
timeLeft = parseInt(document.getElementById('timeInput').value) * 60;
document.getElementById('setup').style.display = 'none';
document.getElementById('game').style.display = 'block';
document.getElementById('gameOver').style.display = 'none';
generateQuestion();
document.getElementById('answerInput').value = '';
document.getElementById('answerInput').focus();
updateTimer();
timerInterval = setInterval(() => {
timeLeft--;
updateTimer();
if (timeLeft <= 0) endGame();
}, 1000);
}
function updateTimer() {
const min = Math.floor(timeLeft / 60);
const sec = timeLeft % 60;
document.getElementById('timer').textContent = `⏱ Temps restant : ${min}:${sec.toString().padStart(2, '0')}`;
}
function submitAnswer() {
const userAnswer = parseInt(document.getElementById('answerInput').value);
const correctSound = document.getElementById('correctSound');
const wrongSound = document.getElementById('wrongSound');
if (userAnswer === question.answer) {
correctSound.play();
score++;
} else {
wrongSound.play();
}
document.getElementById('scoreCard').textContent = `Score : ${score}`;
generateQuestion();
document.getElementById('answerInput').value = '';
document.getElementById('answerInput').focus();
}
function endGame() {
clearInterval(timerInterval);
document.getElementById('game').style.display = 'none';
document.getElementById('gameOver').style.display = 'block';
document.getElementById('finalScore').textContent = `Votre score final : ${score}`;
}
function restartGame() {
document.getElementById('setup').style.display = 'block';
document.getElementById('gameOver').style.display = 'none';
}
</script>
</body>
</html>
<html lang="fr">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Défi de Multiplication</title>
<style>
body {
font-family: 'Segoe UI', sans-serif;
margin: 0;
padding: 1rem;
background: #f0f4f8;
color: #2c3e50;
}
#game-container {
max-width: 600px;
margin: auto;
background: white;
padding: 2rem;
border-radius: 12px;
box-shadow: 0 8px 20px rgba(0,0,0,0.1);
}
h1, h2 {
color: #34495e;
}
input[type="number"], button {
width: 100%;
padding: 0.75rem;
margin-top: 1rem;
font-size: 1rem;
border: 2px solid #ccc;
border-radius: 8px;
box-sizing: border-box;
}
input[type="number"]:focus {
border-color: #2980b9;
outline: none;
}
button {
background-color: #2980b9;
color: white;
font-weight: bold;
border: none;
cursor: pointer;
transition: background-color 0.3s ease;
}
button:hover {
background-color: #1f6394;
}
.score-card {
margin-top: 1rem;
padding: 1rem;
background-color: #ecf0f1;
border-left: 6px solid #3498db;
font-size: 1.25rem;
border-radius: 6px;
}
#timer {
font-weight: bold;
color: #e67e22;
margin-bottom: 1rem;
}
@media (max-width: 600px) {
body {
padding: 1rem;
}
#game-container {
padding: 1rem;
}
}
</style>
</head>
<body>
Défi de Multiplication
<label>

<input type="number" id="timeInput" min="1" max="10" value="5">
</label>
<button onclick="startGame()">

<input type="number" id="answerInput" placeholder="✍ Votre réponse" />
<button onclick="submitAnswer()">

Score : 0
Temps écoulé !
<button onclick="restartGame()">

<script>
let question = {}, score = 0, timeLeft = 0, timerInterval;
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function generateQuestion() {
const a = getRandomInt(2, 12);
const b = getRandomInt(2, 12);
question = { a, b, answer: a * b };
document.getElementById('question').textContent = `Combien font ${a} × ${b} ?`;
}
function startGame() {
score = 0;
document.getElementById('scoreCard').textContent = `Score : ${score}`;
timeLeft = parseInt(document.getElementById('timeInput').value) * 60;
document.getElementById('setup').style.display = 'none';
document.getElementById('game').style.display = 'block';
document.getElementById('gameOver').style.display = 'none';
generateQuestion();
document.getElementById('answerInput').value = '';
document.getElementById('answerInput').focus();
updateTimer();
timerInterval = setInterval(() => {
timeLeft--;
updateTimer();
if (timeLeft <= 0) endGame();
}, 1000);
}
function updateTimer() {
const min = Math.floor(timeLeft / 60);
const sec = timeLeft % 60;
document.getElementById('timer').textContent = `⏱ Temps restant : ${min}:${sec.toString().padStart(2, '0')}`;
}
function submitAnswer() {
const userAnswer = parseInt(document.getElementById('answerInput').value);
const correctSound = document.getElementById('correctSound');
const wrongSound = document.getElementById('wrongSound');
if (userAnswer === question.answer) {
correctSound.play();
score++;
} else {
wrongSound.play();
}
document.getElementById('scoreCard').textContent = `Score : ${score}`;
generateQuestion();
document.getElementById('answerInput').value = '';
document.getElementById('answerInput').focus();
}
function endGame() {
clearInterval(timerInterval);
document.getElementById('game').style.display = 'none';
document.getElementById('gameOver').style.display = 'block';
document.getElementById('finalScore').textContent = `Votre score final : ${score}`;
}
function restartGame() {
document.getElementById('setup').style.display = 'block';
document.getElementById('gameOver').style.display = 'none';
}
</script>
</body>
</html>
Jeu de défi de multiplication
Comments
In Channel