לימוד פיתוח יחידות למידה באמצעות AI
הנחיות יחידת הלימוד

משחק חשבון עם דרקונים

body {
font-family: Arial, sans-serif;
text-align: center;
background-color: #f0f8ff;
}
#game {
margin-top: 50px;
}
.question {
font-size: 24px;
margin-bottom: 20px;
}
.points {
font-size: 20px;
color: green;
}
#dragon {
display: none;
margin-top: 20px;
}
input {
padding: 10px;
font-size: 18px;
}
button {
padding: 10px 20px;
font-size: 18px;
cursor: pointer;
}
#reward {
font-size: 24px;
color: blue;
margin-top: 20px;
}

משחק חשבון עם דרקונים

שאלת חשבון תופיע כאן

נקודות: 0

דרקון

let score = 0;
let correctStreak = 0;

function getRandomInt(min, max) {
return Math.floor(Math.random() * (max – min + 1)) + min;
}

function generateQuestion() {
const num1 = getRandomInt(1, 10);
const num2 = getRandomInt(1, 10);
const question = `${num1} + ${num2}`;
const answer = num1 + num2;
return { question, answer };
}

let currentQuestion = generateQuestion();

document.getElementById(‘question’).innerText = `מהו ${currentQuestion.question}?`;

function checkAnswer() {
const userAnswer = parseInt(document.getElementById(‘answer’).value);
if (userAnswer === currentQuestion.answer) {
score += 10;
correctStreak += 1;
if (correctStreak === 3) {
showDragon();
correctStreak = 0; // איפוס הסדרה לאחר תגמול
} else {
document.getElementById(‘reward’).innerText = “יפה מאוד! המשך כך!”;
}
} else {
document.getElementById(‘reward’).innerText = “טעות, נסה שוב!”;
correctStreak = 0;
}
document.getElementById(‘points’).innerText = `נקודות: ${score}`;
document.getElementById(‘answer’).value = ”;
currentQuestion = generateQuestion();
document.getElementById(‘question’).innerText = `מהו ${currentQuestion.question}?`;
}

function showDragon() {
document.getElementById(‘dragon’).style.display = ‘block’;
document.getElementById(‘reward’).innerText = “מצוין! אתה זכית בדרקון!”;
setTimeout(() => {
document.getElementById(‘dragon’).style.display = ‘none’;
document.getElementById(‘reward’).innerText = “”;
}, 3000);
}