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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
</html>
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>Pixel Hamster Care</title>
|
7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
8 |
+
<style>
|
9 |
+
@keyframes hamsterWalk {
|
10 |
+
0%, 100% { transform: translateX(0) rotate(0deg); }
|
11 |
+
25% { transform: translateX(5px) rotate(5deg); }
|
12 |
+
75% { transform: translateX(-5px) rotate(-5deg); }
|
13 |
+
}
|
14 |
+
|
15 |
+
@keyframes hamsterEat {
|
16 |
+
0%, 100% { transform: scale(1); }
|
17 |
+
50% { transform: scale(1.05) translateY(-3px); }
|
18 |
+
}
|
19 |
+
|
20 |
+
@keyframes hamsterClean {
|
21 |
+
0%, 100% { transform: rotate(0deg); }
|
22 |
+
25% { transform: rotate(15deg); }
|
23 |
+
75% { transform: rotate(-15deg); }
|
24 |
+
}
|
25 |
+
|
26 |
+
@keyframes hamsterHappy {
|
27 |
+
0%, 100% { transform: translateY(0); }
|
28 |
+
50% { transform: translateY(-5px); }
|
29 |
+
}
|
30 |
+
|
31 |
+
.hamster-animation-walk {
|
32 |
+
animation: hamsterWalk 0.8s infinite;
|
33 |
+
}
|
34 |
+
|
35 |
+
.hamster-animation-eat {
|
36 |
+
animation: hamsterEat 0.5s infinite;
|
37 |
+
}
|
38 |
+
|
39 |
+
.hamster-animation-clean {
|
40 |
+
animation: hamsterClean 0.6s infinite;
|
41 |
+
}
|
42 |
+
|
43 |
+
.hamster-animation-happy {
|
44 |
+
animation: hamsterHappy 0.7s infinite;
|
45 |
+
}
|
46 |
+
|
47 |
+
.pixel-art {
|
48 |
+
image-rendering: pixelated;
|
49 |
+
image-rendering: -moz-crisp-edges;
|
50 |
+
image-rendering: crisp-edges;
|
51 |
+
}
|
52 |
+
|
53 |
+
.progress-bar {
|
54 |
+
transition: width 0.5s ease-in-out;
|
55 |
+
}
|
56 |
+
|
57 |
+
.action-button:hover {
|
58 |
+
transform: translateY(-2px);
|
59 |
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
60 |
+
}
|
61 |
+
|
62 |
+
.action-button:active {
|
63 |
+
transform: translateY(0);
|
64 |
+
}
|
65 |
+
|
66 |
+
.notification {
|
67 |
+
animation: fadeInOut 2s ease-in-out;
|
68 |
+
opacity: 0;
|
69 |
+
}
|
70 |
+
|
71 |
+
@keyframes fadeInOut {
|
72 |
+
0%, 100% { opacity: 0; transform: translateY(10px); }
|
73 |
+
20%, 80% { opacity: 1; transform: translateY(0); }
|
74 |
+
}
|
75 |
+
</style>
|
76 |
+
</head>
|
77 |
+
<body class="bg-amber-50 min-h-screen flex flex-col items-center justify-center p-4">
|
78 |
+
<div class="max-w-md w-full bg-amber-100 rounded-2xl shadow-xl overflow-hidden border-4 border-amber-300">
|
79 |
+
<div class="bg-amber-300 p-4 flex justify-between items-center">
|
80 |
+
<h1 class="text-2xl font-bold text-amber-800">Pixel Hamster Care</h1>
|
81 |
+
<div class="text-amber-700 font-mono">Day: <span id="day-counter">1</span></div>
|
82 |
+
</div>
|
83 |
+
|
84 |
+
<div class="p-6 flex flex-col items-center">
|
85 |
+
<!-- Status bars -->
|
86 |
+
<div class="w-full mb-6 space-y-2">
|
87 |
+
<div class="flex items-center">
|
88 |
+
<span class="w-20 text-amber-900 font-medium">Hunger:</span>
|
89 |
+
<div class="flex-1 h-4 bg-amber-200 rounded-full overflow-hidden">
|
90 |
+
<div id="hunger-bar" class="h-full bg-red-500 progress-bar" style="width: 100%"></div>
|
91 |
+
</div>
|
92 |
+
</div>
|
93 |
+
<div class="flex items-center">
|
94 |
+
<span class="w-20 text-amber-900 font-medium">Happiness:</span>
|
95 |
+
<div class="flex-1 h-4 bg-amber-200 rounded-full overflow-hidden">
|
96 |
+
<div id="happiness-bar" class="h-full bg-green-500 progress-bar" style="width: 100%"></div>
|
97 |
+
</div>
|
98 |
+
</div>
|
99 |
+
<div class="flex items-center">
|
100 |
+
<span class="w-20 text-amber-900 font-medium">Cleanliness:</span>
|
101 |
+
<div class="flex-1 h-4 bg-amber-200 rounded-full overflow-hidden">
|
102 |
+
<div id="clean-bar" class="h-full bg-blue-500 progress-bar" style="width: 100%"></div>
|
103 |
+
</div>
|
104 |
+
</div>
|
105 |
+
</div>
|
106 |
+
|
107 |
+
<!-- Hamster display -->
|
108 |
+
<div class="relative w-48 h-48 bg-amber-200 rounded-xl border-2 border-amber-300 flex items-center justify-center mb-6">
|
109 |
+
<div id="hamster-container" class="hamster-animation-walk">
|
110 |
+
<!-- Pixel art hamster SVG -->
|
111 |
+
<svg id="hamster" class="pixel-art" width="120" height="120" viewBox="0 0 120 120">
|
112 |
+
<!-- Body -->
|
113 |
+
<rect x="40" y="50" width="40" height="30" fill="#D1A684" />
|
114 |
+
<rect x="35" y="45" width="10" height="10" fill="#D1A684" />
|
115 |
+
<rect x="75" y="45" width="10" height="10" fill="#D1A684" />
|
116 |
+
|
117 |
+
<!-- Head -->
|
118 |
+
<rect x="45" y="35" width="30" height="20" fill="#D1A684" />
|
119 |
+
|
120 |
+
<!-- Ears -->
|
121 |
+
<rect x="40" y="30" width="10" height="10" fill="#D1A684" />
|
122 |
+
<rect x="70" y="30" width="10" height="10" fill="#D1A684" />
|
123 |
+
<rect x="42" y="32" width="6" height="6" fill="#F5D5B9" />
|
124 |
+
<rect x="72" y="32" width="6" height="6" fill="#F5D5B9" />
|
125 |
+
|
126 |
+
<!-- Eyes -->
|
127 |
+
<rect x="50" y="40" width="5" height="5" fill="#333" />
|
128 |
+
<rect x="65" y="40" width="5" height="5" fill="#333" />
|
129 |
+
|
130 |
+
<!-- Nose -->
|
131 |
+
<rect x="45" y="45" width="5" height="5" fill="#333" />
|
132 |
+
<rect x="70" y="45" width="5" height="5" fill="#333" />
|
133 |
+
|
134 |
+
<!-- Cheeks -->
|
135 |
+
<rect x="45" y="50" width="10" height="5" fill="#F5A9A9" />
|
136 |
+
<rect x="65" y="50" width="10" height="5" fill="#F5A9A9" />
|
137 |
+
|
138 |
+
<!-- Mouth -->
|
139 |
+
<rect x="55" y="50" width="10" height="5" fill="#333" />
|
140 |
+
|
141 |
+
<!-- Arms -->
|
142 |
+
<rect x="35" y="55" width="5" height="15" fill="#D1A684" />
|
143 |
+
<rect x="80" y="55" width="5" height="15" fill="#D1A684" />
|
144 |
+
|
145 |
+
<!-- Legs -->
|
146 |
+
<rect x="45" y="80" width="10" height="5" fill="#D1A684" />
|
147 |
+
<rect x="65" y="80" width="10" height="5" fill="#D1A684" />
|
148 |
+
|
149 |
+
<!-- Tail -->
|
150 |
+
<rect x="30" y="55" width="10" height="5" fill="#D1A684" />
|
151 |
+
</svg>
|
152 |
+
</div>
|
153 |
+
|
154 |
+
<!-- Cage elements -->
|
155 |
+
<div class="absolute bottom-2 left-2 w-16 h-8 bg-amber-400 rounded"></div>
|
156 |
+
<div class="absolute top-2 right-2 w-12 h-6 bg-amber-500 rounded"></div>
|
157 |
+
|
158 |
+
<!-- Notification -->
|
159 |
+
<div id="notification" class="notification absolute top-0 left-0 right-0 bg-amber-400 text-amber-900 text-center py-1 font-medium hidden"></div>
|
160 |
+
</div>
|
161 |
+
|
162 |
+
<!-- Action buttons -->
|
163 |
+
<div class="grid grid-cols-3 gap-4 w-full">
|
164 |
+
<button id="feed-btn" class="action-button bg-red-400 hover:bg-red-500 text-white font-bold py-3 px-4 rounded-lg transition-all flex flex-col items-center">
|
165 |
+
<svg class="w-8 h-8 mb-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
166 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
|
167 |
+
</svg>
|
168 |
+
Feed
|
169 |
+
</button>
|
170 |
+
<button id="play-btn" class="action-button bg-green-400 hover:bg-green-500 text-white font-bold py-3 px-4 rounded-lg transition-all flex flex-col items-center">
|
171 |
+
<svg class="w-8 h-8 mb-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
172 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"></path>
|
173 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
|
174 |
+
</svg>
|
175 |
+
Play
|
176 |
+
</button>
|
177 |
+
<button id="clean-btn" class="action-button bg-blue-400 hover:bg-blue-500 text-white font-bold py-3 px-4 rounded-lg transition-all flex flex-col items-center">
|
178 |
+
<svg class="w-8 h-8 mb-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
179 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"></path>
|
180 |
+
</svg>
|
181 |
+
Clean
|
182 |
+
</button>
|
183 |
+
</div>
|
184 |
+
</div>
|
185 |
+
|
186 |
+
<div class="bg-amber-200 p-4 text-center text-amber-800">
|
187 |
+
<p id="hamster-message">Hello! I'm your new hamster friend!</p>
|
188 |
+
</div>
|
189 |
+
</div>
|
190 |
+
|
191 |
+
<script>
|
192 |
+
// Game state
|
193 |
+
const state = {
|
194 |
+
hunger: 100,
|
195 |
+
happiness: 100,
|
196 |
+
cleanliness: 100,
|
197 |
+
day: 1,
|
198 |
+
isSleeping: false,
|
199 |
+
currentAnimation: 'walk',
|
200 |
+
messages: [
|
201 |
+
"Hello! I'm your new hamster friend!",
|
202 |
+
"I'm getting hungry...",
|
203 |
+
"Play with me!",
|
204 |
+
"My cage is getting dirty...",
|
205 |
+
"I love you!",
|
206 |
+
"Zzz... zzz...",
|
207 |
+
"That was fun!",
|
208 |
+
"Yummy!",
|
209 |
+
"Ahh, so clean now!",
|
210 |
+
"I'm bored...",
|
211 |
+
"Wheel time!"
|
212 |
+
]
|
213 |
+
};
|
214 |
+
|
215 |
+
// DOM elements
|
216 |
+
const hungerBar = document.getElementById('hunger-bar');
|
217 |
+
const happinessBar = document.getElementById('happiness-bar');
|
218 |
+
const cleanBar = document.getElementById('clean-bar');
|
219 |
+
const dayCounter = document.getElementById('day-counter');
|
220 |
+
const hamsterContainer = document.getElementById('hamster-container');
|
221 |
+
const hamsterMessage = document.getElementById('hamster-message');
|
222 |
+
const notification = document.getElementById('notification');
|
223 |
+
const feedBtn = document.getElementById('feed-btn');
|
224 |
+
const playBtn = document.getElementById('play-btn');
|
225 |
+
const cleanBtn = document.getElementById('clean-btn');
|
226 |
+
|
227 |
+
// Game loop
|
228 |
+
let gameLoop = setInterval(() => {
|
229 |
+
// Decrease stats over time
|
230 |
+
state.hunger = Math.max(0, state.hunger - 1);
|
231 |
+
state.happiness = Math.max(0, state.happiness - 0.8);
|
232 |
+
state.cleanliness = Math.max(0, state.cleanliness - 0.5);
|
233 |
+
|
234 |
+
// Update UI
|
235 |
+
updateBars();
|
236 |
+
|
237 |
+
// Random hamster actions
|
238 |
+
if (Math.random() < 0.1) {
|
239 |
+
randomHamsterAction();
|
240 |
+
}
|
241 |
+
|
242 |
+
// Check for day change
|
243 |
+
if (state.hunger <= 0 || state.happiness <= 0 || state.cleanliness <= 0) {
|
244 |
+
showNotification("Your hamster ran away! Starting new day...");
|
245 |
+
resetDay();
|
246 |
+
}
|
247 |
+
|
248 |
+
// Random messages
|
249 |
+
if (Math.random() < 0.2) {
|
250 |
+
showRandomMessage();
|
251 |
+
}
|
252 |
+
|
253 |
+
}, 2000);
|
254 |
+
|
255 |
+
// Update status bars
|
256 |
+
function updateBars() {
|
257 |
+
hungerBar.style.width = `${state.hunger}%`;
|
258 |
+
happinessBar.style.width = `${state.happiness}%`;
|
259 |
+
cleanBar.style.width = `${state.cleanliness}%`;
|
260 |
+
|
261 |
+
// Change colors based on level
|
262 |
+
hungerBar.className = `h-full progress-bar ${state.hunger > 50 ? 'bg-red-500' : state.hunger > 20 ? 'bg-orange-500' : 'bg-yellow-300'}`;
|
263 |
+
happinessBar.className = `h-full progress-bar ${state.happiness > 50 ? 'bg-green-500' : state.happiness > 20 ? 'bg-yellow-500' : 'bg-red-400'}`;
|
264 |
+
cleanBar.className = `h-full progress-bar ${state.cleanliness > 50 ? 'bg-blue-500' : state.cleanliness > 20 ? 'bg-purple-400' : 'bg-gray-400'}`;
|
265 |
+
}
|
266 |
+
|
267 |
+
// Random hamster animation
|
268 |
+
function randomHamsterAction() {
|
269 |
+
const actions = ['walk', 'sleep', 'happy'];
|
270 |
+
const randomAction = actions[Math.floor(Math.random() * actions.length)];
|
271 |
+
|
272 |
+
changeAnimation(randomAction);
|
273 |
+
|
274 |
+
if (randomAction === 'sleep') {
|
275 |
+
hamsterMessage.textContent = "Zzz... zzz...";
|
276 |
+
}
|
277 |
+
}
|
278 |
+
|
279 |
+
// Change hamster animation
|
280 |
+
function changeAnimation(animation) {
|
281 |
+
hamsterContainer.classList.remove(
|
282 |
+
'hamster-animation-walk',
|
283 |
+
'hamster-animation-eat',
|
284 |
+
'hamster-animation-clean',
|
285 |
+
'hamster-animation-happy'
|
286 |
+
);
|
287 |
+
|
288 |
+
state.currentAnimation = animation;
|
289 |
+
|
290 |
+
switch(animation) {
|
291 |
+
case 'walk':
|
292 |
+
hamsterContainer.classList.add('hamster-animation-walk');
|
293 |
+
break;
|
294 |
+
case 'eat':
|
295 |
+
hamsterContainer.classList.add('hamster-animation-eat');
|
296 |
+
break;
|
297 |
+
case 'clean':
|
298 |
+
hamsterContainer.classList.add('hamster-animation-clean');
|
299 |
+
break;
|
300 |
+
case 'happy':
|
301 |
+
hamsterContainer.classList.add('hamster-animation-happy');
|
302 |
+
break;
|
303 |
+
case 'sleep':
|
304 |
+
// No animation for sleep, just static
|
305 |
+
break;
|
306 |
+
}
|
307 |
+
}
|
308 |
+
|
309 |
+
// Show random message
|
310 |
+
function showRandomMessage() {
|
311 |
+
if (state.hunger < 30) {
|
312 |
+
hamsterMessage.textContent = "I'm so hungry!";
|
313 |
+
} else if (state.happiness < 30) {
|
314 |
+
hamsterMessage.textContent = "I'm bored... play with me!";
|
315 |
+
} else if (state.cleanliness < 30) {
|
316 |
+
hamsterMessage.textContent = "My cage is dirty!";
|
317 |
+
} else {
|
318 |
+
const randomIndex = Math.floor(Math.random() * state.messages.length);
|
319 |
+
hamsterMessage.textContent = state.messages[randomIndex];
|
320 |
+
}
|
321 |
+
}
|
322 |
+
|
323 |
+
// Show notification
|
324 |
+
function showNotification(message) {
|
325 |
+
notification.textContent = message;
|
326 |
+
notification.classList.remove('hidden');
|
327 |
+
notification.style.animation = 'none';
|
328 |
+
void notification.offsetWidth; // Trigger reflow
|
329 |
+
notification.style.animation = 'fadeInOut 2s ease-in-out';
|
330 |
+
|
331 |
+
setTimeout(() => {
|
332 |
+
notification.classList.add('hidden');
|
333 |
+
}, 2000);
|
334 |
+
}
|
335 |
+
|
336 |
+
// Reset day
|
337 |
+
function resetDay() {
|
338 |
+
state.hunger = 100;
|
339 |
+
state.happiness = 100;
|
340 |
+
state.cleanliness = 100;
|
341 |
+
state.day++;
|
342 |
+
dayCounter.textContent = state.day;
|
343 |
+
updateBars();
|
344 |
+
changeAnimation('happy');
|
345 |
+
hamsterMessage.textContent = "Yay! A new day!";
|
346 |
+
}
|
347 |
+
|
348 |
+
// Event listeners
|
349 |
+
feedBtn.addEventListener('click', () => {
|
350 |
+
state.hunger = Math.min(100, state.hunger + 25);
|
351 |
+
updateBars();
|
352 |
+
changeAnimation('eat');
|
353 |
+
showNotification("Nom nom nom!");
|
354 |
+
setTimeout(() => changeAnimation('happy'), 1500);
|
355 |
+
});
|
356 |
+
|
357 |
+
playBtn.addEventListener('click', () => {
|
358 |
+
state.happiness = Math.min(100, state.happiness + 25);
|
359 |
+
updateBars();
|
360 |
+
changeAnimation('happy');
|
361 |
+
showNotification("Wheee! So fun!");
|
362 |
+
});
|
363 |
+
|
364 |
+
cleanBtn.addEventListener('click', () => {
|
365 |
+
state.cleanliness = Math.min(100, state.cleanliness + 25);
|
366 |
+
updateBars();
|
367 |
+
changeAnimation('clean');
|
368 |
+
showNotification("Ahh, so fresh!");
|
369 |
+
setTimeout(() => changeAnimation('happy'), 1500);
|
370 |
+
});
|
371 |
+
|
372 |
+
// Initial setup
|
373 |
+
updateBars();
|
374 |
+
</script>
|
375 |
+
</body>
|
376 |
</html>
|