Spaces:
Running
Running
File size: 14,780 Bytes
ab6a04a |
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 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Blob Hunter: Galactic Pursuit 🚀</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&family=Press+Start+2P&display=swap');
body {
background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
font-family: 'Orbitron', sans-serif;
min-height: 100vh;
margin: 0;
overflow-x: hidden;
color: #00fffc;
}
.game-container {
box-shadow: 0 0 30px rgba(0, 255, 252, 0.3);
border: 2px solid #00fffc;
border-radius: 8px;
background: rgba(15, 12, 41, 0.8);
position: relative;
overflow: hidden;
}
.game-container::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background:
radial-gradient(circle at 20% 30%, rgba(0, 255, 252, 0.1) 0%, transparent 50%),
radial-gradient(circle at 80% 70%, rgba(0, 255, 252, 0.1) 0%, transparent 50%);
pointer-events: none;
}
canvas {
display: block;
margin: 0 auto;
border: 1px solid rgba(0, 255, 252, 0.3);
}
.score-display {
font-family: 'Press Start 2P', cursive;
text-shadow: 0 0 10px #00fffc;
letter-spacing: 2px;
}
.game-over {
background: rgba(15, 12, 41, 0.95);
border: 2px solid #00fffc;
box-shadow: 0 0 30px rgba(0, 255, 252, 0.5);
}
.btn-sci-fi {
background: linear-gradient(45deg, #00fffc, #0088ff);
border: none;
color: #0f0c29;
font-weight: bold;
letter-spacing: 1px;
transition: all 0.3s;
box-shadow: 0 0 15px rgba(0, 255, 252, 0.5);
}
.btn-sci-fi:hover {
transform: translateY(-2px);
box-shadow: 0 0 20px rgba(0, 255, 252, 0.8);
}
.stars {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
z-index: -1;
}
.star {
position: absolute;
background: white;
border-radius: 50%;
animation: twinkle var(--duration) infinite ease-in-out;
}
@keyframes twinkle {
0%, 100% { opacity: 0.2; }
50% { opacity: 1; }
}
.pulse {
animation: pulse 2s infinite;
}
@keyframes pulse {
0% { text-shadow: 0 0 5px #00fffc; }
50% { text-shadow: 0 0 20px #00fffc, 0 0 30px #00fffc; }
100% { text-shadow: 0 0 5px #00fffc; }
}
</style>
</head>
<body class="flex flex-col items-center justify-center p-4">
<!-- Background stars -->
<div class="stars" id="stars"></div>
<div class="text-center mb-6">
<h1 class="text-4xl md:text-5xl font-bold mb-2 pulse">
<i class="fas fa-gamepad mr-2"></i> BLOB HUNTER
</h1>
<p class="text-xl text-cyan-300">Galactic Pursuit</p>
</div>
<div class="game-container p-6 mb-6 w-full max-w-2xl">
<div class="flex justify-between items-center mb-4">
<div class="score-display text-xl">
<i class="fas fa-bolt mr-2"></i> SCORE: <span id="scoreDisplay">0</span>
</div>
<div class="score-display text-xl">
<i class="fas fa-clock mr-2"></i> TIME: <span id="timeDisplay">30</span>s
</div>
</div>
<canvas id="gameCanvas" width="600" height="400"></canvas>
<div class="mt-4 text-sm text-cyan-300 flex justify-between">
<div><i class="fas fa-circle text-blue-500 mr-1"></i> Blob = +10 pts</div>
<div><i class="fas fa-circle text-black mr-1"></i> Bomb = -10 pts</div>
<div><i class="fas fa-square text-red-500 mr-1"></i> Hunter (you)</div>
</div>
</div>
<div id="gameOverDisplay" class="game-over hidden p-8 rounded-lg text-center max-w-md w-full">
<h2 class="text-3xl font-bold mb-4 pulse">
<i class="fas fa-skull mr-2"></i> MISSION FAILED!
</h2>
<h3 id="finalScore" class="text-2xl mb-6">Your final score: 0</h3>
<button id="playAgainBtn" class="btn-sci-fi px-6 py-3 rounded-full text-lg">
<i class="fas fa-redo mr-2"></i> ENGAGE AGAIN
</button>
</div>
<div class="mt-6 text-sm text-cyan-300 opacity-70">
<p>Move your hunter with the mouse and click to collect blobs. Avoid bombs!</p>
</div>
<script>
// -----------------------
// Game Configuration
// -----------------------
const GAME_DURATION = 30000; // ms (30 seconds)
const BLOB_SIZE = 20;
const BOMB_SIZE = 15;
const HUNTER_SIZE = 20;
const BLOB_SPEED = 2;
const BOMB_SPEED = 1.5;
const POINTS_PER_BLOB = 10;
const PENALTY_PER_BOMB = 10;
// -----------------------
// Game State Variables
// -----------------------
let canvas = document.getElementById('gameCanvas');
let ctx = canvas.getContext('2d');
let score = 0;
let gameOver = false;
let timer = null;
let timeInterval = null;
let timeLeft = 30;
let blobs = [];
let bombs = [];
let hunter = {
x: canvas.width / 2,
y: canvas.height / 2
};
// -----------------------
// Drawing Functions
// -----------------------
function drawHunter() {
// Draw hunter with gradient
const gradient = ctx.createLinearGradient(hunter.x, hunter.y, hunter.x + HUNTER_SIZE, hunter.y + HUNTER_SIZE);
gradient.addColorStop(0, '#ff0000');
gradient.addColorStop(1, '#ff6666');
ctx.fillStyle = gradient;
ctx.fillRect(hunter.x, hunter.y, HUNTER_SIZE, HUNTER_SIZE);
// Add glow effect
ctx.shadowColor = '#ff0000';
ctx.shadowBlur = 10;
ctx.fillRect(hunter.x, hunter.y, HUNTER_SIZE, HUNTER_SIZE);
ctx.shadowBlur = 0;
}
function drawBlobs() {
blobs.forEach(blob => {
// Create radial gradient for blobs
const gradient = ctx.createRadialGradient(
blob.x, blob.y, 0,
blob.x, blob.y, BLOB_SIZE/2
);
gradient.addColorStop(0, '#00ffff');
gradient.addColorStop(1, '#0000ff');
ctx.fillStyle = gradient;
ctx.beginPath();
ctx.arc(blob.x, blob.y, BLOB_SIZE/2, 0, Math.PI * 2);
ctx.fill();
// Add glow effect
ctx.shadowColor = '#00ffff';
ctx.shadowBlur = 8;
ctx.fill();
ctx.shadowBlur = 0;
});
}
function drawBombs() {
bombs.forEach(bomb => {
// Create radial gradient for bombs
const gradient = ctx.createRadialGradient(
bomb.x, bomb.y, 0,
bomb.x, bomb.y, BOMB_SIZE/2
);
gradient.addColorStop(0, '#ff0000');
gradient.addColorStop(1, '#000000');
ctx.fillStyle = gradient;
ctx.beginPath();
ctx.arc(bomb.x, bomb.y, BOMB_SIZE/2, 0, Math.PI * 2);
ctx.fill();
// Add danger spikes
ctx.strokeStyle = '#ff0000';
ctx.lineWidth = 2;
for (let i = 0; i < 8; i++) {
const angle = (i / 8) * Math.PI * 2;
const x1 = bomb.x + Math.cos(angle) * BOMB_SIZE/2;
const y1 = bomb.y + Math.sin(angle) * BOMB_SIZE/2;
const x2 = bomb.x + Math.cos(angle) * (BOMB_SIZE/2 + 5);
const y2 = bomb.y + Math.sin(angle) * (BOMB_SIZE/2 + 5);
ctx.beginPath();
ctx.moveTo(x1, y1);
ctx.lineTo(x2, y2);
ctx.stroke();
}
});
}
function drawScore() {
document.getElementById('scoreDisplay').textContent = score;
}
function updateTimer() {
timeLeft = Math.ceil((GAME_DURATION - (Date.now() - startTime)) / 1000);
document.getElementById('timeDisplay').textContent = timeLeft > 0 ? timeLeft : 0;
}
// -----------------------
// Game Logic Functions
// -----------------------
function createBlob() {
let x = Math.random() * (canvas.width - BLOB_SIZE);
let y = Math.random() * (canvas.height - BLOB_SIZE);
let speedX = (Math.random() - 0.5) * BLOB_SPEED;
let speedY = (Math.random() - 0.5) * BLOB_SPEED;
blobs.push({ x, y, speedX, speedY });
}
function createBomb() {
let x = Math.random() * (canvas.width - BOMB_SIZE);
let y = Math.random() * (canvas.height - BOMB_SIZE);
let speedX = (Math.random() - 0.5) * BOMB_SPEED;
let speedY = (Math.random() - 0.5) * BOMB_SPEED;
bombs.push({ x, y, speedX, speedY });
}
function updateGameState() {
// Move blobs
blobs.forEach(blob => {
blob.x += blob.speedX;
blob.y += blob.speedY;
// Bounce off walls
if (blob.x < 0 || blob.x > canvas.width) blob.speedX *= -1;
if (blob.y < 0 || blob.y > canvas.height) blob.speedY *= -1;
});
// Move bombs
bombs.forEach(bomb => {
bomb.x += bomb.speedX;
bomb.y += bomb.speedY;
// Bounce off walls
if (bomb.x < 0 || bomb.x > canvas.width) bomb.speedX *= -1;
if (bomb.y < 0 || bomb.y > canvas.height) bomb.speedY *= -1;
});
// Randomly add new blobs & bombs
if (Math.random() < 0.05) createBlob();
if (Math.random() < 0.02) createBomb();
}
function checkClick(x, y) {
// Check if clicked on a blob
for (let i = blobs.length - 1; i >= 0; i--) {
let blob = blobs[i];
let distance = Math.sqrt((x - blob.x) ** 2 + (y - blob.y) ** 2);
if (distance < BLOB_SIZE / 2) {
score += POINTS_PER_BLOB;
blobs.splice(i, 1); // remove blob
playSound('blob');
return;
}
}
// Check if clicked on a bomb
for (let i = bombs.length - 1; i >= 0; i--) {
let bomb = bombs[i];
let distance = Math.sqrt((x - bomb.x) ** 2 + (y - bomb.y) ** 2);
if (distance < BOMB_SIZE / 2) {
score -= PENALTY_PER_BOMB;
bombs.splice(i, 1); // remove bomb
playSound('bomb');
return;
}
}
}
function playSound(type) {
// In a real game, you would play actual sound effects here
console.log(`Playing ${type} sound`);
}
// -----------------------
// Main Game Loop
// -----------------------
function draw() {
if (gameOver) return;
// Clear screen
ctx.clearRect(0, 0, canvas.width, canvas.height);
// Draw starfield background
drawStarfield();
// Draw everything
drawBlobs();
drawBombs();
drawHunter();
drawScore();
// Update game state
updateGameState();
// Request next frame
requestAnimationFrame(draw);
}
function drawStarfield() {
// Draw a subtle starfield in the background
ctx.fillStyle = 'rgba(255, 255, 255, 0.1)';
for (let i = 0; i < 50; i++) {
const x = Math.sin(Date.now() / 1000 + i) * canvas.width / 2 + canvas.width / 2;
const y = Math.cos(Date.now() / 1200 + i * 2) * canvas.height / 2 + canvas.height / 2;
const size = Math.random() * 2;
ctx.beginPath();
ctx.arc(x, y, size, 0, Math.PI * 2);
ctx.fill();
}
}
// -----------------------
// Event Listeners
// -----------------------
canvas.addEventListener('mousemove', (e) => {
const rect = canvas.getBoundingClientRect();
hunter.x = e.clientX - rect.left - HUNTER_SIZE / 2;
hunter.y = e.clientY - rect.top - HUNTER_SIZE / 2;
});
canvas.addEventListener('click', (e) => {
const rect = canvas.getBoundingClientRect();
let x = e.clientX - rect.left;
let y = e.clientY - rect.top;
checkClick(x, y);
});
document.getElementById('playAgainBtn').addEventListener('click', () => {
// Reset game state
score = 0;
gameOver = false;
timeLeft = 30;
blobs = [];
bombs = [];
document.getElementById('gameOverDisplay').classList.add('hidden');
startGame();
});
// -----------------------
// Game Start/End Handling
// -----------------------
let startTime;
function startGame() {
startTime = Date.now();
timeInterval = setInterval(updateTimer, 200);
timer = setTimeout(() => {
gameOver = true;
clearInterval(timeInterval);
document.getElementById('finalScore').textContent = `Your final score: ${score}`;
document.getElementById('gameOverDisplay').classList.remove('hidden');
}, GAME_DURATION);
// Create initial blobs and bombs
for (let i = 0; i < 5; i++) createBlob();
for (let i = 0; i < 2; i++) createBomb();
draw(); // start drawing loop
}
// -----------------------
// Starfield Background
// -----------------------
function createStars() {
const starsContainer = document.getElementById('stars');
const starCount = 200;
for (let i = 0; i < starCount; i++) {
const star = document.createElement('div');
star.className = 'star';
// Random position
const x = Math.random() * 100;
const y = Math.random() * 100;
// Random size
const size = Math.random() * 2;
// Random animation duration
const duration = 3 + Math.random() * 7;
star.style.left = `${x}%`;
star.style.top = `${y}%`;
star.style.width = `${size}px`;
star.style.height = `${size}px`;
star.style.setProperty('--duration', `${duration}s`);
starsContainer.appendChild(star);
}
}
// Initialize the game
createStars();
startGame();
</script>
<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>
</html> |