<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>NEON RUNNER: AI Uprising – Enhanced</title>
<style>
body {
margin: 0;
background: radial-gradient(#000, #0a0a1a);
color: #fff;
font-family: 'Courier New', monospace;
overflow: hidden;
}
canvas {
display: block;
margin: 0 auto;
background: linear-gradient(to bottom, #000 0%, #0a0a1a 100%);
box-shadow: inset 0 0 50px #00f5ff;
}
#info {
position: absolute;
top: 10px;
left: 10px;
font-size: 14px;
color: #00f5ff;
background: rgba(0, 0, 0, 0.6);
padding: 10px;
border-radius: 8px;
z-index: 10;
}
</style>
</head>
<body>
<div id="info">
<strong>NEON RUNNER: AI Uprising</strong><br/>
Arrow Keys / WASD: Move<br/>
Space: Jump<br/>
E / Click: Use Ability<br/>
Q: Cycle Abilities<br/>
R: Restart<br/>
<div id="abilities"></div>
</div>
<canvas id="game" width="1280" height="720"></canvas>
<script>
const canvas = document.getElementById("game");
const ctx = canvas.getContext("2d");
let keys = {};
let mouse = { x: 0, y: 0, pressed: false };
let level = 0; // Start at level 0
let gameOver = false;
const GRAVITY = 0.5;
const FRICTION = 0.8;
const gameWidth = canvas.width;
const gameHeight = canvas.height;
const abilities = [
{ name: "Dash", cooldown: 0, maxCooldown: 30 }, // Quick movement
{ name: "EMP", cooldown: 0, maxCooldown: 200 }, // Area damage
{ name: "Drone", cooldown: 0, maxCooldown: 300 } // Homing attack
];
let selectedAbility = 0;
const levelData = [
{
name: "Sector 7: Slums",
terrain: [
{ x: 0, y: 600, w: 1400, h: 120, type: "ground" },
{ x: 300, y: 500, w: 100, h: 80, type: "platform" },
{ x: 500, y: 400, w: 120, h: 80, type: "destructible" }, // Destructible
{ x: 800, y: 300, w: 100, h: 80, type: "terminal" } // Security
],
enemies: [
{ x: 400, y: 550, type: "standard", health: 20, speed: 1.5, evolveLevel: 1 },
{ x: 600, y: 550, type: "standard", health: 20, speed: 1.5, evolveLevel: 1 }
],
civilians: [
{ x: 350, y: 450, rescued: false },
{ x: 650, y: 350, rescued: false }
],
upgrades: [
{ x: 200, y: 550, type: "speed", collected: false },
{ x: 900, y: 250, type: "energy", collected: false }
],
boss: null
},
{
name: "Sector Core: AI Nexus",
terrain: [
{ x: 0, y: 600, w: 1400, h: 120, type: "ground" },
{ x: 400, y: 400, w: 120, h: 80, type: "destructible" },
{ x: 800, y: 200, w: 100, h: 80, type: "terminal" },
{ x: 1100, y: 300, w: 150, h: 100, type: "boss" } // Boss area
],
enemies: [
{ x: 500, y: 550, type: "elite", health: 30, speed: 2, evolveLevel: 2 },
{ x: 900, y: 550, type: "elite", health: 30, speed: 2, evolveLevel: 2 }
],
civilians: [
{ x: 450, y: 350, rescued: false }
],
upgrades: [
{ x: 300, y: 550, type: "drone", collected: false }
],
boss: { x: 1100, y: 400, health: 100, maxHealth: 100, speed: 1, immuneTo: [] } // Can be modified
}
];
let player = {
x: 50,
y: 500,
vx: 0,
vy: 0,
width: 30,
height: 50,
onGround: false,
speed: 4,
jumpPower: 10,
energy: 100,
maxEnergy: 100,
dronePower: 1,
upgrades: { speed: false, energy: false, drone: false }
};
function drawRect(x, y, w, h, color) {
ctx.fillStyle = color;
ctx.fillRect(x, y, w, h);
}
function drawText(text, x, y) {
ctx.fillStyle = "#00f5ff";
ctx.font = "20px Arial";
ctx.fillText(text, x, y);
}
function resetLevel() {
// Reset player and game state
player = { ...player, x: 50, y: 500, vx: 0, vy: 0, energy: 100 };
levelData[level].enemies.forEach(e => { e.health = e.type === "standard" ? 20 : 30; e.speed = e.evolveLevel <= level ? e.speed + 0.5 : e.speed; });
levelData[level].civilians.forEach(c => c.rescued = false);
levelData[level].upgrades.forEach(u => u.collected = false);
if (levelData[level].boss) levelData[level].boss.health = levelData[level].boss.maxHealth;
gameOver = false;
}
function update() {
if (gameOver) return;
// Player Movement (Frame-by-Frame Logic)
if (keys["ArrowLeft"] || keys["a"]) player.vx -= 0.5;
if (keys["ArrowRight"] || keys["d"]) player.vx += 0.5;
if ((keys["ArrowUp"] || keys["w"] || keys[" "]) && player.onGround) player.vy = -player.jumpPower;
player.vx *= FRICTION;
player.vy += GRAVITY;
player.x += player.vx;
player.y += player.vy;
player.onGround = false;
// Terrain Collision
for (const obj of levelData[level].terrain) {
if (player.x + player.width > obj.x && player.x < obj.x + obj.w && player.y + player.height > obj.y && player.y < obj.y + obj.h) {
if (player.vy > 0 && obj.type !== "destructible") { player.y = obj.y - player.height; player.vy = 0; player.onGround = true; }
if (obj.type === "destructible" && abilities[selectedAbility].name === "EMP") obj.w -= 10; // Destructible logic
}
}
// Abilities and Input
if (keys["q"]) selectedAbility = (selectedAbility + 1) % abilities.length;
if ((keys["e"] || mouse.pressed) && abilities[selectedAbility].cooldown <= 0) useAbility();
abilities.forEach(ab => ab.cooldown > 0 && ab.cooldown--);
// Evolving Enemy AI (Frame-by-Frame Behavior)
for (let e of levelData[level].enemies) {
if (e.health > 0) {
let dx = player.x - e.x;
let dy = player.y - e.y;
let dist = Math.sqrt(dx * dx + dy * dy);
if (dist < 200) e.x += Math.sign(dx) * e.speed; // Basic pursuit
if (e.evolveLevel <= level) e.speed += 0.1; // Evolve by increasing speed
if (dist < 30) player.energy -= 0.5;
}
}
// Civilians and Upgrades
for (let c of levelData[level].civilians) if (!c.rescued && dist(player.x, player.y, c.x, c.y) < 50) c.rescued = true;
for (let u of levelData[level].upgrades) if (!u.collected && dist(player.x, player.y, u.x, u.y) < 30) { u.collected = true; player.upgrades[u.type] = true; }
// Boss Combat
if (levelData[level].boss) {
let boss = levelData[level].boss;
let dx = player.x - boss.x;
if (Math.abs(dx) < 100) boss.x += Math.sign(dx) * boss.speed;
if (dist(player.x, player.y, boss.x, boss.y) < 50) player.energy -= 1;
}
// Win/Loss Conditions
if (player.energy <= 0) { gameOver = true; drawText("DEAD", gameWidth / 2 - 50, gameHeight / 2); }
if (levelData[level].civilians.every(c => c.rescued) && levelData[level].boss && levelData[level].boss.health <= 0) { gameOver = true; drawText("MISSION SUCCESS", gameWidth / 2 - 100, gameHeight / 2); }
}
function useAbility() {
// Ability Logic (Frame-by-Frame Execution)
switch (abilities[selectedAbility].name) {
case "Dash": player.vx += player.speed * 5; break;
case "EMP": levelData[level].enemies.forEach(e => e.health -= 5); break;
case "Drone": levelData[level].enemies.forEach(e => { if (dist(player.x, player.y, e.x, e.y) < 150) e.health -= player.dronePower; }); break;
}
abilities[selectedAbility].cooldown = abilities[selectedAbility].maxCooldown;
}
function dist(x1, y1, x2, y2) { return Math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2); }
function draw() {
ctx.clearRect(0, 0, gameWidth, gameHeight);
// Draw elements (Frame-by-Frame Rendering)
drawRect(0, 0, gameWidth, gameHeight, "#000");
for (const obj of levelData[level].terrain) drawRect(obj.x, obj.y, obj.w, obj.h, obj.type === "destructible" ? "#990000" : "#333");
for (let c of levelData[level].civilians) if (!c.rescued) drawRect(c.x, c.y, 20, 40, "#00ffcc");
for (let u of levelData[level].upgrades) if (!u.collected) drawRect(u.x, u.y, 20, 20, "#ffff00");
drawRect(player.x, player.y, player.width, player.height, "#00f5ff");
for (let e of levelData[level].enemies) if (e.health > 0) drawRect(e.x, e.y, 30, 40, "#ff3333");
if (levelData[level].boss) { let boss = levelData[level].boss; drawRect(boss.x, boss.y, 60, 80, "#990099"); drawRect(boss.x, boss.y - 10, (boss.health / boss.maxHealth) * 60, 5, "#00ff00"); }
document.getElementById("abilities").innerHTML = `<strong>Ability:</strong> ${abilities[selectedAbility].name} | Energy: ${Math.floor(player.energy)}`;
}
function gameLoop() { update(); draw(); if (!gameOver) requestAnimationFrame(gameLoop); }
window.addEventListener("keydown", e => keys[e.key] = true);
window.addEventListener("keyup", e => keys[e.key] = false);
window.addEventListener("mousedown", e => mouse.pressed = true);
window.addEventListener("mouseup", e => mouse.pressed = false);
window.addEventListener("keydown", e => { if (e.key === "r") resetLevel(); });
resetLevel();
gameLoop();
</script>
</body>
</html>