File size: 2,842 Bytes
eea8542
 
e48853f
eea8542
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e48853f
 
 
eea8542
 
 
 
 
 
 
e48853f
eea8542
e48853f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76

// Initialize animations and effects
document.addEventListener('DOMContentLoaded', function() {
    // Add sparkle effects randomly to magic elements
    const magicElements = document.querySelectorAll('.sparkle, .btn-magic');
    magicElements.forEach(el => {
        el.addEventListener('mouseenter', () => {
            const sparkles = ['✨', '⭐', '🌟', '💫'];
            const randomSparkle = sparkles[Math.floor(Math.random() * sparkles.length)];
            const spark = document.createElement('span');
            spark.textContent = randomSparkle;
            spark.style.position = 'absolute';
            spark.style.animation = 'sparkle 1s ease-out';
            spark.style.pointerEvents = 'none';
            spark.style.left = `${Math.random() * 100}%`;
            spark.style.top = `${Math.random() * 100}%`;
            el.appendChild(spark);
            setTimeout(() => spark.remove(), 1000);
        });
    });
    
    // Add floating effect to hero images
    const floatElements = document.querySelectorAll('.float-animation');
    floatElements.forEach(el => {
        el.style.animationDelay = `${Math.random() * 2}s`;
        el.style.animationDuration = `${3 + Math.random() * 2}s`;
    });
    
    // Age group selection animation
const ageGroups = document.querySelectorAll('[href*="exercices.html?age="]');
    ageGroups.forEach(group => {
        group.addEventListener('mouseenter', function() {
            this.querySelector('div').classList.add('animate-bounce');
        });
        group.addEventListener('mouseleave', function() {
            this.querySelector('div').classList.remove('animate-bounce');
        });
    });
});

// Simple math game function for demonstration
function startMathGame(difficulty) {
    const operations = {
        easy: ['+', '-'],
        medium: ['+', '-', '×'],
        hard: ['+', '-', '×', '÷']
    };
    
    const num1 = Math.floor(Math.random() * (difficulty === 'easy' ? 10 : 20)) + 1;
    const num2 = Math.floor(Math.random() * (difficulty === 'easy' ? 10 : 20)) + 1;
    const operation = operations[difficulty][Math.floor(Math.random() * operations[difficulty].length)];
    
    let question, answer;
    
    switch(operation) {
        case '+':
            question = `${num1} + ${num2}`;
            answer = num1 + num2;
            break;
        case '-':
            question = `${Math.max(num1, num2)} - ${Math.min(num1, num2)}`;
            answer = Math.max(num1, num2) - Math.min(num1, num2);
            break;
        case '×':
            question = `${num1} × ${num2}`;
            answer = num1 * num2;
            break;
        case '÷':
            const product = num1 * num2;
            question = `${product} ÷ ${num1}`;
            answer = num2;
            break;
    }
    
    return { question, answer };
}