How to Make a Shooter Game
How to Vibe Code an Action-Packed Shooter Game
Stay locked on target. Direct AI models to build 360-degree mouse aiming, switchable weapon arsenals, hitscan and projectile ballistics, enemy waves, and boss battles in a single HTML5 Canvas file in under 20 minutes.
Core Stack
HTML5 Canvas + JS
Ballistics
Hitscan & Projectiles
AI Partner
Claude / Gemini
Target Time
15–20 Mins
The Vibe Coding Shooter Philosophy
A great shooter game lives on punchy weapon feel, distinct enemy archetypes, escalating level waves, and high-score replayability. Traditional shooter development stalls on trigonometry aiming bugs, object-pooling boilerplate, and raycast collision math. Vibe coding puts you in the Combat Designer & Arsenal Director role: you specify the gunplay feel, screen shake, and enemy wave pacing while conversational AI generates the 60fps HTML5 Canvas loop.
Old-School Shooter Bottlenecks
- Debugging
Math.atan2aiming angles and bullet velocity vectors by hand. - Frame rate drops from forgetting to garbage-collect off-screen projectiles.
- Spending days rigging weapon prefabs before firing a single test shot.
- Flat, lifeless combat with zero muzzle flash, knockback, or hit-stop feedback.
The Vibe Coder Way
- Instant WASD + Mouse Crosshair arena shooter inside a single
index.htmlfile. - Describe the arsenal: "Pulse Rifle, Spread Shotgun, and Hitscan Railgun with weapon upgrades between waves."
- Prompt instant "game juice": "Add 4px camera shake on shotgun fire, glowing shell casings, and boss health bars."
- Track high scores and wave records automatically via
localStorage.
The 4-Step Blueprint
From a blank HTML canvas to surviving frenetic enemy waves and boss fights.
Lock In Movement & Crosshair Aiming
Start with responsive 8-directional WASD movement and 360-degree mouse aiming (or pseudo-3D raycasting if building a retro corridor FPS).
Prompt a Multi-Weapon Arsenal
A shooter isn't a shooter with only one gun. Prompt the AI for switchable weapons—e.g., Rapid Blaster, 5-Pellet Shotgun, and Hitscan Laser—plus an upgrade system for fire rate and damage.
Design Varied Enemies, Waves & Bosses
Create enemy variety: fast Swarmers, ranged Snipers, armored Tanks, and a multi-phase Boss at the end of every 5th wave that drops weapon upgrade crates.
Add High Scores & Deploy
Wire combo score multipliers, persistent localStorage high scores, and synthesized Web Audio laser/explosion SFX, then share your single-file game anywhere.
Vibe Prompt Configurator
Choose your shooter sub-genre, arsenal mechanics, and enemy wave structure. Copy the generated prompt directly into Claude, Cursor, or Gemini.
Essential Elements of a Shooter Game
Whether you are building a top-down shooter, a space shmup, or a first-person raycaster, every standout shooter relies on these core pillars:
-
Varied Weapons & Upgrade System
Give players an arsenal with distinct strengths and weaknesses—rapid-fire rifles, close-range shotguns, splash launchers, and weapon upgrades that scale their firepower.
-
Distinct Enemies & Boss Battles
Populate waves with varied AI behaviors—fast melee rushers, heavy tanks, ranged gunners—culminating in high-intensity Boss fights with telegraphed attacks.
-
Hitscan Raycasting vs. Projectile Ballistics
Combine fast-moving projectile bullets with instant raycast ("hitscan") beams that intersect objects directly along the player's crosshair line of sight.
-
Escalating Levels & Wave Pacing
Structure progression across unlocking levels or escalating survival waves that steadily introduce new hazards, pickup crates, and tactical arenas.
-
High Scores, Combos & Leaderboards
Track accuracy, kill streaks, and high scores in real time so players are constantly rewarded for aggressive, skillful play.
-
High Replayability & Modifiable Arenas
Keep players coming back with randomized power-up drops, unlockable weapon tiers, and customizable arena parameters.
The "Golden" Single-File HTML5 Shooter Game
Save this as index.html and open it in any browser to play a complete top-down arena shooter with 3 switchable weapons (Pulse Rifle, Shotgun, Hitscan Railgun), enemy waves, and weapon upgrades.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vibe Nova Arena Shooter</title>
<style>
* { box-sizing: border-box; margin: 0; padding: 0; font-family: system-ui, -apple-system, sans-serif; }
body {
background: #060911;
color: #f8fafc;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-height: 100vh;
padding: 14px;
}
.shooter-wrap {
background: #111827;
border: 1px solid #1e293b;
border-radius: 18px;
padding: 16px;
max-width: 700px;
width: 100%;
box-shadow: 0 24px 60px rgba(0,0,0,0.7);
}
.hud {
display: grid;
grid-template-columns: repeat(5, 1fr);
gap: 8px;
margin-bottom: 10px;
}
.hud-box {
background: #0b0f19;
border: 1px solid #1e293b;
border-radius: 10px;
padding: 7px;
text-align: center;
}
.hud-k { font-size: 0.65rem; text-transform: uppercase; color: #94a3b8; }
.hud-v { font-size: 0.95rem; font-weight: 800; color: #38bdf8; margin-top: 2px; }
canvas {
display: block;
width: 100%;
height: auto;
background: #090d16;
border-radius: 12px;
border: 1px solid #1e293b;
cursor: crosshair;
}
.bar {
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 10px;
font-size: 0.8rem;
color: #94a3b8;
gap: 8px;
}
.btn {
background: #10b981;
color: #052e16;
border: none;
border-radius: 8px;
padding: 7px 14px;
font-weight: 800;
cursor: pointer;
}
</style>
</head>
<body>
<div class="shooter-wrap">
<div class="hud">
<div class="hud-box"><div class="hud-k">HP</div><div class="hud-v" id="hpEl" style="color:#f43f5e;">100 / 100</div></div>
<div class="hud-box"><div class="hud-k">Wave</div><div class="hud-v" id="wvEl">1</div></div>
<div class="hud-box"><div class="hud-k">Weapon [1-3]</div><div class="hud-v" id="wpEl" style="color:#10b981;">1: Pulse Rifle</div></div>
<div class="hud-box"><div class="hud-k">Arsenal Lv</div><div class="hud-v" id="upEl" style="color:#f59e0b;">Mk I</div></div>
<div class="hud-box"><div class="hud-k">Score (Best)</div><div class="hud-v" id="scEl">0 (0)</div></div>
</div>
<canvas id="arena" width="668" height="400"></canvas>
<div class="bar">
<span id="msgEl">WASD to Move • Mouse to Aim & Hold Click to Shoot • Keys [1] Rifle [2] Shotgun [3] Hitscan Railgun</span>
<button class="btn" id="resetBtn">Restart Arena</button>
</div>
</div>
<script>
const canvas = document.getElementById('arena');
const ctx = canvas.getContext('2d');
const keys = {};
let mouse = { x: 334, y: 200, down: false };
window.addEventListener('keydown', (e) => {
keys[e.code] = true;
if (e.code === 'Digit1') player.weapon = 0;
if (e.code === 'Digit2') player.weapon = 1;
if (e.code === 'Digit3') player.weapon = 2;
});
window.addEventListener('keyup', (e) => { keys[e.code] = false; });
canvas.addEventListener('pointermove', (e) => {
const r = canvas.getBoundingClientRect();
mouse.x = (e.clientX - r.left) * (canvas.width / r.width);
mouse.y = (e.clientY - r.top) * (canvas.height / r.height);
});
canvas.addEventListener('pointerdown', () => { mouse.down = true; });
window.addEventListener('pointerup', () => { mouse.down = false; });
const WEAPONS = [
{ name: '1: Pulse Rifle', cd: 9, spd: 9, dmg: 12, color: '#38bdf8' },
{ name: '2: Spread Shotgun', cd: 24, spd: 8, dmg: 9, color: '#f59e0b' },
{ name: '3: Hitscan Railgun', cd: 34, spd: 0, dmg: 38, color: '#a855f7' }
];
let player = {}, bullets = [], beams = [], enemies = [], particles = [];
let wave = 1, score = 0, shake = 0, best = Number(localStorage.getItem('vibe_shooter_best') || 0);
function initGame() {
player = { x: 334, y: 200, hp: 100, maxHp: 100, weapon: 0, cd: 0, mk: 1 };
bullets = []; beams = []; enemies = []; particles = [];
wave = 1; score = 0;
spawnWave();
}
function spawnWave() {
const count = 4 + wave * 2;
for (let i = 0; i < count; i++) {
const edge = Math.floor(Math.random() * 4);
const x = edge === 0 ? 10 : (edge === 1 ? canvas.width - 10 : Math.random() * canvas.width);
const y = edge === 2 ? 10 : (edge === 3 ? canvas.height - 10 : Math.random() * canvas.height);
const isTank = (i === 0 && wave % 2 === 0);
enemies.push({
x, y,
r: isTank ? 18 : 11,
hp: isTank ? 65 + wave * 18 : 20 + wave * 6,
maxHp: isTank ? 65 + wave * 18 : 20 + wave * 6,
spd: isTank ? 1.15 : 1.7 + Math.min(1.2, wave * 0.08),
color: isTank ? '#f43f5e' : '#fb923c',
flash: 0,
pts: isTank ? 50 : 15
});
}
}
function fireWeapon() {
const w = WEAPONS[player.weapon];
const ang = Math.atan2(mouse.y - player.y, mouse.x - player.x);
const dmgMult = 1 + (player.mk - 1) * 0.25;
player.cd = Math.max(4, Math.floor(w.cd * Math.pow(0.92, player.mk - 1)));
if (player.weapon === 0) {
bullets.push({ x: player.x, y: player.y, vx: Math.cos(ang) * w.spd, vy: Math.sin(ang) * w.spd, dmg: w.dmg * dmgMult, color: w.color });
shake = 2;
} else if (player.weapon === 1) {
for (let i = -2; i <= 2; i++) {
const a = ang + i * 0.11;
bullets.push({ x: player.x, y: player.y, vx: Math.cos(a) * w.spd, vy: Math.sin(a) * w.spd, dmg: w.dmg * dmgMult, color: w.color });
}
shake = 5;
} else {
// Hitscan raycast along line of sight
const ex = player.x + Math.cos(ang) * 800;
const ey = player.y + Math.sin(ang) * 800;
beams.push({ x1: player.x, y1: player.y, x2: ex, y2: ey, alpha: 1 });
shake = 6;
enemies.forEach((e) => {
// Point-to-segment distance for hitscan beam
const dx = ex - player.x, dy = ey - player.y;
const len2 = dx * dx + dy * dy;
const t = Math.max(0, Math.min(1, ((e.x - player.x) * dx + (e.y - player.y) * dy) / len2));
const px = player.x + t * dx, py = player.y + t * dy;
if (Math.hypot(e.x - px, e.y - py) <= e.r + 6) {
damageEnemy(e, w.dmg * dmgMult);
}
});
}
}
function damageEnemy(e, dmg) {
e.hp -= dmg;
e.flash = 3;
for (let i = 0; i < 4; i++) {
particles.push({ x: e.x, y: e.y, vx: (Math.random() - 0.5) * 5, vy: (Math.random() - 0.5) * 5, alpha: 1, color: e.color });
}
if (e.hp <= 0) {
score += e.pts;
if (score > best) {
best = score;
localStorage.setItem('vibe_shooter_best', String(best));
}
}
}
function loop() {
if (player.hp > 0) {
const up = keys['KeyW'] || keys['ArrowUp'];
const dn = keys['KeyS'] || keys['ArrowDown'];
const lt = keys['KeyA'] || keys['ArrowLeft'];
const rt = keys['KeyD'] || keys['ArrowRight'];
if (up) player.y = Math.max(16, player.y - 3.4);
if (dn) player.y = Math.min(canvas.height - 16, player.y + 3.4);
if (lt) player.x = Math.max(16, player.x - 3.4);
if (rt) player.x = Math.min(canvas.width - 16, player.x + 3.4);
if (player.cd > 0) player.cd--;
if (mouse.down && player.cd <= 0) fireWeapon();
}
ctx.save();
if (shake > 0.3) {
ctx.translate((Math.random() - 0.5) * shake, (Math.random() - 0.5) * shake);
shake *= 0.82;
}
ctx.fillStyle = '#090d16';
ctx.fillRect(0, 0, canvas.width, canvas.height);
// Subtle tactical grid
ctx.strokeStyle = 'rgba(30, 41, 59, 0.45)';
for (let x = 0; x < canvas.width; x += 40) { ctx.beginPath(); ctx.moveTo(x, 0); ctx.lineTo(x, canvas.height); ctx.stroke(); }
for (let y = 0; y < canvas.height; y += 40) { ctx.beginPath(); ctx.moveTo(0, y); ctx.lineTo(canvas.width, y); ctx.stroke(); }
// Hitscan beams
beams = beams.filter((b) => b.alpha > 0.05);
beams.forEach((b) => {
ctx.strokeStyle = 'rgba(168, 85, 247, ' + b.alpha + ')';
ctx.lineWidth = 4;
ctx.beginPath(); ctx.moveTo(b.x1, b.y1); ctx.lineTo(b.x2, b.y2); ctx.stroke();
b.alpha *= 0.8;
});
// Bullets
bullets = bullets.filter((b) => b.x > 0 && b.x < canvas.width && b.y > 0 && b.y < canvas.height && !b.hit);
bullets.forEach((b) => {
b.x += b.vx; b.y += b.vy;
ctx.fillStyle = b.color;
ctx.beginPath(); ctx.arc(b.x, b.y, 4, 0, Math.PI * 2); ctx.fill();
enemies.forEach((e) => {
if (!b.hit && e.hp > 0 && Math.hypot(e.x - b.x, e.y - b.y) <= e.r + 4) {
b.hit = true;
damageEnemy(e, b.dmg);
}
});
});
// Enemies
enemies = enemies.filter((e) => e.hp > 0);
enemies.forEach((e) => {
const ang = Math.atan2(player.y - e.y, player.x - e.x);
e.x += Math.cos(ang) * e.spd;
e.y += Math.sin(ang) * e.spd;
if (Math.hypot(player.x - e.x, player.y - e.y) < e.r + 12 && player.hp > 0) {
player.hp = Math.max(0, player.hp - 0.45);
shake = 4;
}
ctx.fillStyle = e.flash > 0 ? '#ffffff' : e.color;
if (e.flash > 0) e.flash--;
ctx.beginPath(); ctx.arc(e.x, e.y, e.r, 0, Math.PI * 2); ctx.fill();
});
if (enemies.length === 0 && player.hp > 0) {
wave++;
player.mk = 1 + Math.floor(wave / 2);
player.hp = Math.min(player.maxHp, player.hp + 15);
spawnWave();
document.getElementById('msgEl').textContent = '⚡ Wave ' + wave + '! Arsenal upgraded to Mk ' + player.mk + ' (+15 HP)!';
}
// Particles
particles = particles.filter((p) => p.alpha > 0.05);
particles.forEach((p) => {
p.x += p.vx; p.y += p.vy; p.alpha *= 0.88;
ctx.fillStyle = p.color;
ctx.globalAlpha = p.alpha;
ctx.fillRect(p.x, p.y, 3, 3);
});
ctx.globalAlpha = 1;
// Player + turret
const pAng = Math.atan2(mouse.y - player.y, mouse.x - player.x);
ctx.save();
ctx.translate(player.x, player.y);
ctx.rotate(pAng);
ctx.fillStyle = '#94a3b8';
ctx.fillRect(4, -3, 16, 6);
ctx.fillStyle = player.hp > 0 ? '#10b981' : '#64748b';
ctx.beginPath(); ctx.arc(0, 0, 12, 0, Math.PI * 2); ctx.fill();
ctx.restore();
ctx.restore();
document.getElementById('hpEl').textContent = Math.ceil(player.hp) + ' / 100';
document.getElementById('wvEl').textContent = wave;
document.getElementById('wpEl').textContent = WEAPONS[player.weapon].name;
document.getElementById('upEl').textContent = 'Mk ' + player.mk;
document.getElementById('scEl').textContent = score + ' (' + best + ')';
requestAnimationFrame(loop);
}
document.getElementById('resetBtn').addEventListener('click', initGame);
initGame();
requestAnimationFrame(loop);
</script>
</body>
</html>
How to Debug Shooters Without Losing Your Vibe
Keep your frame rate locked at 60fps and your aiming laser-accurate with these three vibe fixes:
Cull Off-Screen Projectiles
Prevent thousands of invisible bullets from lagging the browser after 5 minutes: "Filter the bullets array every frame to remove any projectile where x < 0, x > width, y < 0, y > height, or bullet.hit === true."
Normalize Diagonal Movement
Stop players from moving 1.41x faster when holding W+D simultaneously: "If both dx !== 0 and dy !== 0, multiply the movement vector by Math.SQRT1_2 (0.7071) so diagonal speed matches cardinal speed."
Hitscan Segment Math
When coding instant-hit lasers or railguns, prompt the AI: "Use point-to-line-segment distance between each enemy center and the ray segment from player to crosshair max range."
The Vibe Prompt Vault
Copy-paste prompts to add bullet-time slow motion, boss phases, or a 3D raycast FPS view.
⏱️ Prompt: Add a "Bullet-Time" Slow Motion & Dash Ability
"I have a top-down HTML5 Canvas shooter in index.html. Add a 'Chrono Energy' bar that charges as the player kills enemies. Holding Right-Click or Shift activates Bullet-Time, slowing all enemy movement and enemy projectiles to 0.3x speed while keeping the player's aiming and movement at 1.0x speed with a cyan afterimage trail."
🤖 Prompt: Add a Multi-Phase Mecha Boss Fight Every 5th Wave
"Extend my HTML5 shooter so that every 5th wave spawns an 'Omega Dreadnought' Boss with a top-of-screen health bar. Give the Boss 2 attack phases: Phase 1 fires a rotating spiral of red plasma orbs; Phase 2 (below 50% HP) telegraphs a red laser sight line for 1 second before firing a high-damage hitscan beam."
🕶️ Prompt: Convert into a Retro 3D Raycasting First-Person Shooter (FPS)
"Build a single-file HTML5 Canvas 3D raycasting FPS (DOOM/Wolfenstein style) in index.html. Use a 16x16 2D grid map, cast vertical wall strips with distance shading, render billboarded enemy drones in depth order, and draw a centered first-person weapon sprite with muzzle flash and hitscan shooting."