Spaces:
Running
Running
File size: 18,063 Bytes
d0feeee f37b5b9 d0feeee |
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 |
<!DOCTYPE html>
<html>
<head>
<title>Chaos Cannon - CRT Edition</title>
<script src="https://cdn.tailwindcss.com"></script>
<style>
body {
background: #000;
overflow: hidden;
font-family: 'Courier New', monospace;
}
#crt-screen {
position: relative;
width: 800px;
height: 600px;
margin: 20px auto;
background: #111;
border-radius: 10px;
box-shadow: 0 0 20px rgba(0, 255, 0, 0.3),
inset 0 0 50px rgba(0, 255, 0, 0.1);
overflow: hidden;
padding: 10px;
}
#crt-effect {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(rgba(0, 255, 0, 0.1) 1px, transparent 1px);
background-size: 100% 2px;
pointer-events: none;
z-index: 10;
}
#crt-curve {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-radius: 50% 50% 50% 50% / 10% 10% 10% 10%;
box-shadow: inset 0 0 20px rgba(0, 255, 0, 0.2);
pointer-events: none;
z-index: 5;
}
#crt-glow {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: radial-gradient(circle at center, rgba(0, 255, 0, 0.05) 0%, transparent 70%);
pointer-events: none;
z-index: 1;
}
#crt-noise {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAABOSURBVGhD7c4xAQAgDAAx9I9h6Q8O3kQk5+0BAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgBx5hBQHXQ1JQAAAAAElFTkSuQmCC');
opacity: 0.03;
pointer-events: none;
z-index: 15;
}
#game {
display: block;
width: 100%;
height: 100%;
background: #000;
border-radius: 5px;
}
.crt-reflection {
position: absolute;
top: 50%;
left: 50%;
width: 100%;
height: 100%;
background: linear-gradient(135deg, rgba(0,255,0,0.1) 0%, transparent 50%);
transform: translate(-50%, -50%);
pointer-events: none;
z-index: 20;
}
.crt-label {
position: absolute;
bottom: 10px;
right: 20px;
color: #0f0;
font-size: 12px;
text-shadow: 0 0 5px #0f0;
z-index: 30;
}
.crt-power {
position: absolute;
bottom: 10px;
left: 20px;
color: #0f0;
font-size: 12px;
text-shadow: 0 0 5px #0f0;
z-index: 30;
}
.crt-power::before {
content: "";
display: inline-block;
width: 8px;
height: 8px;
background: #0f0;
border-radius: 50%;
margin-right: 5px;
box-shadow: 0 0 5px #0f0;
animation: power-pulse 1s infinite alternate;
}
@keyframes power-pulse {
0% { opacity: 0.5; }
100% { opacity: 1; }
}
@keyframes flicker {
0% { opacity: 0.9; }
5% { opacity: 0.8; }
10% { opacity: 0.95; }
15% { opacity: 0.85; }
20% { opacity: 1; }
25% { opacity: 0.9; }
30% { opacity: 0.98; }
35% { opacity: 0.87; }
40% { opacity: 0.94; }
45% { opacity: 0.91; }
50% { opacity: 0.99; }
100% { opacity: 1; }
}
.flicker {
animation: flicker 0.1s infinite;
}
</style>
</head>
<body class="bg-black flex items-center justify-center h-screen">
<div id="crt-screen" class="relative">
<div id="crt-glow"></div>
<div id="crt-curve"></div>
<canvas id="game" width="800" height="600"></canvas>
<div id="crt-effect"></div>
<div id="crt-noise"></div>
<div class="crt-reflection"></div>
<div class="crt-power">POWER</div>
<div class="crt-label">CHAOS CANNON v1.0</div>
</div>
<script>
const canvas = document.getElementById('game');
const ctx = canvas.getContext('2d');
const audioContext = new (window.AudioContext || window.webkitAudioContext)();
// Add vintage color palette
const colors = {
background: '#0a0a0a',
turretBase: '#00ff00',
turretBarrel: '#00cc00',
projectile: '#ff6600',
enemy: '#00ff00',
text: '#00ff00',
particle1: '#ff3300',
particle2: '#ff9900',
particle3: '#ffff00'
};
class Game {
constructor() {
this.state = 'title';
this.score = 0;
this.shake = 0;
this.turret = new Turret();
this.projectiles = [];
this.enemies = [];
this.particles = [];
this.explosions = [];
this.flickerTimer = 0;
canvas.addEventListener('click', (e) => {
if(this.state === 'title') {
this.start();
} else if(this.state === 'playing') {
this.turret.shoot(this);
}
});
canvas.addEventListener('mousemove', (e) => {
this.turret.angle = Math.atan2(
e.clientY - canvas.offsetTop - this.turret.y,
e.clientX - canvas.offsetLeft - this.turret.x
);
});
}
start() {
this.state = 'playing';
this.score = 0;
this.spawnEnemies();
}
spawnEnemies() {
setInterval(() => {
this.enemies.push(new Enemy(
Math.random() * canvas.width,
-50,
Math.random() * 2 + 1
));
}, 1500);
}
update() {
if(this.state !== 'playing') return;
this.flickerTimer++;
if(this.flickerTimer > 10) {
this.flickerTimer = 0;
document.getElementById('crt-effect').classList.toggle('flicker');
}
// Update all entities
this.turret.update();
this.projectiles.forEach(p => p.update(this));
this.enemies.forEach(e => e.update(this));
this.particles.forEach(p => p.update());
this.explosions.forEach(e => e.update(this));
// Check collisions
this.projectiles.forEach(projectile => {
this.enemies.forEach((enemy, i) => {
if(Math.hypot(
projectile.x - enemy.x,
projectile.y - enemy.y
) < 20) {
this.explosions.push(new Explosion(enemy.x, enemy.y));
this.enemies.splice(i, 1);
this.score += 100;
this.shake = 10;
this.playExplosionSound();
}
});
});
// Cleanup
this.projectiles = this.projectiles.filter(p => !p.dead);
this.particles = this.particles.filter(p => !p.dead);
this.explosions = this.explosions.filter(e => !e.dead);
}
draw() {
ctx.save();
if(this.shake > 0) {
ctx.translate(
Math.random() * this.shake - this.shake/2,
Math.random() * this.shake - this.shake/2
);
this.shake *= 0.9;
}
// Draw scanlines effect
ctx.fillStyle = 'rgba(0, 20, 0, 0.3)';
for(let y = 0; y < canvas.height; y += 2) {
ctx.fillRect(0, y, canvas.width, 1);
}
// Draw vignette
const gradient = ctx.createRadialGradient(
canvas.width/2, canvas.height/2, 0,
canvas.width/2, canvas.height/2, Math.max(canvas.width, canvas.height)/2
);
gradient.addColorStop(0, 'rgba(0, 0, 0, 0)');
gradient.addColorStop(0.7, 'rgba(0, 10, 0, 0.5)');
gradient.addColorStop(1, 'rgba(0, 20, 0, 0.8)');
ctx.fillStyle = gradient;
ctx.fillRect(0, 0, canvas.width, canvas.height);
// Draw all entities
this.turret.draw(ctx);
this.projectiles.forEach(p => p.draw(ctx));
this.enemies.forEach(e => e.draw(ctx));
this.particles.forEach(p => p.draw(ctx));
this.explosions.forEach(e => e.draw(ctx));
// UI
ctx.fillStyle = colors.text;
ctx.font = '20px "Courier New", monospace';
ctx.fillText(`SCORE: ${this.score}`, 20, 30);
if(this.state === 'title') {
ctx.fillStyle = 'rgba(0,0,0,0.8)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
// Title text with glow effect
ctx.fillStyle = colors.text;
ctx.font = 'bold 48px "Courier New", monospace';
const title = 'CHAOS CANNON';
const titleWidth = ctx.measureText(title).width;
ctx.fillText(title, canvas.width/2 - titleWidth/2, canvas.height/2);
// Glow effect
for(let i = 0; i < 3; i++) {
ctx.strokeStyle = `rgba(0, 255, 0, ${0.3 - i*0.1})`;
ctx.lineWidth = 5 - i*2;
ctx.strokeText(title, canvas.width/2 - titleWidth/2, canvas.height/2);
}
ctx.font = '24px "Courier New", monospace';
ctx.fillText('CLICK TO START', canvas.width/2 - 100, canvas.height/2 + 50);
}
ctx.restore();
}
playExplosionSound() {
const oscillator = audioContext.createOscillator();
const gainNode = audioContext.createGain();
oscillator.connect(gainNode);
gainNode.connect(audioContext.destination);
oscillator.type = 'square';
oscillator.frequency.value = 100 + Math.random() * 100;
gainNode.gain.setValueAtTime(0.2, audioContext.currentTime);
gainNode.gain.exponentialRampToValueAtTime(0.01, audioContext.currentTime + 0.3);
oscillator.start();
oscillator.stop(audioContext.currentTime + 0.3);
}
}
class Turret {
constructor() {
this.x = canvas.width/2;
this.y = canvas.height - 50;
this.angle = 0;
this.cooldown = 0;
}
update() {
if(this.cooldown > 0) this.cooldown--;
}
shoot(game) {
if(this.cooldown <= 0) {
game.projectiles.push(new Projectile(
this.x + Math.cos(this.angle) * 40,
this.y + Math.sin(this.angle) * 40,
Math.cos(this.angle) * 15,
Math.sin(this.angle) * 15
));
this.cooldown = 10;
}
}
draw(ctx) {
ctx.save();
ctx.translate(this.x, this.y);
ctx.rotate(this.angle);
// Barrel
ctx.fillStyle = colors.turretBarrel;
ctx.fillRect(0, -5, 40, 10);
// Add barrel glow
const barrelGradient = ctx.createLinearGradient(0, -5, 40, 10);
barrelGradient.addColorStop(0, 'rgba(0, 255, 0, 0.8)');
barrelGradient.addColorStop(1, 'rgba(0, 200, 0, 0.8)');
ctx.fillStyle = barrelGradient;
ctx.fillRect(0, -5, 40, 10);
// Base
ctx.beginPath();
ctx.arc(0, 0, 30, 0, Math.PI * 2);
// Add base glow
const baseGradient = ctx.createRadialGradient(0, 0, 10, 0, 0, 30);
baseGradient.addColorStop(0, 'rgba(0, 255, 0, 0.8)');
baseGradient.addColorStop(1, 'rgba(0, 100, 0, 0.8)');
ctx.fillStyle = baseGradient;
ctx.fill();
ctx.restore();
}
}
class Projectile {
constructor(x, y, vx, vy) {
this.x = x;
this.y = y;
this.vx = vx;
this.vy = vy;
this.dead = false;
}
update(game) {
this.x += this.vx;
this.y += this.vy;
this.vy += 0.2;
if(this.y > canvas.height + 50) this.dead = true;
// Trail particles
const color = Math.random() > 0.5 ? colors.particle1 :
Math.random() > 0.5 ? colors.particle2 : colors.particle3;
game.particles.push(new Particle(
this.x, this.y,
this.vx * -0.2 + Math.random() * 2 - 1,
this.vy * -0.2 + Math.random() * 2 - 1,
color, 20
));
}
draw(ctx) {
// Add glow effect
const glowGradient = ctx.createRadialGradient(
this.x, this.y, 0,
this.x, this.y, 8
);
glowGradient.addColorStop(0, 'rgba(255, 100, 0, 0.8)');
glowGradient.addColorStop(1, 'rgba(255, 50, 0, 0)');
ctx.fillStyle = glowGradient;
ctx.beginPath();
ctx.arc(this.x, this.y, 8, 0, Math.PI * 2);
ctx.fill();
// Projectile core
ctx.fillStyle = colors.projectile;
ctx.beginPath();
ctx.arc(this.x, this.y, 3, 0, Math.PI * 2);
ctx.fill();
}
}
class Enemy {
constructor(x, y, speed) {
this.x = x;
this.y = y;
this.speed = speed;
this.flicker = 0;
}
update(game) {
this.y += this.speed;
this.flicker = (this.flicker + 1) % 10;
if(this.y > canvas.height - 50) {
game.state = 'gameover';
}
}
draw(ctx) {
ctx.save();
ctx.translate(this.x, this.y);
// Flicker effect
if(this.flicker < 2) {
ctx.fillStyle = 'rgba(0, 255, 0, 0.7)';
} else {
ctx.fillStyle = colors.enemy;
}
ctx.beginPath();
ctx.moveTo(-15, 0);
ctx.lineTo(15, 0);
ctx.lineTo(0, 30);
ctx.fill();
// Add glow
const glowGradient = ctx.createLinearGradient(-15, 0, 15, 30);
glowGradient.addColorStop(0, 'rgba(0, 255, 0, 0.3)');
glowGradient.addColorStop(1, 'rgba(0, 150, 0, 0.3)');
ctx.fillStyle = glowGradient;
ctx.beginPath();
ctx.moveTo(-15, 0);
ctx.lineTo(15, 0);
ctx.lineTo(0, 30);
ctx.fill();
ctx.restore();
}
}
class Explosion {
constructor(x, y) {
this.x = x;
this.y = y;
this.particles = [];
this.dead = false;
for(let i = 0; i < 50; i++) {
const hue = Math.random() * 30 + 20;
this.particles.push(new Particle(
x, y,
Math.random() * 10 - 5,
Math.random() * 10 - 5,
`hsl(${hue}, 100%, 50%)`,
40
));
}
}
update(game) {
this.particles.forEach(p => p.update());
this.dead = this.particles.every(p => p.dead);
}
draw(ctx) {
this.particles.forEach(p => p.draw(ctx));
// Add explosion glow
if(!this.dead) {
const glowGradient = ctx.createRadialGradient(
this.x, this.y, 0,
this.x, this.y, 50
);
glowGradient.addColorStop(0, 'rgba(255, 100, 0, 0.5)');
glowGradient.addColorStop(1, 'rgba(255, 50, 0, 0)');
ctx.fillStyle = glowGradient;
ctx.beginPath();
ctx.arc(this.x, this.y, 50, 0, Math.PI * 2);
ctx.fill();
}
}
}
class Particle {
constructor(x, y, vx, vy, color, life) {
this.x = x;
this.y = y;
this.vx = vx;
this.vy = vy;
this.color = color;
this.life = life;
this.dead = false;
this.size = Math.random() * 3 + 1;
}
update() {
this.x += this.vx;
this.y += this.vy;
this.vy += 0.1;
this.life -= 1;
this.dead = this.life <= 0;
}
draw(ctx) {
// Add glow
const glowGradient = ctx.createRadialGradient(
this.x, this.y, 0,
this.x, this.y, this.size * 2
);
glowGradient.addColorStop(0, this.color);
glowGradient.addColorStop(1, 'rgba(255, 255, 0, 0)');
ctx.fillStyle = glowGradient;
ctx.beginPath();
ctx.arc(this.x, this.y, this.size * 2, 0, Math.PI * 2);
ctx.fill();
// Particle core
ctx.fillStyle = this.color;
ctx.beginPath();
ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
ctx.fill();
}
}
// Game loop
const game = new Game();
function frame() {
game.update();
game.draw();
requestAnimationFrame(frame);
}
frame();
// Add CRT power on effect
setTimeout(() => {
document.getElementById('crt-screen').style.boxShadow =
'0 0 20px rgba(0, 255, 0, 0.5), inset 0 0 50px rgba(0, 255, 0, 0.2)';
}, 500);
</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=LukasBe/chaos-cannon-crt" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html> |