import { useState } from 'react'; import { Card, CardContent } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; import { motion } from 'framer-motion';
export default function GameEdukasi() { const [score, setScore] = useState(0); const [question, setQuestion] = useState(generateQuestion()); const [answer, setAnswer] = useState('');
function generateQuestion() { const a = Math.floor(Math.random() * 10) + 1; const b = Math.floor(Math.random() * 10) + 1; return { text: ${a} + ${b} = ?, correct: a + b }; }
function checkAnswer() { if (parseInt(answer) === question.correct) { setScore(score + 1); } setQuestion(generateQuestion()); setAnswer(''); }
return (
<motion.h1 initial={{ y: -20, opacity: 0 }} animate={{ y: 0, opacity: 1 }} className="text-4xl font-bold mb-6 text-blue-700"> 🎮 Game Edukasi Matematika