Spaces:
Running
Running
Add 2 files
Browse files- README.md +6 -4
- index.html +605 -19
README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
colorTo: red
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: math-prodigy
|
| 3 |
+
emoji: 🐳
|
| 4 |
+
colorFrom: green
|
| 5 |
colorTo: red
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite
|
| 10 |
---
|
| 11 |
|
| 12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
|
@@ -1,19 +1,605 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="zh-CN">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>数学小天才</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<script>
|
| 9 |
+
tailwind.config = {
|
| 10 |
+
theme: {
|
| 11 |
+
extend: {
|
| 12 |
+
fontFamily: {
|
| 13 |
+
sans: ['Inter', 'sans-serif'],
|
| 14 |
+
},
|
| 15 |
+
animation: {
|
| 16 |
+
'float': 'float 3s ease-in-out infinite',
|
| 17 |
+
'pulse-slow': 'pulse 3s cubic-bezier(0.4, 0, 0.6, 1) infinite',
|
| 18 |
+
'fade-in': 'fadeIn 0.3s ease-out',
|
| 19 |
+
'fade-out': 'fadeOut 0.3s ease-out',
|
| 20 |
+
'slide-up': 'slideUp 0.8s cubic-bezier(0.34, 1.56, 0.64, 1)',
|
| 21 |
+
},
|
| 22 |
+
keyframes: {
|
| 23 |
+
float: {
|
| 24 |
+
'0%, 100%': { transform: 'translateY(0)' },
|
| 25 |
+
'50%': { transform: 'translateY(-10px)' },
|
| 26 |
+
},
|
| 27 |
+
fadeIn: {
|
| 28 |
+
'0%': { opacity: '0', transform: 'translateY(10px)' },
|
| 29 |
+
'100%': { opacity: '1', transform: 'translateY(0)' },
|
| 30 |
+
},
|
| 31 |
+
fadeOut: {
|
| 32 |
+
'0%': { opacity: '1', transform: 'translateY(0)' },
|
| 33 |
+
'100%': { opacity: '0', transform: 'translateY(-10px)' },
|
| 34 |
+
},
|
| 35 |
+
slideUp: {
|
| 36 |
+
'0%': { transform: 'translateY(100%)', opacity: '0' },
|
| 37 |
+
'100%': { transform: 'translateY(0)', opacity: '1' },
|
| 38 |
+
},
|
| 39 |
+
}
|
| 40 |
+
}
|
| 41 |
+
}
|
| 42 |
+
}
|
| 43 |
+
</script>
|
| 44 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 45 |
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
|
| 46 |
+
<style>
|
| 47 |
+
@keyframes confetti-fall {
|
| 48 |
+
0% { transform: translateY(-100px) rotate(0deg); opacity: 1; }
|
| 49 |
+
100% { transform: translateY(100vh) rotate(360deg); opacity: 0; }
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
.animate-confetti {
|
| 53 |
+
animation: confetti-fall 2s linear forwards;
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
.linear-card {
|
| 57 |
+
background: rgba(255, 255, 255, 0.6);
|
| 58 |
+
backdrop-filter: blur(12px);
|
| 59 |
+
border: 1px solid rgba(255, 255, 255, 0.2);
|
| 60 |
+
box-shadow: 0 8px 32px rgba(31, 38, 135, 0.05);
|
| 61 |
+
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
.linear-card:hover {
|
| 65 |
+
box-shadow: 0 8px 32px rgba(31, 38, 135, 0.1);
|
| 66 |
+
transform: translateY(-2px);
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
.btn-transition {
|
| 70 |
+
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
.btn-scale:hover {
|
| 74 |
+
transform: scale(1.02);
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
.btn-scale:active {
|
| 78 |
+
transform: scale(0.98);
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
.elevate-on-hover {
|
| 82 |
+
transition: transform 0.2s ease, box-shadow 0.2s ease;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
.elevate-on-hover:hover {
|
| 86 |
+
transform: translateY(-4px);
|
| 87 |
+
box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
.slide-in {
|
| 91 |
+
animation: slideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
@keyframes slideIn {
|
| 95 |
+
from { transform: translateY(20px); opacity: 0; }
|
| 96 |
+
to { transform: translateY(0); opacity: 1; }
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
.fade-in {
|
| 100 |
+
animation: fadeIn 0.3s ease-out forwards;
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
.bounce-animation {
|
| 104 |
+
animation: bounce 0.5s alternate infinite ease-in-out;
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
@keyframes bounce {
|
| 108 |
+
from { transform: translateY(-5px); }
|
| 109 |
+
to { transform: translateY(5px); }
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
/* Celebration animation */
|
| 113 |
+
.celebration-item {
|
| 114 |
+
position: absolute;
|
| 115 |
+
opacity: 0;
|
| 116 |
+
z-index: 100;
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
@keyframes celebrationRise {
|
| 120 |
+
0% {
|
| 121 |
+
transform: translateY(100vh) scale(0);
|
| 122 |
+
opacity: 1;
|
| 123 |
+
}
|
| 124 |
+
40% {
|
| 125 |
+
transform: translateY(60vh) scale(1);
|
| 126 |
+
opacity: 0.8;
|
| 127 |
+
}
|
| 128 |
+
80% {
|
| 129 |
+
opacity: 0.5;
|
| 130 |
+
}
|
| 131 |
+
100% {
|
| 132 |
+
transform: translateY(-100px) scale(0.5);
|
| 133 |
+
opacity: 0;
|
| 134 |
+
}
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
/* Mobile game mode styles */
|
| 138 |
+
.game-mode .game-header,
|
| 139 |
+
.game-mode .game-footer {
|
| 140 |
+
display: none;
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
.game-mode .game-wrapper {
|
| 144 |
+
margin-top: 0;
|
| 145 |
+
padding-top: 0.5rem;
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
.game-mode .answer-options {
|
| 149 |
+
grid-template-columns: 1fr !important;
|
| 150 |
+
gap: 0.5rem !important;
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
.game-mode .answer-btn {
|
| 154 |
+
padding: 0.75rem !important;
|
| 155 |
+
font-size: 1rem !important;
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
.game-mode .visual-aid {
|
| 159 |
+
gap: 0.25rem !important;
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
.game-mode .visual-item {
|
| 163 |
+
width: 1.75rem !important;
|
| 164 |
+
height: 1.75rem !important;
|
| 165 |
+
font-size: 0.75rem !important;
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
.game-mode #question {
|
| 169 |
+
font-size: 2rem !important;
|
| 170 |
+
margin-bottom: 0.5rem !important;
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
.game-mode .character {
|
| 174 |
+
font-size: 3rem !important;
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
.game-mode .stats-bar {
|
| 178 |
+
padding: 0.5rem !important;
|
| 179 |
+
margin-bottom: 0.5rem !important;
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
.game-mode .stats-item {
|
| 183 |
+
font-size: 0.875rem !important;
|
| 184 |
+
}
|
| 185 |
+
</style>
|
| 186 |
+
</head>
|
| 187 |
+
<body class="bg-gradient-to-br from-gray-50 to-gray-100 min-h-screen font-sans text-gray-800">
|
| 188 |
+
<div id="app" class="container mx-auto px-4 py-4 max-w-4xl relative">
|
| 189 |
+
<!-- Header (hidden during gameplay) -->
|
| 190 |
+
<header class="game-header text-center mb-6 fade-in">
|
| 191 |
+
<div class="w-16 h-16 mx-auto mb-4 linear-card rounded-full flex items-center justify-center shadow-sm hover:shadow-md transition-all elevate-on-hover">
|
| 192 |
+
<i class="fas fa-calculator text-2xl text-indigo-500"></i>
|
| 193 |
+
</div>
|
| 194 |
+
<h1 class="text-2xl font-bold text-gray-800 mb-2 tracking-tight">数学小天才</h1>
|
| 195 |
+
<p class="text-xs text-gray-500">快乐学习 · 轻松进步</p>
|
| 196 |
+
</header>
|
| 197 |
+
|
| 198 |
+
<!-- Main wrapper -->
|
| 199 |
+
<main class="game-wrapper">
|
| 200 |
+
<!-- Game selection screen -->
|
| 201 |
+
<div id="game-selection" class="p-4 linear-card rounded-xl overflow-hidden slide-in">
|
| 202 |
+
<h2 class="text-xl font-semibold text-center text-gray-700 mb-4">选择游戏模式</h2>
|
| 203 |
+
|
| 204 |
+
<div class="grid grid-cols-1 gap-3 mb-6">
|
| 205 |
+
<button onclick="startGame('addition')" class="linear-card btn-transition btn-scale py-3 px-4 rounded-lg hover:bg-indigo-50/50 text-indigo-600 font-medium flex items-center justify-center gap-2 border border-indigo-100">
|
| 206 |
+
<i class="fas fa-plus text-lg"></i>
|
| 207 |
+
<span>加法练习</span>
|
| 208 |
+
</button>
|
| 209 |
+
<button onclick="startGame('subtraction')" class="linear-card btn-transition btn-scale py-3 px-4 rounded-lg hover:bg-purple-50/50 text-purple-600 font-medium flex items-center justify-center gap-2 border border-purple-100">
|
| 210 |
+
<i class="fas fa-minus text-lg"></i>
|
| 211 |
+
<span>减法练习</span>
|
| 212 |
+
</button>
|
| 213 |
+
</div>
|
| 214 |
+
|
| 215 |
+
<div class="space-y-2">
|
| 216 |
+
<h3 class="text-base font-medium text-gray-700">难度设置</h3>
|
| 217 |
+
<div class="grid grid-cols-3 gap-2">
|
| 218 |
+
<label>
|
| 219 |
+
<input type="radio" name="difficulty" value="easy" checked class="hidden peer">
|
| 220 |
+
<div class="h-full linear-card peer-checked:bg-indigo-50/50 peer-checked:border-indigo-200 peer-checked:text-indigo-600 border border-gray-100 rounded-lg p-2 text-center cursor-pointer transition-all flex flex-col items-center">
|
| 221 |
+
<i class="fas fa-smile text-lg mb-1"></i>
|
| 222 |
+
<span class="text-xs">简单模式</span>
|
| 223 |
+
<span class="text-[0.6rem] text-gray-500 mt-0.5">数字1-5</span>
|
| 224 |
+
</div>
|
| 225 |
+
</label>
|
| 226 |
+
<label>
|
| 227 |
+
<input type="radio" name="difficulty" value="medium" class="hidden peer">
|
| 228 |
+
<div class="h-full linear-card peer-checked:bg-purple-50/50 peer-checked:border-purple-200 peer-checked:text-purple-600 border border-gray-100 rounded-lg p-2 text-center cursor-pointer transition-all flex flex-col items-center">
|
| 229 |
+
<i class="fas fa-meh text-lg mb-1"></i>
|
| 230 |
+
<span class="text-xs">中等模式</span>
|
| 231 |
+
<span class="text-[0.6rem] text-gray-500 mt-0.5">数字1-10</span>
|
| 232 |
+
</div>
|
| 233 |
+
</label>
|
| 234 |
+
<label>
|
| 235 |
+
<input type="radio" name="difficulty" value="hard" class="hidden peer">
|
| 236 |
+
<div class="h-full linear-card peer-checked:bg-rose-50/50 peer-checked:border-rose-200 peer-checked:text-rose-600 border border-gray-100 rounded-lg p-2 text-center cursor-pointer transition-all flex flex-col items-center">
|
| 237 |
+
<i class="fas fa-frown text-lg mb-1"></i>
|
| 238 |
+
<span class="text-xs">困难模式</span>
|
| 239 |
+
<span class="text-[0.6rem] text-gray-500 mt-0.5">数字1-20</span>
|
| 240 |
+
</div>
|
| 241 |
+
</label>
|
| 242 |
+
</div>
|
| 243 |
+
</div>
|
| 244 |
+
</div>
|
| 245 |
+
|
| 246 |
+
<!-- Game area -->
|
| 247 |
+
<div id="game-area" class="hidden">
|
| 248 |
+
<div class="flex justify-between items-center mb-3 linear-card bg-gradient-to-r from-indigo-50/50 to-purple-50/50 p-2 rounded-lg border border-gray-100 stats-bar">
|
| 249 |
+
<div class="flex items-center gap-1 stats-item">
|
| 250 |
+
<i class="fas fa-star text-amber-400 text-sm"></i>
|
| 251 |
+
<span>得分: <span id="score" class="font-medium text-indigo-600">0</span></span>
|
| 252 |
+
</div>
|
| 253 |
+
<div class="flex items-center gap-1 stats-item">
|
| 254 |
+
<i class="fas fa-clock text-purple-500 text-sm"></i>
|
| 255 |
+
<span>时间: <span id="time" class="font-medium text-purple-600">60</span>秒</span>
|
| 256 |
+
</div>
|
| 257 |
+
<button onclick="backToMenu()" class="text-xs bg-white/70 px-2 py-0.5 rounded-full border border-gray-200 text-gray-600 hover:bg-white">
|
| 258 |
+
<i class="fas fa-times"></i>
|
| 259 |
+
</button>
|
| 260 |
+
</div>
|
| 261 |
+
|
| 262 |
+
<!-- Question card -->
|
| 263 |
+
<div class="linear-card rounded-lg p-3 mb-3">
|
| 264 |
+
<div id="question" class="text-2xl font-bold text-center mb-2"></div>
|
| 265 |
+
<div id="visual-aid" class="visual-aid flex justify-center items-center flex-wrap gap-1 mb-2"></div>
|
| 266 |
+
</div>
|
| 267 |
+
|
| 268 |
+
<!-- Answer options -->
|
| 269 |
+
<div id="answer-options" class="answer-options grid grid-cols-2 gap-2 mb-3"></div>
|
| 270 |
+
|
| 271 |
+
<!-- Feedback area -->
|
| 272 |
+
<div class="linear-card rounded-lg p-3 overflow-hidden">
|
| 273 |
+
<div id="feedback" class="text-center text-xs mb-2"></div>
|
| 274 |
+
<div id="character" class="character text-4xl text-center bounce-animation">🤔</div>
|
| 275 |
+
</div>
|
| 276 |
+
|
| 277 |
+
<!-- Next button -->
|
| 278 |
+
<div id="next-btn-container" class="hidden mt-3">
|
| 279 |
+
<button id="next-btn" onclick="nextQuestion()"
|
| 280 |
+
class="w-full py-2 answer-btn linear-card bg-gradient-to-r from-indigo-500 to-purple-500 text-white rounded-lg font-medium btn-transition btn-scale hover:from-indigo-600 hover:to-purple-600 hover:shadow-md">
|
| 281 |
+
下一题 <i class="fas fa-arrow-right ml-1"></i>
|
| 282 |
+
</button>
|
| 283 |
+
</div>
|
| 284 |
+
</div>
|
| 285 |
+
|
| 286 |
+
<!-- Results screen -->
|
| 287 |
+
<div id="results-screen" class="hidden">
|
| 288 |
+
<div class="linear-card rounded-xl p-4 text-center slide-up">
|
| 289 |
+
<div class="w-16 h-16 mx-auto mb-4 bg-gradient-to-r from-indigo-500 to-purple-500 text-white rounded-full flex items-center justify-center text-2xl shadow-sm">
|
| 290 |
+
🎓
|
| 291 |
+
</div>
|
| 292 |
+
<h2 class="text-xl font-bold mb-2">游戏完成!</h2>
|
| 293 |
+
<p class="text-gray-600 mb-3 text-xs">你的精彩表现值得赞赏</p>
|
| 294 |
+
|
| 295 |
+
<div class="linear-card rounded-lg p-4 inline-block mb-4 bg-gradient-to-r from-indigo-50/50 to-purple-50/50">
|
| 296 |
+
<p class="text-gray-600 mb-1 text-xs">最终得分</p>
|
| 297 |
+
<p id="final-score" class="text-3xl font-bold bg-gradient-to-r from-indigo-600 to-purple-600 bg-clip-text text-transparent">0</p>
|
| 298 |
+
</div>
|
| 299 |
+
|
| 300 |
+
<div class="flex flex-col gap-2">
|
| 301 |
+
<button onclick="restartGame()"
|
| 302 |
+
class="linear-card btn-transition btn-scale py-2 px-3 bg-indigo-500 hover:bg-indigo-600 text-white rounded-lg text-xs font-medium flex items-center justify-center gap-1">
|
| 303 |
+
<i class="fas fa-redo text-xs"></i> 再玩一次
|
| 304 |
+
</button>
|
| 305 |
+
<button onclick="backToMenu()"
|
| 306 |
+
class="linear-card btn-transition btn-scale py-2 px-3 bg-white hover:bg-gray-50 text-gray-700 border border-gray-200 rounded-lg text-xs font-medium flex items-center justify-center gap-1">
|
| 307 |
+
<i class="fas fa-home text-xs"></i> 返回菜单
|
| 308 |
+
</button>
|
| 309 |
+
</div>
|
| 310 |
+
</div>
|
| 311 |
+
</div>
|
| 312 |
+
</main>
|
| 313 |
+
|
| 314 |
+
<footer class="game-footer text-center mt-6 text-gray-500 text-xs">
|
| 315 |
+
<p>用 <i class="fas fa-heart text-rose-400"></i> 为孩子打造 · © 2023 数学小天才</p>
|
| 316 |
+
</footer>
|
| 317 |
+
</div>
|
| 318 |
+
|
| 319 |
+
<script>
|
| 320 |
+
// Game variables
|
| 321 |
+
let currentGameType = '';
|
| 322 |
+
let currentDifficulty = 'easy';
|
| 323 |
+
let score = 0;
|
| 324 |
+
let timeLeft = 60;
|
| 325 |
+
let timer;
|
| 326 |
+
let currentQuestion = {};
|
| 327 |
+
let correctAnswer;
|
| 328 |
+
|
| 329 |
+
// DOM elements
|
| 330 |
+
const appElement = document.getElementById('app');
|
| 331 |
+
const gameSelection = document.getElementById('game-selection');
|
| 332 |
+
const gameArea = document.getElementById('game-area');
|
| 333 |
+
const resultsScreen = document.getElementById('results-screen');
|
| 334 |
+
const questionElement = document.getElementById('question');
|
| 335 |
+
const visualAidElement = document.getElementById('visual-aid');
|
| 336 |
+
const answerOptionsElement = document.getElementById('answer-options');
|
| 337 |
+
const feedbackElement = document.getElementById('feedback');
|
| 338 |
+
const characterElement = document.getElementById('character');
|
| 339 |
+
const scoreElement = document.getElementById('score');
|
| 340 |
+
const timeElement = document.getElementById('time');
|
| 341 |
+
const finalScoreElement = document.getElementById('final-score');
|
| 342 |
+
const nextButtonContainer = document.getElementById('next-btn-container');
|
| 343 |
+
const nextButton = document.getElementById('next-btn');
|
| 344 |
+
|
| 345 |
+
// Start game
|
| 346 |
+
function startGame(gameType) {
|
| 347 |
+
currentGameType = gameType;
|
| 348 |
+
const selectedDifficulty = document.querySelector('input[name="difficulty"]:checked');
|
| 349 |
+
currentDifficulty = selectedDifficulty ? selectedDifficulty.value : 'easy';
|
| 350 |
+
score = 0;
|
| 351 |
+
timeLeft = 60;
|
| 352 |
+
|
| 353 |
+
// Enter game mode (hide header/footer)
|
| 354 |
+
appElement.classList.add('game-mode');
|
| 355 |
+
|
| 356 |
+
gameSelection.classList.add('hidden');
|
| 357 |
+
gameArea.classList.remove('hidden');
|
| 358 |
+
|
| 359 |
+
updateScore();
|
| 360 |
+
updateTimer();
|
| 361 |
+
startTimer();
|
| 362 |
+
generateQuestion();
|
| 363 |
+
}
|
| 364 |
+
|
| 365 |
+
// Timer functions
|
| 366 |
+
function startTimer() {
|
| 367 |
+
clearInterval(timer);
|
| 368 |
+
timer = setInterval(() => {
|
| 369 |
+
timeLeft--;
|
| 370 |
+
updateTimer();
|
| 371 |
+
|
| 372 |
+
if (timeLeft <= 0) {
|
| 373 |
+
endGame();
|
| 374 |
+
}
|
| 375 |
+
}, 1000);
|
| 376 |
+
}
|
| 377 |
+
|
| 378 |
+
function updateTimer() {
|
| 379 |
+
timeElement.textContent = timeLeft;
|
| 380 |
+
|
| 381 |
+
// Change color when time is running out
|
| 382 |
+
if (timeLeft <= 10) {
|
| 383 |
+
timeElement.classList.remove('text-purple-600');
|
| 384 |
+
timeElement.classList.add('text-rose-500');
|
| 385 |
+
} else {
|
| 386 |
+
timeElement.classList.remove('text-rose-500');
|
| 387 |
+
timeElement.classList.add('text-purple-600');
|
| 388 |
+
}
|
| 389 |
+
}
|
| 390 |
+
|
| 391 |
+
// Generate question
|
| 392 |
+
function generateQuestion() {
|
| 393 |
+
nextButtonContainer.classList.add('hidden');
|
| 394 |
+
feedbackElement.textContent = '';
|
| 395 |
+
feedbackElement.className = 'text-center text-xs mb-2';
|
| 396 |
+
characterElement.textContent = '🤔';
|
| 397 |
+
characterElement.classList.add('bounce-animation');
|
| 398 |
+
characterElement.style.animation = '';
|
| 399 |
+
|
| 400 |
+
let num1, num2, maxNumber;
|
| 401 |
+
|
| 402 |
+
// Set max number based on difficulty
|
| 403 |
+
switch(currentDifficulty) {
|
| 404 |
+
case 'easy':
|
| 405 |
+
maxNumber = 5;
|
| 406 |
+
break;
|
| 407 |
+
case 'medium':
|
| 408 |
+
maxNumber = 10;
|
| 409 |
+
break;
|
| 410 |
+
case 'hard':
|
| 411 |
+
maxNumber = 20;
|
| 412 |
+
break;
|
| 413 |
+
}
|
| 414 |
+
|
| 415 |
+
if (currentGameType === 'addition') {
|
| 416 |
+
num1 = Math.floor(Math.random() * maxNumber) + 1;
|
| 417 |
+
num2 = Math.floor(Math.random() * maxNumber) + 1;
|
| 418 |
+
correctAnswer = num1 + num2;
|
| 419 |
+
questionElement.textContent = `${num1} + ${num2} = ?`;
|
| 420 |
+
|
| 421 |
+
// Create visual aid for addition
|
| 422 |
+
visualAidElement.innerHTML = '';
|
| 423 |
+
for (let i = 0; i < num1; i++) {
|
| 424 |
+
visualAidElement.innerHTML += `<div class="visual-item w-6 h-6 bg-gradient-to-br from-blue-400 to-blue-500 rounded-md flex items-center justify-center text-white font-bold text-xs shadow-sm">🍎</div>`;
|
| 425 |
+
}
|
| 426 |
+
visualAidElement.innerHTML += `<div class="text-lg font-bold mx-1 text-gray-500">+</div>`;
|
| 427 |
+
for (let i = 0; i < num2; i++) {
|
| 428 |
+
visualAidElement.innerHTML += `<div class="visual-item w-6 h-6 bg-gradient-to-br from-red-400 to-red-500 rounded-md flex items-center justify-center text-white font-bold text-xs shadow-sm">🍐</div>`;
|
| 429 |
+
}
|
| 430 |
+
} else { // Subtraction
|
| 431 |
+
num1 = Math.floor(Math.random() * maxNumber) + 1;
|
| 432 |
+
num2 = Math.floor(Math.random() * num1) + 1;
|
| 433 |
+
correctAnswer = num1 - num2;
|
| 434 |
+
questionElement.textContent = `${num1} - ${num2} = ?`;
|
| 435 |
+
|
| 436 |
+
// Create visual aid for subtraction
|
| 437 |
+
visualAidElement.innerHTML = '';
|
| 438 |
+
for (let i = 0; i < num1; i++) {
|
| 439 |
+
visualAidElement.innerHTML += `<div class="visual-item w-6 h-6 bg-gradient-to-br from-green-400 to-green-500 rounded-md flex items-center justify-center text-white font-bold text-xs shadow-sm">🐶</div>`;
|
| 440 |
+
}
|
| 441 |
+
visualAidElement.innerHTML += `<div class="text-lg font-bold mx-1 text-gray-500">-</div>`;
|
| 442 |
+
for (let i = 0; i < num2; i++) {
|
| 443 |
+
visualAidElement.innerHTML += `<div class="visual-item w-6 h-6 bg-gradient-to-br from-yellow-400 to-yellow-500 rounded-md flex items-center justify-center text-white font-bold text-xs shadow-sm">🏠</div>`;
|
| 444 |
+
}
|
| 445 |
+
}
|
| 446 |
+
|
| 447 |
+
// Generate answer options
|
| 448 |
+
generateAnswerOptions(correctAnswer, maxNumber);
|
| 449 |
+
}
|
| 450 |
+
|
| 451 |
+
function generateAnswerOptions(correct, max) {
|
| 452 |
+
answerOptionsElement.innerHTML = '';
|
| 453 |
+
let options = [correct];
|
| 454 |
+
|
| 455 |
+
// Generate 3 incorrect answers
|
| 456 |
+
while (options.length < 4) {
|
| 457 |
+
let wrongAnswer;
|
| 458 |
+
if (currentGameType === 'addition') {
|
| 459 |
+
wrongAnswer = Math.floor(Math.random() * (max * 2)) + 1;
|
| 460 |
+
} else {
|
| 461 |
+
wrongAnswer = Math.floor(Math.random() * max) + 1;
|
| 462 |
+
}
|
| 463 |
+
|
| 464 |
+
if (wrongAnswer !== correct && !options.includes(wrongAnswer)) {
|
| 465 |
+
options.push(wrongAnswer);
|
| 466 |
+
}
|
| 467 |
+
}
|
| 468 |
+
|
| 469 |
+
// Shuffle options
|
| 470 |
+
options = shuffleArray(options);
|
| 471 |
+
|
| 472 |
+
// Create buttons for each option
|
| 473 |
+
options.forEach(option => {
|
| 474 |
+
const button = document.createElement('button');
|
| 475 |
+
button.className = 'answer-btn linear-card btn-transition py-2 rounded-lg hover:bg-gray-50/50 border border-gray-100 text-sm font-medium';
|
| 476 |
+
button.textContent = option;
|
| 477 |
+
button.onclick = () => checkAnswer(option);
|
| 478 |
+
answerOptionsElement.appendChild(button);
|
| 479 |
+
});
|
| 480 |
+
}
|
| 481 |
+
|
| 482 |
+
// Check answer
|
| 483 |
+
function checkAnswer(selectedAnswer) {
|
| 484 |
+
// Disable all answer buttons
|
| 485 |
+
const buttons = answerOptionsElement.querySelectorAll('button');
|
| 486 |
+
buttons.forEach(button => {
|
| 487 |
+
button.disabled = true;
|
| 488 |
+
button.classList.remove('hover:bg-gray-50/50');
|
| 489 |
+
if (parseInt(button.textContent) === correctAnswer) {
|
| 490 |
+
button.classList.add('bg-green-50/50', 'border-green-200', 'text-green-600');
|
| 491 |
+
} else if (parseInt(button.textContent) === selectedAnswer && selectedAnswer !== correctAnswer) {
|
| 492 |
+
button.classList.add('bg-rose-50/50', 'border-rose-200', 'text-rose-600');
|
| 493 |
+
} else {
|
| 494 |
+
button.classList.add('opacity-70');
|
| 495 |
+
}
|
| 496 |
+
});
|
| 497 |
+
|
| 498 |
+
if (selectedAnswer === correctAnswer) {
|
| 499 |
+
// Correct answer
|
| 500 |
+
score += 10;
|
| 501 |
+
updateScore();
|
| 502 |
+
feedbackElement.textContent = '✓ 太棒了!答案正确';
|
| 503 |
+
feedbackElement.classList.add('text-green-500');
|
| 504 |
+
characterElement.textContent = '🎉';
|
| 505 |
+
characterElement.classList.remove('bounce-animation');
|
| 506 |
+
characterElement.style.animation = 'none';
|
| 507 |
+
void characterElement.offsetWidth; // Trigger reflow
|
| 508 |
+
characterElement.style.animation = 'bounce 0.5s alternate infinite ease-in-out';
|
| 509 |
+
createRisingCelebration();
|
| 510 |
+
|
| 511 |
+
buttons.forEach(button => {
|
| 512 |
+
if (parseInt(button.textContent) === correctAnswer) {
|
| 513 |
+
button.classList.add('animate-pulse');
|
| 514 |
+
setTimeout(() => button.classList.remove('animate-pulse'), 1500);
|
| 515 |
+
}
|
| 516 |
+
});
|
| 517 |
+
} else {
|
| 518 |
+
// Wrong answer
|
| 519 |
+
feedbackElement.textContent = `✕ 正确答案是 ${correctAnswer}`;
|
| 520 |
+
feedbackElement.classList.add('text-rose-500');
|
| 521 |
+
characterElement.textContent = '😢';
|
| 522 |
+
characterElement.style.animation = 'bounce 0.2s reverse 2';
|
| 523 |
+
}
|
| 524 |
+
|
| 525 |
+
nextButtonContainer.classList.remove('hidden');
|
| 526 |
+
}
|
| 527 |
+
|
| 528 |
+
// Create celebration effects (bottom-up animation)
|
| 529 |
+
function createRisingCelebration() {
|
| 530 |
+
const emojis = ['🎉', '✨', '🌟', '🎈', '🥳', '👍', '👏'];
|
| 531 |
+
const colors = ['#3B82F6', '#10B981', '#F59E0B', '#EF4444', '#8B5CF6', '#EC4899'];
|
| 532 |
+
|
| 533 |
+
for (let i = 0; i < 15; i++) {
|
| 534 |
+
setTimeout(() => {
|
| 535 |
+
const element = document.createElement('div');
|
| 536 |
+
element.className = 'celebration-item text-2xl';
|
| 537 |
+
element.textContent = emojis[Math.floor(Math.random() * emojis.length)];
|
| 538 |
+
|
| 539 |
+
// Random left position
|
| 540 |
+
const randomLeft = 5 + Math.random() * 90;
|
| 541 |
+
element.style.left = `${randomLeft}%`;
|
| 542 |
+
|
| 543 |
+
// Random delay and duration
|
| 544 |
+
const randomDelay = Math.random() * 0.5;
|
| 545 |
+
const randomDuration = 1 + Math.random() * 1;
|
| 546 |
+
|
| 547 |
+
// Random color
|
| 548 |
+
const randomColor = colors[Math.floor(Math.random() * colors.length)];
|
| 549 |
+
element.style.color = randomColor;
|
| 550 |
+
|
| 551 |
+
element.style.animation = `celebrationRise ${randomDuration}s ${randomDelay}s forwards`;
|
| 552 |
+
|
| 553 |
+
document.body.appendChild(element);
|
| 554 |
+
|
| 555 |
+
// Remove element after animation
|
| 556 |
+
setTimeout(() => {
|
| 557 |
+
element.remove();
|
| 558 |
+
}, (randomDelay + randomDuration) * 1000);
|
| 559 |
+
}, Math.random() * 300);
|
| 560 |
+
}
|
| 561 |
+
}
|
| 562 |
+
|
| 563 |
+
// Next question
|
| 564 |
+
function nextQuestion() {
|
| 565 |
+
generateQuestion();
|
| 566 |
+
}
|
| 567 |
+
|
| 568 |
+
// End game
|
| 569 |
+
function endGame() {
|
| 570 |
+
clearInterval(timer);
|
| 571 |
+
gameArea.classList.add('hidden');
|
| 572 |
+
resultsScreen.classList.remove('hidden');
|
| 573 |
+
finalScoreElement.textContent = score;
|
| 574 |
+
}
|
| 575 |
+
|
| 576 |
+
// Restart game
|
| 577 |
+
function restartGame() {
|
| 578 |
+
resultsScreen.classList.add('hidden');
|
| 579 |
+
startGame(currentGameType);
|
| 580 |
+
}
|
| 581 |
+
|
| 582 |
+
// Back to menu
|
| 583 |
+
function backToMenu() {
|
| 584 |
+
appElement.classList.remove('game-mode');
|
| 585 |
+
resultsScreen.classList.add('hidden');
|
| 586 |
+
gameArea.classList.add('hidden');
|
| 587 |
+
gameSelection.classList.remove('hidden');
|
| 588 |
+
}
|
| 589 |
+
|
| 590 |
+
// Update score
|
| 591 |
+
function updateScore() {
|
| 592 |
+
scoreElement.textContent = score;
|
| 593 |
+
}
|
| 594 |
+
|
| 595 |
+
// Utility functions
|
| 596 |
+
function shuffleArray(array) {
|
| 597 |
+
for (let i = array.length - 1; i > 0; i--) {
|
| 598 |
+
const j = Math.floor(Math.random() * (i + 1));
|
| 599 |
+
[array[i], array[j]] = [array[j], array[i]];
|
| 600 |
+
}
|
| 601 |
+
return array;
|
| 602 |
+
}
|
| 603 |
+
</script>
|
| 604 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - <a href="https://enzostvs-deepsite.hf.space?remix=busyhe/math-prodigy" style="color: #fff;text-decoration: underline;" target="_blank" >🧬 Remix</a></p></body>
|
| 605 |
+
</html>
|