Spaces:
Running
Running
Add 2 files
Browse files- README.md +7 -5
- index.html +462 -19
README.md
CHANGED
@@ -1,10 +1,12 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
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: blob-hunter
|
3 |
+
emoji: 🐳
|
4 |
+
colorFrom: yellow
|
5 |
+
colorTo: yellow
|
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,462 @@
|
|
1 |
-
<!
|
2 |
-
<html>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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>Blob Hunter: Galactic Pursuit 🚀</title>
|
7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
9 |
+
<style>
|
10 |
+
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&family=Press+Start+2P&display=swap');
|
11 |
+
|
12 |
+
body {
|
13 |
+
background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
|
14 |
+
font-family: 'Orbitron', sans-serif;
|
15 |
+
min-height: 100vh;
|
16 |
+
margin: 0;
|
17 |
+
overflow-x: hidden;
|
18 |
+
color: #00fffc;
|
19 |
+
}
|
20 |
+
|
21 |
+
.game-container {
|
22 |
+
box-shadow: 0 0 30px rgba(0, 255, 252, 0.3);
|
23 |
+
border: 2px solid #00fffc;
|
24 |
+
border-radius: 8px;
|
25 |
+
background: rgba(15, 12, 41, 0.8);
|
26 |
+
position: relative;
|
27 |
+
overflow: hidden;
|
28 |
+
}
|
29 |
+
|
30 |
+
.game-container::before {
|
31 |
+
content: '';
|
32 |
+
position: absolute;
|
33 |
+
top: 0;
|
34 |
+
left: 0;
|
35 |
+
right: 0;
|
36 |
+
bottom: 0;
|
37 |
+
background:
|
38 |
+
radial-gradient(circle at 20% 30%, rgba(0, 255, 252, 0.1) 0%, transparent 50%),
|
39 |
+
radial-gradient(circle at 80% 70%, rgba(0, 255, 252, 0.1) 0%, transparent 50%);
|
40 |
+
pointer-events: none;
|
41 |
+
}
|
42 |
+
|
43 |
+
canvas {
|
44 |
+
display: block;
|
45 |
+
margin: 0 auto;
|
46 |
+
border: 1px solid rgba(0, 255, 252, 0.3);
|
47 |
+
}
|
48 |
+
|
49 |
+
.score-display {
|
50 |
+
font-family: 'Press Start 2P', cursive;
|
51 |
+
text-shadow: 0 0 10px #00fffc;
|
52 |
+
letter-spacing: 2px;
|
53 |
+
}
|
54 |
+
|
55 |
+
.game-over {
|
56 |
+
background: rgba(15, 12, 41, 0.95);
|
57 |
+
border: 2px solid #00fffc;
|
58 |
+
box-shadow: 0 0 30px rgba(0, 255, 252, 0.5);
|
59 |
+
}
|
60 |
+
|
61 |
+
.btn-sci-fi {
|
62 |
+
background: linear-gradient(45deg, #00fffc, #0088ff);
|
63 |
+
border: none;
|
64 |
+
color: #0f0c29;
|
65 |
+
font-weight: bold;
|
66 |
+
letter-spacing: 1px;
|
67 |
+
transition: all 0.3s;
|
68 |
+
box-shadow: 0 0 15px rgba(0, 255, 252, 0.5);
|
69 |
+
}
|
70 |
+
|
71 |
+
.btn-sci-fi:hover {
|
72 |
+
transform: translateY(-2px);
|
73 |
+
box-shadow: 0 0 20px rgba(0, 255, 252, 0.8);
|
74 |
+
}
|
75 |
+
|
76 |
+
.stars {
|
77 |
+
position: fixed;
|
78 |
+
top: 0;
|
79 |
+
left: 0;
|
80 |
+
width: 100%;
|
81 |
+
height: 100%;
|
82 |
+
pointer-events: none;
|
83 |
+
z-index: -1;
|
84 |
+
}
|
85 |
+
|
86 |
+
.star {
|
87 |
+
position: absolute;
|
88 |
+
background: white;
|
89 |
+
border-radius: 50%;
|
90 |
+
animation: twinkle var(--duration) infinite ease-in-out;
|
91 |
+
}
|
92 |
+
|
93 |
+
@keyframes twinkle {
|
94 |
+
0%, 100% { opacity: 0.2; }
|
95 |
+
50% { opacity: 1; }
|
96 |
+
}
|
97 |
+
|
98 |
+
.pulse {
|
99 |
+
animation: pulse 2s infinite;
|
100 |
+
}
|
101 |
+
|
102 |
+
@keyframes pulse {
|
103 |
+
0% { text-shadow: 0 0 5px #00fffc; }
|
104 |
+
50% { text-shadow: 0 0 20px #00fffc, 0 0 30px #00fffc; }
|
105 |
+
100% { text-shadow: 0 0 5px #00fffc; }
|
106 |
+
}
|
107 |
+
</style>
|
108 |
+
</head>
|
109 |
+
<body class="flex flex-col items-center justify-center p-4">
|
110 |
+
<!-- Background stars -->
|
111 |
+
<div class="stars" id="stars"></div>
|
112 |
+
|
113 |
+
<div class="text-center mb-6">
|
114 |
+
<h1 class="text-4xl md:text-5xl font-bold mb-2 pulse">
|
115 |
+
<i class="fas fa-gamepad mr-2"></i> BLOB HUNTER
|
116 |
+
</h1>
|
117 |
+
<p class="text-xl text-cyan-300">Galactic Pursuit</p>
|
118 |
+
</div>
|
119 |
+
|
120 |
+
<div class="game-container p-6 mb-6 w-full max-w-2xl">
|
121 |
+
<div class="flex justify-between items-center mb-4">
|
122 |
+
<div class="score-display text-xl">
|
123 |
+
<i class="fas fa-bolt mr-2"></i> SCORE: <span id="scoreDisplay">0</span>
|
124 |
+
</div>
|
125 |
+
<div class="score-display text-xl">
|
126 |
+
<i class="fas fa-clock mr-2"></i> TIME: <span id="timeDisplay">30</span>s
|
127 |
+
</div>
|
128 |
+
</div>
|
129 |
+
|
130 |
+
<canvas id="gameCanvas" width="600" height="400"></canvas>
|
131 |
+
|
132 |
+
<div class="mt-4 text-sm text-cyan-300 flex justify-between">
|
133 |
+
<div><i class="fas fa-circle text-blue-500 mr-1"></i> Blob = +10 pts</div>
|
134 |
+
<div><i class="fas fa-circle text-black mr-1"></i> Bomb = -10 pts</div>
|
135 |
+
<div><i class="fas fa-square text-red-500 mr-1"></i> Hunter (you)</div>
|
136 |
+
</div>
|
137 |
+
</div>
|
138 |
+
|
139 |
+
<div id="gameOverDisplay" class="game-over hidden p-8 rounded-lg text-center max-w-md w-full">
|
140 |
+
<h2 class="text-3xl font-bold mb-4 pulse">
|
141 |
+
<i class="fas fa-skull mr-2"></i> MISSION FAILED!
|
142 |
+
</h2>
|
143 |
+
<h3 id="finalScore" class="text-2xl mb-6">Your final score: 0</h3>
|
144 |
+
<button id="playAgainBtn" class="btn-sci-fi px-6 py-3 rounded-full text-lg">
|
145 |
+
<i class="fas fa-redo mr-2"></i> ENGAGE AGAIN
|
146 |
+
</button>
|
147 |
+
</div>
|
148 |
+
|
149 |
+
<div class="mt-6 text-sm text-cyan-300 opacity-70">
|
150 |
+
<p>Move your hunter with the mouse and click to collect blobs. Avoid bombs!</p>
|
151 |
+
</div>
|
152 |
+
|
153 |
+
<script>
|
154 |
+
// -----------------------
|
155 |
+
// Game Configuration
|
156 |
+
// -----------------------
|
157 |
+
const GAME_DURATION = 30000; // ms (30 seconds)
|
158 |
+
const BLOB_SIZE = 20;
|
159 |
+
const BOMB_SIZE = 15;
|
160 |
+
const HUNTER_SIZE = 20;
|
161 |
+
const BLOB_SPEED = 2;
|
162 |
+
const BOMB_SPEED = 1.5;
|
163 |
+
const POINTS_PER_BLOB = 10;
|
164 |
+
const PENALTY_PER_BOMB = 10;
|
165 |
+
|
166 |
+
// -----------------------
|
167 |
+
// Game State Variables
|
168 |
+
// -----------------------
|
169 |
+
let canvas = document.getElementById('gameCanvas');
|
170 |
+
let ctx = canvas.getContext('2d');
|
171 |
+
let score = 0;
|
172 |
+
let gameOver = false;
|
173 |
+
let timer = null;
|
174 |
+
let timeInterval = null;
|
175 |
+
let timeLeft = 30;
|
176 |
+
let blobs = [];
|
177 |
+
let bombs = [];
|
178 |
+
let hunter = {
|
179 |
+
x: canvas.width / 2,
|
180 |
+
y: canvas.height / 2
|
181 |
+
};
|
182 |
+
|
183 |
+
// -----------------------
|
184 |
+
// Drawing Functions
|
185 |
+
// -----------------------
|
186 |
+
function drawHunter() {
|
187 |
+
// Draw hunter with gradient
|
188 |
+
const gradient = ctx.createLinearGradient(hunter.x, hunter.y, hunter.x + HUNTER_SIZE, hunter.y + HUNTER_SIZE);
|
189 |
+
gradient.addColorStop(0, '#ff0000');
|
190 |
+
gradient.addColorStop(1, '#ff6666');
|
191 |
+
|
192 |
+
ctx.fillStyle = gradient;
|
193 |
+
ctx.fillRect(hunter.x, hunter.y, HUNTER_SIZE, HUNTER_SIZE);
|
194 |
+
|
195 |
+
// Add glow effect
|
196 |
+
ctx.shadowColor = '#ff0000';
|
197 |
+
ctx.shadowBlur = 10;
|
198 |
+
ctx.fillRect(hunter.x, hunter.y, HUNTER_SIZE, HUNTER_SIZE);
|
199 |
+
ctx.shadowBlur = 0;
|
200 |
+
}
|
201 |
+
|
202 |
+
function drawBlobs() {
|
203 |
+
blobs.forEach(blob => {
|
204 |
+
// Create radial gradient for blobs
|
205 |
+
const gradient = ctx.createRadialGradient(
|
206 |
+
blob.x, blob.y, 0,
|
207 |
+
blob.x, blob.y, BLOB_SIZE/2
|
208 |
+
);
|
209 |
+
gradient.addColorStop(0, '#00ffff');
|
210 |
+
gradient.addColorStop(1, '#0000ff');
|
211 |
+
|
212 |
+
ctx.fillStyle = gradient;
|
213 |
+
ctx.beginPath();
|
214 |
+
ctx.arc(blob.x, blob.y, BLOB_SIZE/2, 0, Math.PI * 2);
|
215 |
+
ctx.fill();
|
216 |
+
|
217 |
+
// Add glow effect
|
218 |
+
ctx.shadowColor = '#00ffff';
|
219 |
+
ctx.shadowBlur = 8;
|
220 |
+
ctx.fill();
|
221 |
+
ctx.shadowBlur = 0;
|
222 |
+
});
|
223 |
+
}
|
224 |
+
|
225 |
+
function drawBombs() {
|
226 |
+
bombs.forEach(bomb => {
|
227 |
+
// Create radial gradient for bombs
|
228 |
+
const gradient = ctx.createRadialGradient(
|
229 |
+
bomb.x, bomb.y, 0,
|
230 |
+
bomb.x, bomb.y, BOMB_SIZE/2
|
231 |
+
);
|
232 |
+
gradient.addColorStop(0, '#ff0000');
|
233 |
+
gradient.addColorStop(1, '#000000');
|
234 |
+
|
235 |
+
ctx.fillStyle = gradient;
|
236 |
+
ctx.beginPath();
|
237 |
+
ctx.arc(bomb.x, bomb.y, BOMB_SIZE/2, 0, Math.PI * 2);
|
238 |
+
ctx.fill();
|
239 |
+
|
240 |
+
// Add danger spikes
|
241 |
+
ctx.strokeStyle = '#ff0000';
|
242 |
+
ctx.lineWidth = 2;
|
243 |
+
for (let i = 0; i < 8; i++) {
|
244 |
+
const angle = (i / 8) * Math.PI * 2;
|
245 |
+
const x1 = bomb.x + Math.cos(angle) * BOMB_SIZE/2;
|
246 |
+
const y1 = bomb.y + Math.sin(angle) * BOMB_SIZE/2;
|
247 |
+
const x2 = bomb.x + Math.cos(angle) * (BOMB_SIZE/2 + 5);
|
248 |
+
const y2 = bomb.y + Math.sin(angle) * (BOMB_SIZE/2 + 5);
|
249 |
+
ctx.beginPath();
|
250 |
+
ctx.moveTo(x1, y1);
|
251 |
+
ctx.lineTo(x2, y2);
|
252 |
+
ctx.stroke();
|
253 |
+
}
|
254 |
+
});
|
255 |
+
}
|
256 |
+
|
257 |
+
function drawScore() {
|
258 |
+
document.getElementById('scoreDisplay').textContent = score;
|
259 |
+
}
|
260 |
+
|
261 |
+
function updateTimer() {
|
262 |
+
timeLeft = Math.ceil((GAME_DURATION - (Date.now() - startTime)) / 1000);
|
263 |
+
document.getElementById('timeDisplay').textContent = timeLeft > 0 ? timeLeft : 0;
|
264 |
+
}
|
265 |
+
|
266 |
+
// -----------------------
|
267 |
+
// Game Logic Functions
|
268 |
+
// -----------------------
|
269 |
+
function createBlob() {
|
270 |
+
let x = Math.random() * (canvas.width - BLOB_SIZE);
|
271 |
+
let y = Math.random() * (canvas.height - BLOB_SIZE);
|
272 |
+
let speedX = (Math.random() - 0.5) * BLOB_SPEED;
|
273 |
+
let speedY = (Math.random() - 0.5) * BLOB_SPEED;
|
274 |
+
blobs.push({ x, y, speedX, speedY });
|
275 |
+
}
|
276 |
+
|
277 |
+
function createBomb() {
|
278 |
+
let x = Math.random() * (canvas.width - BOMB_SIZE);
|
279 |
+
let y = Math.random() * (canvas.height - BOMB_SIZE);
|
280 |
+
let speedX = (Math.random() - 0.5) * BOMB_SPEED;
|
281 |
+
let speedY = (Math.random() - 0.5) * BOMB_SPEED;
|
282 |
+
bombs.push({ x, y, speedX, speedY });
|
283 |
+
}
|
284 |
+
|
285 |
+
function updateGameState() {
|
286 |
+
// Move blobs
|
287 |
+
blobs.forEach(blob => {
|
288 |
+
blob.x += blob.speedX;
|
289 |
+
blob.y += blob.speedY;
|
290 |
+
// Bounce off walls
|
291 |
+
if (blob.x < 0 || blob.x > canvas.width) blob.speedX *= -1;
|
292 |
+
if (blob.y < 0 || blob.y > canvas.height) blob.speedY *= -1;
|
293 |
+
});
|
294 |
+
|
295 |
+
// Move bombs
|
296 |
+
bombs.forEach(bomb => {
|
297 |
+
bomb.x += bomb.speedX;
|
298 |
+
bomb.y += bomb.speedY;
|
299 |
+
// Bounce off walls
|
300 |
+
if (bomb.x < 0 || bomb.x > canvas.width) bomb.speedX *= -1;
|
301 |
+
if (bomb.y < 0 || bomb.y > canvas.height) bomb.speedY *= -1;
|
302 |
+
});
|
303 |
+
|
304 |
+
// Randomly add new blobs & bombs
|
305 |
+
if (Math.random() < 0.05) createBlob();
|
306 |
+
if (Math.random() < 0.02) createBomb();
|
307 |
+
}
|
308 |
+
|
309 |
+
function checkClick(x, y) {
|
310 |
+
// Check if clicked on a blob
|
311 |
+
for (let i = blobs.length - 1; i >= 0; i--) {
|
312 |
+
let blob = blobs[i];
|
313 |
+
let distance = Math.sqrt((x - blob.x) ** 2 + (y - blob.y) ** 2);
|
314 |
+
if (distance < BLOB_SIZE / 2) {
|
315 |
+
score += POINTS_PER_BLOB;
|
316 |
+
blobs.splice(i, 1); // remove blob
|
317 |
+
playSound('blob');
|
318 |
+
return;
|
319 |
+
}
|
320 |
+
}
|
321 |
+
// Check if clicked on a bomb
|
322 |
+
for (let i = bombs.length - 1; i >= 0; i--) {
|
323 |
+
let bomb = bombs[i];
|
324 |
+
let distance = Math.sqrt((x - bomb.x) ** 2 + (y - bomb.y) ** 2);
|
325 |
+
if (distance < BOMB_SIZE / 2) {
|
326 |
+
score -= PENALTY_PER_BOMB;
|
327 |
+
bombs.splice(i, 1); // remove bomb
|
328 |
+
playSound('bomb');
|
329 |
+
return;
|
330 |
+
}
|
331 |
+
}
|
332 |
+
}
|
333 |
+
|
334 |
+
function playSound(type) {
|
335 |
+
// In a real game, you would play actual sound effects here
|
336 |
+
console.log(`Playing ${type} sound`);
|
337 |
+
}
|
338 |
+
|
339 |
+
// -----------------------
|
340 |
+
// Main Game Loop
|
341 |
+
// -----------------------
|
342 |
+
function draw() {
|
343 |
+
if (gameOver) return;
|
344 |
+
// Clear screen
|
345 |
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
346 |
+
|
347 |
+
// Draw starfield background
|
348 |
+
drawStarfield();
|
349 |
+
|
350 |
+
// Draw everything
|
351 |
+
drawBlobs();
|
352 |
+
drawBombs();
|
353 |
+
drawHunter();
|
354 |
+
drawScore();
|
355 |
+
|
356 |
+
// Update game state
|
357 |
+
updateGameState();
|
358 |
+
|
359 |
+
// Request next frame
|
360 |
+
requestAnimationFrame(draw);
|
361 |
+
}
|
362 |
+
|
363 |
+
function drawStarfield() {
|
364 |
+
// Draw a subtle starfield in the background
|
365 |
+
ctx.fillStyle = 'rgba(255, 255, 255, 0.1)';
|
366 |
+
for (let i = 0; i < 50; i++) {
|
367 |
+
const x = Math.sin(Date.now() / 1000 + i) * canvas.width / 2 + canvas.width / 2;
|
368 |
+
const y = Math.cos(Date.now() / 1200 + i * 2) * canvas.height / 2 + canvas.height / 2;
|
369 |
+
const size = Math.random() * 2;
|
370 |
+
ctx.beginPath();
|
371 |
+
ctx.arc(x, y, size, 0, Math.PI * 2);
|
372 |
+
ctx.fill();
|
373 |
+
}
|
374 |
+
}
|
375 |
+
|
376 |
+
// -----------------------
|
377 |
+
// Event Listeners
|
378 |
+
// -----------------------
|
379 |
+
canvas.addEventListener('mousemove', (e) => {
|
380 |
+
const rect = canvas.getBoundingClientRect();
|
381 |
+
hunter.x = e.clientX - rect.left - HUNTER_SIZE / 2;
|
382 |
+
hunter.y = e.clientY - rect.top - HUNTER_SIZE / 2;
|
383 |
+
});
|
384 |
+
|
385 |
+
canvas.addEventListener('click', (e) => {
|
386 |
+
const rect = canvas.getBoundingClientRect();
|
387 |
+
let x = e.clientX - rect.left;
|
388 |
+
let y = e.clientY - rect.top;
|
389 |
+
checkClick(x, y);
|
390 |
+
});
|
391 |
+
|
392 |
+
document.getElementById('playAgainBtn').addEventListener('click', () => {
|
393 |
+
// Reset game state
|
394 |
+
score = 0;
|
395 |
+
gameOver = false;
|
396 |
+
timeLeft = 30;
|
397 |
+
blobs = [];
|
398 |
+
bombs = [];
|
399 |
+
document.getElementById('gameOverDisplay').classList.add('hidden');
|
400 |
+
startGame();
|
401 |
+
});
|
402 |
+
|
403 |
+
// -----------------------
|
404 |
+
// Game Start/End Handling
|
405 |
+
// -----------------------
|
406 |
+
let startTime;
|
407 |
+
|
408 |
+
function startGame() {
|
409 |
+
startTime = Date.now();
|
410 |
+
timeInterval = setInterval(updateTimer, 200);
|
411 |
+
|
412 |
+
timer = setTimeout(() => {
|
413 |
+
gameOver = true;
|
414 |
+
clearInterval(timeInterval);
|
415 |
+
document.getElementById('finalScore').textContent = `Your final score: ${score}`;
|
416 |
+
document.getElementById('gameOverDisplay').classList.remove('hidden');
|
417 |
+
}, GAME_DURATION);
|
418 |
+
|
419 |
+
// Create initial blobs and bombs
|
420 |
+
for (let i = 0; i < 5; i++) createBlob();
|
421 |
+
for (let i = 0; i < 2; i++) createBomb();
|
422 |
+
|
423 |
+
draw(); // start drawing loop
|
424 |
+
}
|
425 |
+
|
426 |
+
// -----------------------
|
427 |
+
// Starfield Background
|
428 |
+
// -----------------------
|
429 |
+
function createStars() {
|
430 |
+
const starsContainer = document.getElementById('stars');
|
431 |
+
const starCount = 200;
|
432 |
+
|
433 |
+
for (let i = 0; i < starCount; i++) {
|
434 |
+
const star = document.createElement('div');
|
435 |
+
star.className = 'star';
|
436 |
+
|
437 |
+
// Random position
|
438 |
+
const x = Math.random() * 100;
|
439 |
+
const y = Math.random() * 100;
|
440 |
+
|
441 |
+
// Random size
|
442 |
+
const size = Math.random() * 2;
|
443 |
+
|
444 |
+
// Random animation duration
|
445 |
+
const duration = 3 + Math.random() * 7;
|
446 |
+
|
447 |
+
star.style.left = `${x}%`;
|
448 |
+
star.style.top = `${y}%`;
|
449 |
+
star.style.width = `${size}px`;
|
450 |
+
star.style.height = `${size}px`;
|
451 |
+
star.style.setProperty('--duration', `${duration}s`);
|
452 |
+
|
453 |
+
starsContainer.appendChild(star);
|
454 |
+
}
|
455 |
+
}
|
456 |
+
|
457 |
+
// Initialize the game
|
458 |
+
createStars();
|
459 |
+
startGame();
|
460 |
+
</script>
|
461 |
+
<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=porkz/blob-hunter" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
462 |
+
</html>
|