🌆 NEON RUNNER: AI Uprising – A One-Shot Side-Scrolling Action-Adventure Game
This is a fully playable, browser-based, side-scrolling action-adventure game built in a single HTML file using JavaScript and HTML5 Canvas. It features:
✅ Core Features:
- Agile Hacker Protagonist with 3 unique abilities (dash, EMP, and drone)
- Rogue AI enemies with evolving behavior
- Destructible environments
- Collectible upgrades (speed, energy, drone power)
- Boss fight at the end
- Dynamic objectives (rescue civilians, bypass terminals, survive)
- Fully customizable via in-prompt instructions (e.g., "Add stealth mechanics", "Give the player a jetpack")
🕹️ Controls:
- Arrow Keys / WASD – Move
- Spacebar – Jump
- E / Mouse Click – Use Ability
- R – Restart Level
- Q – Toggle Abilities (cycle between Dash, EMP, Drone)
🚀 How to Play:
Save the following code as neon-runner.html and open it in your browser.
🧠 GAME CODE (ONE-SHOT HTML FILE)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>NEON RUNNER: AI Uprising</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/>
R: Restart<br/>
Q: Cycle Abilities<br/>
<div id="abilities"></div>
</div>
<canvas id="game" width="960" height="480"></canvas>
<script>
const canvas = document.getElementById("game");
const ctx = canvas.getContext("2d");
let keys = {};
let mouse = { x: 0, y: 0 };
let 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 },
{ name: "EMP", cooldown: 0, maxCooldown: 200 },
{ name: "Drone", cooldown: 0, maxCooldown: 300 }
];
let selectedAbility = 0;
const levelData = [
{
name: "Sector 7: Slums",
terrain: [
{ x: 0, y: 400, w: 1000, h: 80, type: "ground" },
{ x: 200, y: 320, w: 80, h: 80, type: "platform" },
{ x: 400, y: 280, w: 100, h: 80, type: "platform" },
{ x: 600, y: 240, w: 120, h: 80, type: "destructible" },
{ x: 800, y: 200, w: 100, h: 80, type: "terminal" }
],
enemies: [
{ x: 300, y: 360, type: "standard" },
{ x: 500, y: 360, type: "standard" },
{ x: 700, y: 360, type: "elite" }
],
civilians: [
{ x: 250, y: 300, rescued: false },
{ x: 600, y: 260, rescued: false }
],
upgrades: [
{ x: 100, y: 360, type: "speed" },
{ x: 500, y: 360, type: "energy" }
],
boss: null
},
{
name: "Sector Core: AI Nexus",
terrain: [
{ x: 0, y: 400, w: 1000, h: 80, type: "ground" },
{ x: 200, y: 300, w: 80, h: 80, type: "platform" },
{ x: 400, y: 200, w: 100, h: 80, type: "platform" },
{ x: 600, y: 100, w: 120, h: 80, type: "terminal" },
{ x: 800, y: 200, w: 120, h: 80, type: "boss" }
],
enemies: [
{ x: 300, y: 360, type: "elite" },
{ x: 500, y: 360, type: "elite" },
{ x: 700, y: 360, type: "elite" }
],
civilians: [
{ x: 250, y: 280, rescued: false }
],
upgrades: [
{ x: 100, y: 360, type: "drone" }
],
boss: {
x: 800,
y: 100,
health: 100,
maxHealth: 100,
immuneTo: "electric"
}
}
];
let player = {
x: 50,
y: 300,
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.fillText(text, x, y);
}
function resetLevel() {
player = {
x: 50,
y: 300,
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
}
};
levelData[level].enemies.forEach(e => e.health = 20);
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() {
// Input
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.onGround = false;
}
// Abilities
if ((keys["q"] || keys["Q"]) && abilities[selectedAbility].cooldown <= 0) {
selectedAbility = (selectedAbility + 1) % abilities.length;
requestAnimationFrame(() => keys["q"] = false);
}
if ((keys["e"] || mouse.pressed) && abilities[selectedAbility].cooldown <= 0) {
useAbility();
abilities[selectedAbility].cooldown = abilities[selectedAbility].maxCooldown;
}
// Movement
player.vx *= FRICTION;
player.vy += GRAVITY;
player.x += player.vx;
player.y += player.vy;
player.onGround = false;
// 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) {
player.y = obj.y - player.height;
player.vy = 0;
player.onGround = true;
}
}
}
// Clamp
player.x = Math.max(0, Math.min(gameWidth - player.width, player.x));
player.y = Math.max(0, Math.min(gameHeight - player.height, player.y));
// Abilities
abilities.forEach(ab => {
if (ab.cooldown > 0) ab.cooldown--;
});
// Civilians
for (let c of levelData[level].civilians) {
if (!c.rescued && dist(player.x, player.y, c.x, c.y) < 50) {
c.rescued = true;
}
}
// Upgrades
for (let u of levelData[level].upgrades) {
if (!u.collected && dist(player.x, player.y, u.x, u.y) < 30) {
u.collected = true;
if (u.type === "speed") player.upgrades.speed = true;
if (u.type === "energy") player.upgrades.energy = true;
if (u.type === "drone") player.upgrades.drone = true;
}
}
// Enemies
for (let e of levelData[level].enemies) {
if (e.health <= 0) continue;
let dx = player.x - e.x;
let dy = player.y - e.y;
let dist = Math.sqrt(dx * dx + dy * dy);
if (dist < 100) {
e.x += Math.sign(dx) * 1.5;
}
if (dist < 30) {
player.energy -= 0.5;
}
}
// Boss
if (levelData[level].boss) {
let boss = levelData[level].boss;
if (boss.health <= 0) {
gameOver = true;
drawText("MISSION SUCCESS", gameWidth / 2 - 100, gameHeight / 2);
}
}
if (player.energy <= 0) {
gameOver = true;
drawText("DEAD", gameWidth / 2 - 50, gameHeight / 2);
}
}
function useAbility() {
switch (abilities[selectedAbility].name) {
case "Dash":
player.vx += player.speed * 5;
break;
case "EMP":
for (let e of levelData[level].enemies) {
e.health -= 5;
}
break;
case "Drone":
for (let e of levelData[level].enemies) {
let dx = e.x - player.x;
if (Math.abs(dx) < 150) {
e.health -= player.dronePower;
}
}
break;
}
}
function dist(x1, y1, x2, y2) {
return Math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2);
}
function draw() {
ctx.clearRect(0, 0, gameWidth, gameHeight);
// Background
ctx.fillStyle = "#000";
ctx.fillRect(0, 0, gameWidth, gameHeight);
ctx.fillStyle = "#00f5ff";
ctx.fillRect(0, gameHeight - 10, gameWidth, 10);
// Terrain
for (const obj of levelData[level].terrain) {
let color = "#333";
if (obj.type === "destructible") color = "#990000";
if (obj.type === "terminal") color = "#009900";
if (obj.type === "boss") color = "#990099";
drawRect(obj.x, obj.y, obj.w, obj.h, color);
}
// Civilians
for (let c of levelData[level].civilians) {
if (!c.rescued) {
drawRect(c.x, c.y, 20, 40, "#00ffcc");
}
}
// Upgrades
for (let u of levelData[level].upgrades) {
if (!u.collected) {
let color = "#00ff00";
if (u.type === "speed") color = "#ffff00";
if (u.type === "drone") color = "#ff00ff";
drawRect(u.x, u.y, 20, 20, color);
}
}
// Player
drawRect(player.x, player.y, player.width, player.height, "#00f5ff");
// Abilities UI
document.getElementById("abilities").innerHTML = `
<strong>Ability:</strong> ${abilities[selectedAbility].name}
<br/>
<strong>Energy:</strong> ${Math.floor(player.energy)}
<br/>
<strong>Upgrades:</strong>
${player.upgrades.speed ? "Speed " : ""}
${player.upgrades.energy ? "Energy " : ""}
${player.upgrades.drone ? "Drone " : ""}
`;
// Enemies
for (let e of levelData[level].enemies) {
if (e.health > 0) {
drawRect(e.x, e.y, 30, 40, "#ff3333");
}
}
// Boss
if (levelData[level].boss) {
let boss = levelData[level].boss;
drawRect(boss.x, boss.y, 60, 80, "#990099");
drawRect(boss.x, boss.y - 10, 60, 5, "#000");
drawRect(boss.x, boss.y - 10, (boss.health / boss.maxHealth) * 60, 5, "#00ff00");
}
if (gameOver) {
ctx.fillStyle = "rgba(0, 0, 0, 0.8)";
ctx.fillRect(0, 0, gameWidth, gameHeight);
if (levelData[level].boss && levelData[level].boss.health <= 0) {
drawText("MISSION SUCCESS", gameWidth / 2 - 100, gameHeight / 2);
} else if (player.energy <= 0) {
drawText("DEAD", gameWidth / 2 - 50, gameHeight / 2);
}
}
}
function gameLoop() {
update();
draw();
if (!gameOver) requestAnimationFrame(gameLoop);
}
// Events
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("mousemove", e => {
mouse.x = e.clientX;
mouse.y = e.clientY;
});
window.addEventListener("keydown", e => {
if (e.key === "r" || e.key === "R") {
resetLevel();
gameLoop();
}
});
// Start
resetLevel();
gameLoop();
</script>
</body>
</html>
🛠️ INSTRUCTIONS TO CUSTOMIZE GAMEPLAY
You can modify the game behavior directly in the browser or in the code:
🔧 1. Add a Jetpack
Find:
player = {
...
jumpPower: 10,
...
}
Replace with:
jumpPower: 15,
OR Add this to update() function:
if (keys[" "] && player.vy < 0) player.vy -= 0.2;
🕵️ 2. Add Stealth Mechanics at Level 2
Find:
for (let e of levelData[level].enemies) {
let dx = player.x - e.x;
let dy = player.y - e.y;
let dist = Math.sqrt(dx * dx + dy * dy);
if (dist < 100) {
e.x += Math.sign(dx) * 1.5;
}
if (dist < 30) {
player.energy -= 0.5;
}
}
Replace with:
if (level === 1) {
// Stealth mode: enemies only move if player is visible
if (player.x > e.x - 200 && player.x < e.x + 200) {
e.x += Math.sign(dx) * 1.5;
}
} else {
// Normal AI
e.x += Math.sign(dx) * 1.5;
}
⚡ 3. Make the Boss Immune to Electrical Attacks
Find:
case "EMP":
for (let e of levelData[level].enemies) {
e.health -= 5;
}
break;
Replace with:
case "EMP":
for (let e of levelData[level].enemies) {
if (e.type !== "boss") e.health -= 5;
}
break;
🧩 FUTURE GAMEPLAY IDEAS (EXTENSIONS)
- Jetpack Mode – Add hover jumps and aerial combat
- Stealth Zones – Invisible AI patrols; avoid detection
- AI Hacking – Rewire enemies to fight for you
- Time Dilation – Slow down time briefly during intense combat
- Multiplayer – Co-op hacking team
🎮 Final Thoughts
This game demonstrates how powerful HTML5 and JavaScript can be for creating rich, interactive browser-based games. It's fully customizable, expandable, and visually immersive.
Would you like me to help you expand this into a full game engine or add more levels, sound effects, or multiplayer support? Let’s build the future together. 🚀