<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>NEON REVOLT: UPRISING</title>
<link href="https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&display=swap" rel="stylesheet">
<style>
body { margin: 0; background-color: #010103; overflow: hidden; }
canvas { display: block; background: #0c0a14; }
.hud {
position: absolute;
top: 20px;
left: 20px;
color: #00ffff;
font-family: 'Orbitron', sans-serif;
text-shadow: 0 0 5px #00ffff;
}
.hud p { margin: 5px 0; }
.overlay {
position: absolute;
top: 0; left: 0; right: 0; bottom: 0;
background: rgba(12, 10, 20, 0.9);
color: #fff;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
font-family: 'Orbitron', sans-serif;
text-align: center;
}
.overlay h1 { font-size: 4em; color: #00ffff; text-shadow: 0 0 10px #00ffff, 0 0 20px #ff00c3; }
.overlay p { font-size: 1.2em; max-width: 600px; color: #e0e0e0; line-height: 1.5; }
.overlay button {
background: transparent;
border: 2px solid #00ffff;
color: #00ffff;
padding: 15px 30px;
font-size: 1.2em;
cursor: pointer;
transition: all 0.3s;
margin-top: 20px;
}
.overlay button:hover { background: #00ffff; color: #0c0a14; box-shadow: 0 0 20px #00ffff; }
</style>
</head>
<body>
<div id="hud" class="hud">
<p>HEALTH: <span id="health">100</span></p>
<p>ENERGY: <span id="energy">100</span></p>
<p>OBJECTIVES: <span id="objectives"></span></p>
</div>
<div id="start-screen" class="overlay">
<h1>NEON REVOLT</h1>
<p>The city AI has turned. Use your abilities to fight back, rescue civilians, and confront the Warden at the city core.</p>
<p>Controls: [A/D] Move | [W/Space] Jump | [J] Shoot | [K] Dash | [L] EMP</p>
<button id="start-button">BEGIN UPRISING</button>
</div>
<div id="end-screen" class="overlay" style="display: none;">
<h1 id="end-title"></h1>
<p id="end-message"></p>
<button id="restart-button">RETRY</button>
</div>
<canvas id="game-canvas"></canvas>
<script>
// --- GAME CONFIGURATION & MODIFIABLE PARAMETERS ---
const CONFIG = {
playerHasJetpack: false,
stealthMechanics: { enabled: false, visibilityRadius: 200 },
bossImmunity: null, // Can be 'EMP', 'DataSpike'
};
// --- CORE GAME SETUP ---
const canvas = document.getElementById('game-canvas');
const ctx = canvas.getContext('2d');
const hudHealth = document.getElementById('health');
const hudEnergy = document.getElementById('energy');
const hudObjectives = document.getElementById('objectives');
const startScreen = document.getElementById('start-screen');
const endScreen = document.getElementById('end-screen');
const startButton = document.getElementById('start-button');
const restartButton = document.getElementById('restart-button');
canvas.width = 1280;
canvas.height = 720;
const GRAVITY = 0.6;
const keys = {};
class Player {
constructor() { this.reset(); }
reset() {
this.x = 100; this.y = 500; this.width = 30; this.height = 48;
this.vx = 0; this.vy = 0;
this.speed = 5; this.jumpPower = 14; this.onGround = false;
this.health = 100; this.maxHealth = 100;
this.energy = 100; this.maxEnergy = 100;
this.dataSpikeDamage = 10; this.upgrades = 0;
this.dashCooldown = 0; this.empCooldown = 0;
this.invulnerable = 0;
}
update() {
// --- MOVEMENT LOGIC ---
if (keys['a'] || keys['ArrowLeft']) this.vx = -this.speed;
else if (keys['d'] || keys['ArrowRight']) this.vx = this.speed;
else this.vx = 0;
if ((keys['w'] || keys['ArrowUp'] || keys[' ']) && this.onGround) {
this.vy = -this.jumpPower;
this.onGround = false;
}
// JETPACK MODIFICATION LOGIC
if (CONFIG.playerHasJetpack && (keys['w'] || keys['ArrowUp'] || keys[' ']) && this.energy > 0) {
this.vy -= 0.5;
this.energy -= 0.5;
}
this.vy += GRAVITY;
this.y += this.vy;
this.x += this.vx;
this.onGround = false;
// --- ABILITY LOGIC ---
if ((keys['j'] || keys['z']) && this.energy >= 10) this.shoot();
if ((keys['k'] || keys['x']) && this.dashCooldown === 0 && this.energy >= 20) this.dash();
if ((keys['l'] || keys['c']) && this.empCooldown === 0 && this.energy >= 40) this.emp();
this.dashCooldown = Math.max(0, this.dashCooldown - 1);
this.empCooldown = Math.max(0, this.empCooldown - 1);
this.invulnerable = Math.max(0, this.invulnerable - 1);
this.energy = Math.min(this.maxEnergy, this.energy + 0.1);
// Clamp player to screen
if (this.x < 0) this.x = 0;
if (this.x + this.width > world.width) this.x = world.width - this.width;
}
draw() {
ctx.fillStyle = this.invulnerable > 0 ? '#ff00c3' : '#00ffff';
ctx.fillRect(this.x, this.y, this.width, this.height);
ctx.fillStyle = '#fff';
ctx.fillRect(this.x + 8, this.y + 10, 4, 12);
ctx.fillRect(this.x + 18, this.y + 10, 4, 12);
}
shoot() {
if (this.energy < 10) return;
this.energy -= 10;
const projectile = new Projectile(this.x + this.width / 2, this.y + 20, this.vx > 0 || !keys['a']);
world.projectiles.push(projectile);
keys['j'] = keys['z'] = false; // Prevent holding down
}
dash() {
this.energy -= 20;
this.dashCooldown = 60;
const dashDirection = (keys['d'] || keys['ArrowRight']) ? 1 : -1;
this.x += 150 * dashDirection;
this.invulnerable = 20; // Invulnerable during dash
world.createParticles(this.x, this.y, 10, '#ff00c3');
}
emp() {
this.energy -= 40;
this.empCooldown = 200;
world.createEMP(this.x, this.y);
}
takeDamage(amount) {
if (this.invulnerable > 0) return;
this.health -= amount;
this.invulnerable = 120; // 2 seconds of invulnerability
world.screenShake = 15;
if (this.health <= 0) world.gameOver(false);
}
}
class Projectile {
constructor(x, y, goingRight) {
this.x = x; this.y = y; this.width = 15; this.height = 5;
this.speed = 15;
this.direction = goingRight ? 1 : -1;
}
update() { this.x += this.speed * this.direction; }
draw() { ctx.fillStyle = '#f0ff00'; ctx.fillRect(this.x, this.y, this.width, this.height); }
}
class Enemy {
constructor(x, y, type, path) {
this.x = x; this.y = y; this.type = type;
this.health = type === 'drone' ? 30 : 100;
this.width = type === 'drone' ? 40 : 50;
this.height = type === 'drone' ? 30 : 50;
this.vx = type === 'drone' ? 2 : 0;
this.path = path; this.stunned = 0;
this.isActive = type !== 'turret';
this.shootCooldown = 0;
}
update(player) {
if (this.stunned > 0) { this.stunned--; return; }
let playerVisible = true;
// STEALTH MODIFICATION LOGIC
if (CONFIG.stealthMechanics.enabled) {
const dist = Math.hypot(this.x - player.x, this.y - player.y);
if (dist > CONFIG.stealthMechanics.visibilityRadius) playerVisible = false;
}
if (this.type === 'drone' && playerVisible) {
if (this.x < this.path[0] || this.x > this.path[1]) this.vx *= -1;
this.x += this.vx;
}
if (this.type === 'turret') {
const distToPlayer = Math.hypot(this.x - player.x, this.y - player.y);
if (distToPlayer < 400 && playerVisible) this.isActive = true; else this.isActive = false;
if (this.isActive && this.shootCooldown <= 0) {
const angle = Math.atan2(player.y - this.y, player.x - this.x);
world.enemyProjectiles.push(new EnemyProjectile(this.x, this.y, angle));
this.shootCooldown = 120;
}
this.shootCooldown = Math.max(0, this.shootCooldown - 1);
}
}
draw() {
ctx.fillStyle = this.stunned > 0 ? '#555' : '#ff3c3c';
ctx.fillRect(this.x, this.y, this.width, this.height);
ctx.fillStyle = '#fff';
if(this.type === 'drone') ctx.fillRect(this.x + 15, this.y + 10, 10, 10);
if(this.type === 'turret' && this.isActive) ctx.fillStyle = '#f0ff00';
if(this.type === 'turret') ctx.fillRect(this.x + 20, this.y + 20, 10, 10);
}
}
class EnemyProjectile {
constructor(x, y, angle) {
this.x = x; this.y = y; this.radius = 5;
this.speed = 4;
this.vx = Math.cos(angle) * this.speed;
this.vy = Math.sin(angle) * this.speed;
}
update() { this.x += this.vx; this.y += this.vy; }
draw() { ctx.fillStyle = '#ff3c3c'; ctx.beginPath(); ctx.arc(this.x, this.y, this.radius, 0, Math.PI * 2); ctx.fill(); }
}
class Boss extends Enemy {
constructor(x, y) {
super(x, y, 'boss');
this.maxHealth = 500;
this.health = 500;
this.width = 100;
this.height = 100;
this.attackPattern = 'laser';
this.attackCooldown = 0;
}
update(player) {
if (this.stunned > 0) { this.stunned--; return; }
this.attackCooldown = Math.max(0, this.attackCooldown - 1);
if (this.attackCooldown === 0) {
const patternRoll = Math.random();
if (patternRoll < 0.6) this.attackPattern = 'volley'; // Fire 3 shots
else this.attackPattern = 'slam'; // Quick dash
this.attackCooldown = 180;
if (this.attackPattern === 'volley') {
for(let i = 0; i < 3; i++) {
setTimeout(() => {
const angle = Math.atan2(player.y - this.y, player.x - this.x);
world.enemyProjectiles.push(new EnemyProjectile(this.x, this.y, angle));
}, i * 200);
}
}
}
if (this.attackPattern === 'slam' && this.attackCooldown < 120 && this.attackCooldown > 110) {
this.x += (player.x - this.x) * 0.1;
}
}
draw() {
// Health bar
ctx.fillStyle = '#500';
ctx.fillRect(this.x, this.y - 20, this.width, 10);
ctx.fillStyle = '#ff3c3c';
ctx.fillRect(this.x, this.y - 20, this.width * (this.health / this.maxHealth), 10);
// Body
ctx.fillStyle = this.stunned > 0 ? '#555' : '#a00060';
ctx.fillRect(this.x, this.y, this.width, this.height);
}
}
class Particle {
constructor(x, y, color) {
this.x = x; this.y = y; this.color = color;
this.size = Math.random() * 5 + 2;
this.life = 60;
this.vx = (Math.random() - 0.5) * 4;
this.vy = (Math.random() - 0.5) * 4;
}
update() { this.x += this.vx; this.y += this.vy; this.life--; }
draw() { ctx.globalAlpha = this.life / 60; ctx.fillStyle = this.color; ctx.fillRect(this.x, this.y, this.size, this.size); ctx.globalAlpha = 1; }
}
const world = {
platforms: [], projectiles: [], enemyProjectiles: [], enemies: [], particles: [], civilians: [], terminals: [], upgrades: [],
width: 3840, height: 720, cameraX: 0, screenShake: 0,
reset() {
this.platforms = []; this.projectiles = []; this.enemyProjectiles = []; this.enemies = []; this.particles = [];
this.civilians = []; this.terminals = []; this.upgrades = []; this.boss = null;
// LEVEL DESIGN
this.platforms.push({ x: 0, y: 680, w: 800, h: 40 }); // Ground 1
this.platforms.push({ x: 300, y: 550, w: 200, h: 20 });
this.platforms.push({ x: 900, y: 680, w: 1000, h: 40 }); // Ground 2
this.platforms.push({ x: 1200, y: 500, w: 150, h: 20 });
this.platforms.push({ x: 1400, y: 400, w: 150, h: 20 });
this.platforms.push({ x: 1600, y: 300, w: 150, h: 20, type: 'destructible', health: 50 }); // Destructible Wall
this.platforms.push({ x: 2000, y: 680, w: 1840, h: 40 }); // Ground 3
this.platforms.push({ x: 2200, y: 550, w: 150, h: 20 });
this.platforms.push({ x: 2400, y: 450, w: 150, h: 20, type: 'laserGrid' }); // Laser Grid
this.platforms.push({ x: 3000, y: 200, w: 20, h: 480 }); // Wall before boss
this.platforms.push({ x: 3200, y: 680, w: 640, h: 40 }); // Boss Arena
this.enemies.push(new Enemy(600, 650, 'drone', [500, 750]));
this.enemies.push(new Enemy(1300, 650, 'turret'));
this.enemies.push(new Enemy(2600, 650, 'drone', [2500, 2800]));
this.boss = new Boss(3400, 580);
this.enemies.push(this.boss);
this.civilians.push({x: 400, y: 510, rescued: false});
this.civilians.push({x: 1450, y: 360, rescued: false});
this.civilians.push({x: 2250, y: 510, rescued: false});
this.terminals.push({x: 1800, y: 640, bypassed: false});
this.terminals.push({x: 2800, y: 640, bypassed: false});
this.upgrades.push({x: 1000, y: 640, collected: false});
this.player = new Player();
},
update() {
this.player.update();
this.handleCollisions(this.player);
this.projectiles.forEach((p, i) => { p.update(); if (p.x < 0 || p.x > this.width) this.projectiles.splice(i, 1); });
this.enemyProjectiles.forEach((p, i) => { p.update(); if (p.x < 0 || p.x > this.width) this.enemyProjectiles.splice(i, 1); });
this.enemies.forEach(e => e.update(this.player));
this.particles.forEach((p, i) => { p.update(); if (p.life <= 0) this.particles.splice(i, 1); });
this.checkObjectives();
// Camera follow
this.cameraX = this.player.x - canvas.width / 2;
if (this.cameraX < 0) this.cameraX = 0;
if (this.cameraX > this.width - canvas.width) this.cameraX = this.width - canvas.width;
if (this.screenShake > 0) this.screenShake--;
},
draw() {
ctx.save();
if(this.screenShake > 0) {
ctx.translate(Math.random() * this.screenShake - this.screenShake / 2, Math.random() * this.screenShake - this.screenShake / 2);
}
ctx.translate(-this.cameraX, 0);
// Draw entities
this.platforms.forEach(p => {
if(p.type === 'destructible') ctx.fillStyle = '#8B4513';
else if(p.type === 'laserGrid') ctx.fillStyle = 'rgba(255, 0, 195, 0.5)';
else ctx.fillStyle = '#444';
ctx.fillRect(p.x, p.y, p.w, p.h);
});
this.civilians.forEach(c => { if(!c.rescued) {ctx.fillStyle = '#33ff33'; ctx.fillRect(c.x, c.y, 20, 40);} });
this.terminals.forEach(t => { ctx.fillStyle = t.bypassed ? '#005500' : '#ffff00'; ctx.fillRect(t.x, t.y, 40, 40); });
this.upgrades.forEach(u => { if(!u.collected) {ctx.fillStyle = '#ff00c3'; ctx.fillRect(u.x, u.y, 20, 20); } });
this.projectiles.forEach(p => p.draw());
this.enemyProjectiles.forEach(p => p.draw());
this.enemies.forEach(e => e.draw());
this.particles.forEach(p => p.draw());
this.player.draw();
ctx.restore();
// HUD update
hudHealth.textContent = Math.max(0, Math.round(this.player.health));
hudEnergy.textContent = Math.round(this.player.energy);
},
handleCollisions(p) {
// Player vs Platforms
this.platforms.forEach(plat => {
if (p.x < plat.x + plat.w && p.x + p.width > plat.x && p.y < plat.y + plat.h && p.y + p.height > plat.y) {
if (plat.type === 'laserGrid' && p.invulnerable <= 0) {
p.takeDamage(10);
}
const pBottom = p.y + p.height;
if (p.vy >= 0 && pBottom - p.vy <= plat.y) {
p.y = plat.y - p.height; p.vy = 0; p.onGround = true;
} else if (p.vy < 0 && p.y > plat.y + plat.h - p.vy) { // Head bump
p.y = plat.y + plat.h; p.vy = 0;
} else if (p.vx > 0 && p.x + p.width - p.vx < plat.x) { // Side collision
p.x = plat.x - p.width;
} else if (p.vx < 0 && p.x - p.vx > plat.x + plat.w) {
p.x = plat.x + plat.w;
}
}
});
// Projectiles vs Enemies/Platforms
this.projectiles.forEach((proj, i) => {
this.enemies.forEach((enemy, j) => {
if (proj.x < enemy.x + enemy.width && proj.x + proj.width > enemy.x && proj.y < enemy.y + enemy.height && proj.y + proj.height > enemy.y) {
// BOSS IMMUNITY LOGIC
if (enemy.type === 'boss' && CONFIG.bossImmunity === 'DataSpike') return;
enemy.health -= this.player.dataSpikeDamage;
if(enemy.health <= 0) {
if (enemy.type === 'boss') this.gameOver(true); else this.enemies.splice(j, 1);
}
this.projectiles.splice(i, 1);
this.createParticles(proj.x, proj.y, 5, '#ff3c3c');
}
});
this.platforms.forEach(plat => {
if (plat.type === 'destructible' && proj.x < plat.x + plat.w && proj.x + proj.width > plat.x && proj.y < plat.y + plat.h && proj.y + proj.height > plat.y) {
plat.health -= this.player.dataSpikeDamage;
if(plat.health <= 0) plat.y = 9999; // "Destroy" it
this.projectiles.splice(i, 1);
}
});
});
// Enemy projectiles vs Player
this.enemyProjectiles.forEach((proj, i) => {
if (proj.x > p.x && proj.x < p.x + p.width && proj.y > p.y && proj.y < p.y + p.height) {
p.takeDamage(10);
this.enemyProjectiles.splice(i, 1);
}
});
// Player vs Collectibles
this.civilians.forEach(c => { if(!c.rescued && Math.hypot(p.x - c.x, p.y - c.y) < 50) c.rescued = true; });
this.upgrades.forEach(u => { if(!u.collected && Math.hypot(p.x - u.x, p.y - u.y) < 50) { u.collected = true; p.dataSpikeDamage += 5; }});
// Player vs Terminals
this.terminals.forEach(t => { if(!t.bypassed && Math.hypot(p.x - t.x, p.y - t.y) < 50) {
// Interact with 'L' (EMP)
if(keys['l'] || keys['c']) t.bypassed = true;
}});
},
createParticles(x, y, count, color) { for(let i=0; i<count; i++) this.particles.push(new Particle(x, y, color)); },
createEMP(x, y) {
this.createParticles(x, y, 50, '#00ffff');
this.enemies.forEach(e => {
if (Math.hypot(e.x - x, e.y - y) < 300) {
// BOSS IMMUNITY LOGIC
if (e.type === 'boss' && CONFIG.bossImmunity === 'EMP') return;
e.stunned = 300;
}
});
},
checkObjectives() {
const rescued = this.civilians.filter(c => c.rescued).length;
const bypassed = this.terminals.filter(t => t.bypassed).length;
hudObjectives.textContent = `Rescue: ${rescued}/3 | Bypass: ${bypassed}/2`;
},
gameOver(win) {
gameRunning = false;
document.getElementById('end-title').textContent = win ? "UPRISING SUCCESS" : "CONNECTION LOST";
document.getElementById('end-message').textContent = win ? "You've defeated the Warden and freed the city. A new dawn breaks over Aethelburg." : "Mainframe's control is absolute. Your light has faded into the neon glow.";
endScreen.style.display = 'flex';
}
};
let gameRunning = false;
function gameLoop() {
if (!gameRunning) return;
ctx.clearRect(0, 0, canvas.width, canvas.height);
world.update();
world.draw();
requestAnimationFrame(gameLoop);
}
// Event Listeners
window.addEventListener('keydown', e => keys[e.key.toLowerCase()] = true);
window.addEventListener('keyup', e => keys[e.key.toLowerCase()] = false);
startButton.addEventListener('click', () => {
startScreen.style.display = 'none';
world.reset();
gameRunning = true;
gameLoop();
});
restartButton.addEventListener('click', () => {
endScreen.style.display = 'none';
world.reset();
gameRunning = true;
gameLoop();
});
</script>
</body>
</html>