Spaces:
Running
Running
File size: 33,508 Bytes
1e9b46f |
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 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pixel Rush | Light Trail Platformer</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=Press+Start+2P&display=swap');
:root {
--neon-blue: #00f7ff;
--neon-pink: #ff00f7;
--neon-purple: #9d00ff;
--dark-bg: #0f0a1a;
}
body {
font-family: 'Press Start 2P', cursive;
background-color: var(--dark-bg);
overflow: hidden;
touch-action: none;
user-select: none;
}
.game-container {
position: relative;
width: 100vw;
height: 100vh;
overflow: hidden;
}
#gameCanvas {
background-color: #000;
display: block;
image-rendering: pixelated;
}
.neon-text {
text-shadow: 0 0 10px var(--neon-blue), 0 0 20px var(--neon-pink);
color: white;
}
.neon-border {
box-shadow: 0 0 10px var(--neon-blue), 0 0 20px var(--neon-pink), inset 0 0 10px var(--neon-blue);
border: 2px solid var(--neon-blue);
}
.pixel-button {
transition: all 0.2s;
position: relative;
overflow: hidden;
}
.pixel-button:hover {
transform: translateY(-2px);
box-shadow: 0 0 15px var(--neon-blue), 0 0 30px var(--neon-pink);
}
.pixel-button:active {
transform: translateY(1px);
}
.pixel-button::before {
content: '';
position: absolute;
top: -10px;
left: -10px;
right: -10px;
bottom: -10px;
background: linear-gradient(45deg, var(--neon-blue), var(--neon-pink), var(--neon-purple));
z-index: -1;
filter: blur(20px);
opacity: 0;
transition: opacity 0.3s;
}
.pixel-button:hover::before {
opacity: 0.7;
}
.glow {
animation: pulse 2s infinite alternate;
}
@keyframes pulse {
0% { opacity: 0.7; }
100% { opacity: 1; }
}
.menu-screen {
background: rgba(15, 10, 26, 0.9);
backdrop-filter: blur(5px);
}
.score-display {
background: rgba(0, 0, 0, 0.7);
border: 2px solid var(--neon-blue);
}
.mobile-controls {
touch-action: none;
}
.mobile-btn {
touch-action: none;
background: rgba(0, 0, 0, 0.5);
border: 2px solid var(--neon-blue);
}
.mobile-btn:active {
background: var(--neon-blue);
}
</style>
</head>
<body>
<div class="game-container flex items-center justify-center">
<canvas id="gameCanvas"></canvas>
<!-- Main Menu -->
<div id="mainMenu" class="menu-screen absolute inset-0 flex flex-col items-center justify-center gap-8 neon-text">
<h1 class="text-5xl md:text-7xl mb-4 glow">PIXEL RUSH</h1>
<div class="flex flex-col gap-4 w-full max-w-md px-4">
<button id="startBtn" class="pixel-button neon-border bg-black py-4 px-8 text-xl neon-text">
START GAME
</button>
<button id="howToBtn" class="pixel-button neon-border bg-black py-4 px-8 text-xl neon-text">
HOW TO PLAY
</button>
<button id="settingsBtn" class="pixel-button neon-border bg-black py-4 px-8 text-xl neon-text">
SETTINGS
</button>
</div>
<div class="absolute bottom-4 text-sm opacity-70">
Use arrow keys or touch controls
</div>
</div>
<!-- How To Play -->
<div id="howToMenu" class="menu-screen absolute inset-0 hidden flex-col items-center justify-center gap-6 neon-text p-4">
<h2 class="text-3xl mb-6">HOW TO PLAY</h2>
<div class="max-w-md bg-black bg-opacity-70 neon-border p-6 text-left text-sm leading-relaxed">
<div class="mb-4 flex items-start gap-3">
<i class="fas fa-arrow-up mt-1 text-purple-300"></i>
<p>Press UP to jump over obstacles and gaps</p>
</div>
<div class="mb-4 flex items-start gap-3">
<i class="fas fa-arrow-left mt-1 text-blue-300"></i>
<i class="fas fa-arrow-right mt-1 text-blue-300"></i>
<p>Move LEFT/RIGHT to navigate platforms</p>
</div>
<div class="mb-4 flex items-start gap-3">
<i class="fas fa-bolt mt-1 text-yellow-300"></i>
<p>Collect energy orbs to grow your trail</p>
</div>
<div class="mb-4 flex items-start gap-3">
<i class="fas fa-skull mt-1 text-red-300"></i>
<p>Avoid touching your trail or falling off</p>
</div>
<div class="mt-6 text-center">
<p class="text-purple-300">The longer your trail, the higher your score!</p>
</div>
</div>
<button id="backFromHowToBtn" class="pixel-button neon-border bg-black py-3 px-6 mt-6 neon-text">
BACK
</button>
</div>
<!-- Settings -->
<div id="settingsMenu" class="menu-screen absolute inset-0 hidden flex-col items-center justify-center gap-6 neon-text p-4">
<h2 class="text-3xl mb-6">SETTINGS</h2>
<div class="max-w-md bg-black bg-opacity-70 neon-border p-6 w-full">
<div class="mb-6">
<label class="block mb-2">Game Speed</label>
<div class="flex gap-2">
<button data-speed="0.8" class="speed-btn pixel-button neon-border bg-black py-2 px-4 text-sm active">Slow</button>
<button data-speed="1.2" class="speed-btn pixel-button neon-border bg-black py-2 px-4 text-sm">Normal</button>
<button data-speed="1.6" class="speed-btn pixel-button neon-border bg-black py-2 px-4 text-sm">Fast</button>
</div>
</div>
<div class="mb-6">
<label class="block mb-2">Trail Style</label>
<div class="flex gap-2 flex-wrap">
<button data-trail="solid" class="trail-btn pixel-button neon-border bg-black py-2 px-4 text-sm active">Solid</button>
<button data-trail="glow" class="trail-btn pixel-button neon-border bg-black py-2 px-4 text-sm">Glow</button>
<button data-trail="pulse" class="trail-btn pixel-button neon-border bg-black py-2 px-4 text-sm">Pulse</button>
<button data-trail="rainbow" class="trail-btn pixel-button neon-border bg-black py-2 px-4 text-sm">Rainbow</button>
</div>
</div>
<div class="flex items-center justify-between">
<label for="soundToggle" class="cursor-pointer">Sound Effects</label>
<div class="relative">
<input type="checkbox" id="soundToggle" class="hidden" checked>
<div class="toggle-bg bg-gray-700 w-12 h-6 rounded-full">
<div class="toggle-circle absolute left-0 top-0 bg-blue-400 w-6 h-6 rounded-full transition-transform"></div>
</div>
</div>
</div>
</div>
<button id="backFromSettingsBtn" class="pixel-button neon-border bg-black py-3 px-6 mt-6 neon-text">
BACK
</button>
</div>
<!-- Game Over -->
<div id="gameOverMenu" class="menu-screen absolute inset-0 hidden flex-col items-center justify-center gap-6 neon-text">
<h2 class="text-4xl text-red-400 mb-2">GAME OVER</h2>
<div class="text-xl mb-2">Your Score:</div>
<div id="finalScore" class="text-5xl text-yellow-300 mb-8">0</div>
<div class="flex flex-col gap-4 w-full max-w-md px-4">
<button id="restartBtn" class="pixel-button neon-border bg-black py-4 px-8 text-xl neon-text">
PLAY AGAIN
</button>
<button id="menuBtn" class="pixel-button neon-border bg-black py-4 px-8 text-xl neon-text">
MAIN MENU
</button>
</div>
</div>
<!-- In-Game UI -->
<div id="gameUI" class="absolute top-0 left-0 right-0 p-4 hidden">
<div class="flex justify-between items-center">
<div class="score-display py-2 px-4 rounded">
<span class="text-yellow-300">SCORE: </span>
<span id="scoreValue" class="text-white">0</span>
</div>
<div class="score-display py-2 px-4 rounded">
<span class="text-blue-300">LENGTH: </span>
<span id="lengthValue" class="text-white">1</span>
</div>
</div>
</div>
<!-- Mobile Controls (hidden by default) -->
<div id="mobileControls" class="absolute bottom-0 left-0 right-0 p-4 hidden mobile-controls">
<div class="flex justify-between">
<div class="flex gap-4">
<button id="mobileLeft" class="mobile-btn w-16 h-16 rounded-full flex items-center justify-center">
<i class="fas fa-arrow-left text-2xl"></i>
</button>
<button id="mobileRight" class="mobile-btn w-16 h-16 rounded-full flex items-center justify-center">
<i class="fas fa-arrow-right text-2xl"></i>
</button>
</div>
<button id="mobileUp" class="mobile-btn w-16 h-16 rounded-full flex items-center justify-center">
<i class="fas fa-arrow-up text-2xl"></i>
</button>
</div>
</div>
</div>
<script>
// Game variables
let canvas, ctx;
let gameWidth, gameHeight;
let gameActive = false;
let score = 0;
let trailLength = 1;
let gameSpeed = 0.8; // Default to slow speed
let trailStyle = 'solid';
let soundEnabled = true;
let isMobile = false;
// Player variables
let player = {
x: 100,
y: 300,
width: 20,
height: 20,
velocityY: 0,
gravity: 0.3, // Reduced gravity for slower fall
jumpForce: -9, // Reduced jump force for lower jumps
isJumping: false,
speed: 0
};
// Trail segments
let trail = [];
const maxTrailLength = 100;
// Platforms
let platforms = [];
const platformHeight = 20;
// Collectibles
let collectibles = [];
// Obstacles
let obstacles = [];
// Initialize game
function init() {
canvas = document.getElementById('gameCanvas');
ctx = canvas.getContext('2d');
// Check if mobile
isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
if (isMobile) {
document.getElementById('mobileControls').classList.remove('hidden');
}
resizeCanvas();
setupEventListeners();
generateInitialPlatforms();
}
// Resize canvas to window
function resizeCanvas() {
gameWidth = window.innerWidth;
gameHeight = window.innerHeight;
canvas.width = gameWidth;
canvas.height = gameHeight;
// Adjust player position if game is active
if (gameActive) {
player.y = Math.min(player.y, gameHeight - player.height - platformHeight);
}
}
// Set up event listeners
function setupEventListeners() {
// Window resize
window.addEventListener('resize', resizeCanvas);
// Keyboard controls
window.addEventListener('keydown', handleKeyDown);
window.addEventListener('keyup', handleKeyUp);
// Mobile controls
document.getElementById('mobileLeft').addEventListener('touchstart', () => movePlayer('left'));
document.getElementById('mobileLeft').addEventListener('touchend', () => stopPlayer());
document.getElementById('mobileRight').addEventListener('touchstart', () => movePlayer('right'));
document.getElementById('mobileRight').addEventListener('touchend', () => stopPlayer());
document.getElementById('mobileUp').addEventListener('touchstart', () => jump());
// Menu buttons
document.getElementById('startBtn').addEventListener('click', startGame);
document.getElementById('howToBtn').addEventListener('click', () => toggleMenu('howToMenu'));
document.getElementById('settingsBtn').addEventListener('click', () => toggleMenu('settingsMenu'));
document.getElementById('backFromHowToBtn').addEventListener('click', () => toggleMenu('mainMenu'));
document.getElementById('backFromSettingsBtn').addEventListener('click', () => toggleMenu('mainMenu'));
document.getElementById('restartBtn').addEventListener('click', startGame);
document.getElementById('menuBtn').addEventListener('click', () => {
document.getElementById('gameOverMenu').classList.add('hidden');
document.getElementById('mainMenu').classList.remove('hidden');
});
// Settings buttons
document.querySelectorAll('.speed-btn').forEach(btn => {
btn.addEventListener('click', () => {
document.querySelector('.speed-btn.active').classList.remove('active');
btn.classList.add('active');
gameSpeed = parseFloat(btn.dataset.speed);
// Update player speed immediately if game is active
if (gameActive) {
player.speed = player.speed > 0 ? 3 * gameSpeed : player.speed < 0 ? -3 * gameSpeed : 0;
}
});
});
document.querySelectorAll('.trail-btn').forEach(btn => {
btn.addEventListener('click', () => {
document.querySelector('.trail-btn.active').classList.remove('active');
btn.classList.add('active');
trailStyle = btn.dataset.trail;
});
});
document.getElementById('soundToggle').addEventListener('change', (e) => {
soundEnabled = e.target.checked;
});
}
// Toggle between menus
function toggleMenu(menuId) {
document.querySelector('.menu-screen:not(.hidden)').classList.add('hidden');
document.getElementById(menuId).classList.remove('hidden');
}
// Handle keyboard input
function handleKeyDown(e) {
if (!gameActive) return;
switch(e.key) {
case 'ArrowLeft':
movePlayer('left');
break;
case 'ArrowRight':
movePlayer('right');
break;
case 'ArrowUp':
jump();
break;
}
}
function handleKeyUp(e) {
if (!gameActive) return;
if (e.key === 'ArrowLeft' || e.key === 'ArrowRight') {
stopPlayer();
}
}
// Player movement
function movePlayer(direction) {
if (direction === 'left') {
player.speed = -3 * gameSpeed; // Reduced base speed
} else if (direction === 'right') {
player.speed = 3 * gameSpeed; // Reduced base speed
}
}
function stopPlayer() {
player.speed = 0;
}
function jump() {
if (!player.isJumping && gameActive) {
player.velocityY = player.jumpForce;
player.isJumping = true;
}
}
// Start the game
function startGame() {
// Reset game state
score = 0;
trailLength = 1;
trail = [];
platforms = [];
collectibles = [];
obstacles = [];
// Reset player
player = {
x: 100,
y: 300,
width: 20,
height: 20,
velocityY: 0,
gravity: 0.3,
jumpForce: -9,
isJumping: false,
speed: 0
};
// Generate initial platforms
generateInitialPlatforms();
// Hide menus, show game UI
document.querySelector('.menu-screen:not(.hidden)').classList.add('hidden');
document.getElementById('gameUI').classList.remove('hidden');
// Start game loop
gameActive = true;
requestAnimationFrame(gameLoop);
}
// Generate initial platforms
function generateInitialPlatforms() {
// Starting platform
platforms.push({
x: 0,
y: gameHeight - platformHeight,
width: gameWidth,
height: platformHeight
});
// Additional platforms - spaced further apart for slower gameplay
for (let i = 0; i < 10; i++) {
const width = Math.random() * 150 + 100; // Wider platforms
const x = i * 400 + 250; // More space between platforms
const y = gameHeight - platformHeight - (Math.random() * 150); // Lower height variation
platforms.push({
x: x,
y: y,
width: width,
height: platformHeight
});
// Add collectibles above platforms
if (Math.random() > 0.3) {
collectibles.push({
x: x + width / 2 - 10,
y: y - 30,
width: 20,
height: 20,
collected: false
});
}
// Add obstacles less frequently
if (Math.random() > 0.8) {
obstacles.push({
x: x + width / 2 - 15,
y: y - 40,
width: 30,
height: 40
});
}
}
}
// Game loop
function gameLoop() {
if (!gameActive) return;
update();
render();
requestAnimationFrame(gameLoop);
}
// Update game state
function update() {
// Update player position
player.x += player.speed;
// Apply gravity
player.velocityY += player.gravity;
player.y += player.velocityY;
// Check platform collisions
let onPlatform = false;
for (const platform of platforms) {
if (
player.x + player.width > platform.x &&
player.x < platform.x + platform.width &&
player.y + player.height >= platform.y &&
player.y + player.height <= platform.y + platform.height / 2 &&
player.velocityY > 0
) {
player.y = platform.y - player.height;
player.velocityY = 0;
player.isJumping = false;
onPlatform = true;
}
}
// Add current position to trail (less frequently for slower trail growth)
if (trail.length === 0 ||
Math.sqrt(
Math.pow(player.x + player.width / 2 - trail[trail.length-1].x, 2) +
Math.pow(player.y + player.height / 2 - trail[trail.length-1].y, 2)
) > 10) {
trail.push({
x: player.x + player.width / 2,
y: player.y + player.height / 2
});
}
// Limit trail length
if (trail.length > maxTrailLength) {
trail.shift();
}
// Check collectible collisions
for (const collectible of collectibles) {
if (
!collectible.collected &&
player.x + player.width > collectible.x &&
player.x < collectible.x + collectible.width &&
player.y + player.height > collectible.y &&
player.y < collectible.y + collectible.height
) {
collectible.collected = true;
score += 10;
trailLength += 3; // Reduced trail growth
}
}
// Check obstacle collisions
for (const obstacle of obstacles) {
if (
player.x + player.width > obstacle.x &&
player.x < obstacle.x + obstacle.width &&
player.y + player.height > obstacle.y &&
player.y < obstacle.y + obstacle.height
) {
gameOver();
return;
}
}
// Check trail collisions (with more lenient collision detection)
for (let i = 0; i < trail.length - 15; i++) {
const segment = trail[i];
const distance = Math.sqrt(
Math.pow(player.x + player.width / 2 - segment.x, 2) +
Math.pow(player.y + player.height / 2 - segment.y, 2)
);
if (distance < 12) { // Slightly more lenient collision
gameOver();
return;
}
}
// Check if player fell off screen
if (player.y > gameHeight) {
gameOver();
return;
}
// Camera follow - move platforms when player reaches right half
if (player.x > gameWidth / 2) {
const moveAmount = player.x - gameWidth / 2;
player.x = gameWidth / 2;
// Move platforms and collectibles
for (const platform of platforms) {
platform.x -= moveAmount;
}
for (const collectible of collectibles) {
collectible.x -= moveAmount;
}
for (const obstacle of obstacles) {
obstacle.x -= moveAmount;
}
// Move trail segments
for (const segment of trail) {
segment.x -= moveAmount;
}
// Generate new platforms as needed (with more spacing)
if (platforms[platforms.length - 1].x < gameWidth) {
const width = Math.random() * 150 + 100;
const x = platforms[platforms.length - 1].x + 400;
const y = gameHeight - platformHeight - (Math.random() * 150);
platforms.push({
x: x,
y: y,
width: width,
height: platformHeight
});
// Add collectibles above platforms
if (Math.random() > 0.3) {
collectibles.push({
x: x + width / 2 - 10,
y: y - 30,
width: 20,
height: 20,
collected: false
});
}
// Add obstacles less frequently
if (Math.random() > 0.8) {
obstacles.push({
x: x + width / 2 - 15,
y: y - 40,
width: 30,
height: 40
});
}
}
// Remove off-screen platforms
if (platforms[0].x + platforms[0].width < 0) {
platforms.shift();
}
// Remove off-screen collectibles
collectibles = collectibles.filter(c => !c.collected && c.x + c.width > 0);
// Remove off-screen obstacles
obstacles = obstacles.filter(o => o.x + o.width > 0);
}
// Update UI
document.getElementById('scoreValue').textContent = score;
document.getElementById('lengthValue').textContent = trailLength;
}
// Render game
function render() {
// Clear canvas
ctx.fillStyle = '#000';
ctx.fillRect( 0, 0, gameWidth, gameHeight );
// Draw background (simple starfield)
ctx.fillStyle = '#fff';
for (let i = 0; i < 100; i++) {
const x = (i * 100 + (Date.now() / 40) % 100) % gameWidth; // Slower star movement
const y = (i * 80) % gameHeight;
const size = Math.random() * 2 + 1;
ctx.fillRect(x, y, size, size);
}
// Draw platforms
ctx.fillStyle = '#444';
for (const platform of platforms) {
ctx.fillRect(platform.x, platform.y, platform.width, platform.height);
// Platform details
ctx.fillStyle = '#555';
for (let x = platform.x; x < platform.x + platform.width; x += 20) {
ctx.fillRect(x, platform.y, 15, 3);
}
ctx.fillStyle = '#444';
}
// Draw collectibles
for (const collectible of collectibles) {
if (!collectible.collected) {
// Glowing effect
ctx.beginPath();
ctx.arc(
collectible.x + collectible.width / 2,
collectible.y + collectible.height / 2,
collectible.width / 2,
0,
Math.PI * 2
);
const gradient = ctx.createRadialGradient(
collectible.x + collectible.width / 2,
collectible.y + collectible.height / 2,
0,
collectible.x + collectible.width / 2,
collectible.y + collectible.height / 2,
collectible.width / 2
);
gradient.addColorStop(0, 'rgba(255, 255, 0, 0.8)');
gradient.addColorStop(1, 'rgba(255, 200, 0, 0.2)');
ctx.fillStyle = gradient;
ctx.fill();
// Core
ctx.beginPath();
ctx.arc(
collectible.x + collectible.width / 2,
collectible.y + collectible.height / 2,
collectible.width / 4,
0,
Math.PI * 2
);
ctx.fillStyle = 'yellow';
ctx.fill();
}
}
// Draw obstacles
ctx.fillStyle = '#f00';
for (const obstacle of obstacles) {
// Base
ctx.fillRect(obstacle.x, obstacle.y, obstacle.width, obstacle.height);
// Spikes
ctx.beginPath();
ctx.moveTo(obstacle.x, obstacle.y);
ctx.lineTo(obstacle.x + obstacle.width / 2, obstacle.y - 15);
ctx.lineTo(obstacle.x + obstacle.width, obstacle.y);
ctx.closePath();
ctx.fillStyle = '#d00';
ctx.fill();
}
// Draw trail
if (trail.length > 1) {
ctx.beginPath();
ctx.moveTo(trail[0].x, trail[0].y);
for (let i = 1; i < trail.length; i++) {
ctx.lineTo(trail[i].x, trail[i].y);
}
ctx.lineWidth = 8;
switch(trailStyle) {
case 'glow':
ctx.strokeStyle = 'rgba(0, 247, 255, 0.7)';
ctx.shadowBlur = 15;
ctx.shadowColor = '#00f7ff';
break;
case 'pulse':
const pulseVal = Math.sin(Date.now() / 300) * 0.3 + 0.7; // Slower pulse
ctx.strokeStyle = `rgba(0, ${Math.floor(247 * pulseVal)}, 255, ${pulseVal})`;
break;
case 'rainbow':
const gradient = ctx.createLinearGradient(0, 0, gameWidth, 0);
gradient.addColorStop(0, '#ff00f7');
gradient.addColorStop(0.5, '#00f7ff');
gradient.addColorStop(1, '#9d00ff');
ctx.strokeStyle = gradient;
break;
default: // solid
ctx.strokeStyle = '#00f7ff';
}
ctx.stroke();
// Reset shadow
ctx.shadowBlur = 0;
}
// Draw player
ctx.fillStyle = '#fff';
ctx.fillRect(player.x, player.y, player.width, player.height);
// Player eyes
ctx.fillStyle = '#00f7ff';
ctx.fillRect(player.x + 5, player.y + 5, 5, 5);
ctx.fillRect(player.x + 10, player.y + 5, 5, 5);
}
// Game over
function gameOver() {
gameActive = false;
// Show game over menu
document.getElementById('gameUI').classList.add('hidden');
document.getElementById('gameOverMenu').classList.remove('hidden');
document.getElementById('finalScore').textContent = score;
}
// Initialize game when page loads
window.addEventListener('load', init);
</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=sreeramajay/pixel-rush" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html> |