-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
206 lines (179 loc) · 7.73 KB
/
index.html
File metadata and controls
206 lines (179 loc) · 7.73 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FunWebGames - Play & Learn!</title>
<link rel="stylesheet" href="css/shared.css">
<meta name="description" content="10 fun educational games for children aged 5-7">
<link rel="manifest" href="manifest.json">
<meta name="theme-color" content="#FF6B6B">
<link rel="apple-touch-icon" href="icons/icon-192x192.png">
</head>
<body>
<!-- Skip Link for Accessibility -->
<a href="#game-grid" class="skip-link">Skip to games</a>
<!-- Install Prompt (hidden by default) -->
<div id="install-prompt" class="install-prompt hidden">
<p>📲 Install FunWebGames to play offline!</p>
<button class="btn btn-primary" id="install-btn">Install</button>
<button class="btn btn-secondary" id="dismiss-install">Not Now</button>
</div>
<!-- Page Header -->
<header class="page-header">
<h1 class="page-header__title">🎮 FunWebGames 🎮</h1>
<p class="page-header__subtitle">Pick a game and have fun!</p>
</header>
<!-- Game Grid -->
<main class="game-grid">
<!-- Game 1: Color Match Memory -->
<a href="games/color-match/index.html" class="game-card" style="background: linear-gradient(135deg, #FFF0F5 0%, #F0FFF0 100%);">
<div class="game-card__thumbnail">🎨</div>
<div class="game-card__emoji">🔵</div>
<h2 class="game-card__name">Color Match</h2>
</a>
<!-- Game 2: Animal Puzzle -->
<a href="games/animal-puzzle/index.html" class="game-card" style="background: linear-gradient(135deg, #F0F8FF 0%, #FFF0F5 100%);">
<div class="game-card__thumbnail">🧩</div>
<div class="game-card__emoji">🐱</div>
<h2 class="game-card__name">Animal Puzzle</h2>
</a>
<!-- Game 3: Bubble Pop -->
<a href="games/bubble-pop/index.html" class="game-card" style="background: linear-gradient(135deg, #FFF9F0 0%, #F0F8FF 100%);">
<div class="game-card__thumbnail">🫧</div>
<div class="game-card__emoji">🔢</div>
<h2 class="game-card__name">Bubble Pop</h2>
</a>
<!-- Game 4: Shape Builder -->
<a href="games/shape-builder/index.html" class="game-card" style="background: linear-gradient(135deg, #F0FFF0 0%, #FFF9F0 100%);">
<div class="game-card__thumbnail">🔷</div>
<div class="game-card__emoji">🏠</div>
<h2 class="game-card__name">Shape Builder</h2>
</a>
<!-- Game 5: Counting Garden -->
<a href="games/counting-garden/index.html" class="game-card" style="background: linear-gradient(135deg, #FFF0F5 0%, #F0FFF0 100%);">
<div class="game-card__thumbnail">🌸</div>
<div class="game-card__emoji">🦋</div>
<h2 class="game-card__name">Counting Garden</h2>
</a>
<!-- Game 6: Letter Explorer -->
<a href="games/letter-explorer/index.html" class="game-card" style="background: linear-gradient(135deg, #F0F8FF 0%, #FFF0F5 100%);">
<div class="game-card__thumbnail">🔤</div>
<div class="game-card__emoji">🅰️</div>
<h2 class="game-card__name">Letter Explorer</h2>
</a>
<!-- Game 7: Music Maker -->
<a href="games/music-maker/index.html" class="game-card" style="background: linear-gradient(135deg, #FFF9F0 0%, #F0F8FF 100%);">
<div class="game-card__thumbnail">🎵</div>
<div class="game-card__emoji">🎹</div>
<h2 class="game-card__name">Music Maker</h2>
</a>
<!-- Game 8: Maze Runner -->
<a href="games/maze-runner/index.html" class="game-card" style="background: linear-gradient(135deg, #F0FFF0 0%, #FFF9F0 100%);">
<div class="game-card__thumbnail">🗺️</div>
<div class="game-card__emoji">🐰</div>
<h2 class="game-card__name">Maze Runner</h2>
</a>
<!-- Game 9: Star Catcher -->
<a href="games/star-catcher/index.html" class="game-card" style="background: linear-gradient(135deg, #FFF0F5 0%, #F0F8FF 100%);">
<div class="game-card__thumbnail">⭐</div>
<div class="game-card__emoji">🌙</div>
<h2 class="game-card__name">Star Catcher</h2>
</a>
<!-- Game 10: Dress Up -->
<a href="games/dress-up/index.html" class="game-card" style="background: linear-gradient(135deg, #F0F8FF 0%, #FFF0F5 100%);">
<div class="game-card__thumbnail">👗</div>
<div class="game-card__emoji">🎀</div>
<h2 class="game-card__name">Dress Up</h2>
</a>
</main>
<!-- Footer with High Score Reset -->
<footer class="page-footer">
<button id="reset-scores-btn" class="btn btn--small btn--secondary">🔄 Reset Scores</button>
</footer>
<script src="js/highscore.js"></script>
<script>
// Add playful sound effects on card click (GR-3: Audio & Feedback)
document.querySelectorAll('.game-card').forEach(card => {
card.addEventListener('click', (e) => {
// Create a soft "pop" sound using Web Audio API
try {
const audioContext = new (window.AudioContext || window.webkitAudioContext)();
const oscillator = audioContext.createOscillator();
const gainNode = audioContext.createGain();
oscillator.connect(gainNode);
gainNode.connect(audioContext.destination);
oscillator.frequency.value = 600;
oscillator.type = 'sine';
gainNode.gain.setValueAtTime(0.3, audioContext.currentTime);
gainNode.gain.exponentialRampToValueAtTime(0.01, audioContext.currentTime + 0.2);
oscillator.start(audioContext.currentTime);
oscillator.stop(audioContext.currentTime + 0.2);
} catch (err) {
// Audio not supported, continue silently
}
});
});
// Reset Scores Button
const resetScoresBtn = document.getElementById('reset-scores-btn');
if (resetScoresBtn) {
resetScoresBtn.addEventListener('click', () => {
const scores = HighScore.getAll();
const scoreCount = Object.keys(scores).length;
if (scoreCount === 0) {
alert('No scores to reset! 🎮');
return;
}
const confirmed = confirm('Reset all high scores? This cannot be undone.');
if (confirmed) {
HighScore.reset();
alert('All scores reset! 🎉');
}
});
}
// Service Worker Registration
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/sw.js')
.then((registration) => {
console.log('[SW] Registration successful:', registration.scope);
})
.catch((error) => {
console.log('[SW] Registration failed:', error);
});
});
}
// Install Prompt
let deferredPrompt;
const installPrompt = document.getElementById('install-prompt');
const installBtn = document.getElementById('install-btn');
const dismissInstall = document.getElementById('dismiss-install');
window.addEventListener('beforeinstallprompt', (e) => {
e.preventDefault();
deferredPrompt = e;
installPrompt.classList.remove('hidden');
});
if (installBtn) {
installBtn.addEventListener('click', async () => {
if (deferredPrompt) {
deferredPrompt.prompt();
const { outcome } = await deferredPrompt.userChoice;
console.log('[Install] User choice:', outcome);
deferredPrompt = null;
installPrompt.classList.add('hidden');
}
});
}
if (dismissInstall) {
dismissInstall.addEventListener('click', () => {
installPrompt.classList.add('hidden');
});
}
window.addEventListener('appinstalled', () => {
console.log('[Install] App installed');
installPrompt.classList.add('hidden');
deferredPrompt = null;
});
</script>
</body>
</html>