Meta Description" name="description" />
<!DOCTYPE html>
<html>
<head>
<title>Neon Blaster</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<style>
body { margin: 0; background: #050505; overflow: hidden; font-family: 'Courier New', Courier, monospace; touch-action: none; }
canvas { display: block; }
#ui { position: absolute; top: 10px; left: 10px; color: #0f0; font-size: 18px; pointer-events: none; }
</style>
</head>
<body>
<div id="ui">SCORE: 0</div>
<canvas id="game"></canvas>
<script>
const canvas = document.getElementById('game');
const ctx = canvas.getContext('2d');
const scoreDiv = document.getElementById('ui');
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
let score = 0;
let gameActive = true;
const player = { x: canvas.width/2, y: canvas.height - 100, size: 25 };
const projectiles = [];
const enemies = [];
let lastShot = 0;
// --- Controls ---
function handleInput(e) {
if(!gameActive) return;
const x = e.touches ? e.touches[0].clientX : e.clientX;
const y = e.touches ? e.touches[0].clientY : e.clientY;
player.x = x;
player.y = y - 40; // Offset so finger doesn't block ship
}
window.addEventListener('mousemove', handleInput);
window.addEventListener('touchmove', (e) => { e.preventDefault(); handleInput(e); }, {passive: false});
function spawnEnemy() {
if (!gameActive) return;
enemies.push({
x: Math.random() * (canvas.width - 20) + 10,
y: -20,
speed: 2 + (score / 50),
hp: 1
});
setTimeout(spawnEnemy, Math.max(200, 1000 - (score * 5)));
}
function update() {
if (!gameActive) return;
ctx.fillStyle = 'rgba(0, 0, 0, 0.3)'; // Trail effect
ctx.fillRect(0, 0, canvas.width, canvas.height);
// --- Player ---
ctx.strokeStyle = '#0f0';
ctx.lineWidth = 3;
ctx.beginPath();
ctx.moveTo(player.x, player.y - 15);
ctx.lineTo(player.x - 15, player.y + 15);
ctx.lineTo(player.x + 15, player.y + 15);
ctx.closePath();
ctx.stroke();
// --- Auto-Fire ---
const now = Date.now();
if (now - lastShot > 200) {
projectiles.push({ x: player.x, y: player.y - 15 });
lastShot = now;
}
// --- Projectiles ---
projectiles.forEach((p, i) => {
p.y -= 10;
ctx.fillStyle = '#ff0';
ctx.fillRect(p.x - 2, p.y, 4, 15);
if (p.y < 0) projectiles.splice(i, 1);
});
// --- Enemies ---
enemies.forEach((en, ei) => {
en.y += en.speed;
ctx.strokeStyle = '#f00';
ctx.beginPath();
ctx.arc(en.x, en.y, 15, 0, Math.PI * 2);
ctx.stroke();
// Collision: Bullet vs Enemy
projectiles.forEach((p, pi) => {
const dist = Math.hypot(p.x - en.x, p.y - en.y);
if (dist < 20) {
enemies.splice(ei, 1);
projectiles.splice(pi, 1);
score += 10;
scoreDiv.innerText = "SCORE: " + score;
}
});
// Collision: Player vs Enemy
if (Math.hypot(player.x - en.x, player.y - en.y) < 25) {
gameActive = false;
alert("GAME OVER\nFinal Score: " + score);
location.reload();
}
if (en.y > canvas.height) enemies.splice(ei, 1);
});
requestAnimationFrame(update);
}
spawnEnemy();
update();
</script>
</body>
</html>
1
1
4KB
4KB
120.0ms
188.0ms
121.0ms