Let's check if there are any build errors right now by running build_project or checking GameCanvas.tsx.
Wait, before we run build, let's look at what we need to add:
- In
GameCanvas.tsx, add tree canopies and weather particles to Section 11 (right before // Draw Floating Texts).
- Add
biomeId to the dependency array of the loop useEffect (line 1826: }, [gameState, autoAim, heroClass, biomeId, credits, ...).
- Add the First Person View Mode! Let's design and integrate FPV mode now!
Let's check how we can design the First Person View Mode cleanly:
Let's add a state to GameCanvas.tsx:
const [viewMode, setViewMode] = useState<'TOP_DOWN' | 'FIRST_PERSON'>('TOP_DOWN');
Let's also store viewMode in gameRef.current so the 60fps loop can read it without React re-render issues:
In gameRef.current, add:
viewMode: 'TOP_DOWN' | 'FIRST_PERSON';
headBob: number;
weaponRecoil: number;
And whenever viewMode changes (or when user presses hotkey V or clicks the toggle button on HUD), we update both state setViewMode and gameRef.current.viewMode = newMode;.
Let's also save the player's preference or make it easy to toggle!
Let's analyze how Controls change when viewMode === 'FIRST_PERSON':
In Section 2 (Player Movement & Controls):
If viewMode === 'TOP_DOWN':
- WASD moves N/S/E/W:
moveX, moveY.
- Aim Angle is towards mouse cursor
(g.mouse.x, g.mouse.y).
If viewMode === 'FIRST_PERSON':
- WASD moves relative to camera facing direction (
g.player.angle):
W / ArrowUp moves forward along facing direction: moveX += Math.cos(g.player.angle); moveY += Math.sin(g.player.angle);
S / ArrowDown moves backward: moveX -= Math.cos(g.player.angle); moveY -= Math.sin(g.player.angle);
A / ArrowLeft strafes left: moveX += Math.cos(g.player.angle - Math.PI/2); moveY += Math.sin(g.player.angle - Math.PI/2);
D / ArrowRight strafes right: moveX += Math.cos(g.player.angle + Math.PI/2); moveY += Math.sin(g.player.angle + Math.PI/2);
- For touch joystick:
joystick.vy (< 0 is forward, > 0 is backward) and joystick.vx is strafe left/right!
moveX += Math.cos(g.player.angle) * (-g.joystick.vy) + Math.cos(g.player.angle + Math.PI/2) * g.joystick.vx;
moveY += Math.sin(g.player.angle) * (-g.joystick.vy) + Math.sin(g.player.angle + Math.PI/2) * g.joystick.vx;
- Aiming / Turning in First Person:
- If
autoAim is ON and enemies are present: smoothly turn towards the closest enemy!
const targetAngle = Math.atan2(closest.y - g.player.y, closest.x - g.player.x);
We can smoothly interpolate g.player.angle towards targetAngle!
- If
autoAim is OFF (manual aiming):
- When moving the mouse cursor horizontally across the screen, turn
g.player.angle! How?
- Let's check: if the mouse is to the left or right of the screen center
cx = canvas.width / 2, turn left or right proportional to distance from center!
const turnSpeed = (g.mouse.x - canvasRef.current.width / 2) * 0.00015 * dt;
g.player.angle += turnSpeed;
- Or if the mouse moves, rotate view! To make it feel super responsive without pointer lock, having the view turn when the cursor is away from center (like a turret/mech control or flight simulator), AND when dragging on touch or using arrow keys left/right! Let's make
ArrowLeft/ArrowRight turn left/right in FPV if not strafing, or let mouse position smoothly guide your operative's field of view!
- When walking (
moveLen > 0), update head bob: g.headBob += 0.015 * dt;. When standing still, g.headBob *= 0.9;.
- When shooting weapon, set
g.weaponRecoil = 15;. In loop: g.weaponRecoil *= 0.85;.
Let's examine how Rendering works when viewMode === 'FIRST_PERSON':
Instead of drawing the 2D top-down view in Section 11, we draw the Retro 3D Perspective / FPS View!
Let's see how we render the 3D FPS view step-by-step:
-
Sky & Horizon:
- The horizon line is at
horizY = canvas.height / 2 + Math.sin(g.headBob) * 10 + (g.screenShake > 0.5 ? (Math.random()-0.5)*g.screenShake : 0);
- Sky gradient (from
y = 0 to y = horizY): top color is dark biome sky (biome.bgColor), bottom color at horizon is glowing atmospheric mist (biome.weatherColor with 0.3 opacity or biome.groundTone).
- Ground gradient (from
y = horizY to canvas.height): top at horizon is dark distance (biome.bgColor), bottom at feet is rich soil (biome.groundTone).
- Draw perspective grid / speed lines on the floor! For lines radiating out from horizon center
(canvas.width/2, horizY), draw 12 lines to the bottom edge of screen! For horizontal depth lines, draw lines at exponentially increasing distances from horizon to bottom of screen! This creates a stunning 3D grid floor!
-
Projecting & Sorting 3D Entities:
- Collect ALL visible objects into a single array to be sorted by distance
camZ from furthest to nearest! What objects?
g.props (trees, rocks, crystal clusters, spore bushes, water pools, grass tufts).
g.enemies (drones, crawlers, brutes, spitters, bosses).
g.gems (XP crystals).
g.projectiles (plasma bolts, laser beams, slashes, enemy fireballs).
g.particles (sparks, explosions, blood/ichor, water rings).
g.weather (fireflies, snow, sandstorm, embers).
- For each entity at
(ex, ey):
dx = ex - g.player.x; dy = ey - g.player.y;
- Rotate into camera view space using
-g.player.angle:
const cosA = Math.cos(-g.player.angle);
const sinA = Math.sin(-g.player.angle);
const camX = dx * sinA + dy * cosA; (lateral offset to left/right of camera)
const camZ = dx * cosA - dy * sinA; (depth in front of camera)
- If
camZ > 5 (in front of camera and not behind player!) and camZ < 1500 (within view distance):
- Calculate perspective projection:
const focalLen = canvas.width * 0.75; (approx 70-degree FOV!)
const screenX = canvas.width / 2 + (camX / camZ) * focalLen;
const screenY = horizY + (heightOffset / camZ) * focalLen; (where heightOffset depends on object type: e.g. floating texts are higher, ground pools/grid are lower, characters are centered on ground plane!).
Let's check: how can we add the HUD toggle button for Top-Down vs FPV?
In HUD.tsx, let's add a button right next to the Auto-Aim toggle or in the top/bottom bar:
🎥 VIEW: 2D TOP-DOWN / 🎥 VIEW: 3D FIRST-PERSON
And when clicked, it toggles onToggleViewMode(). Also bind hotkey V or Tab in GameCanvas.tsx!
Let's check if we can implement all of this cleanly!
Let's first check HUD.tsx and add the View Mode toggle button and prop.
Let's read src/components/HUD.tsx around the bottom bar where Auto-Aim toggle is located.
Let's check lines 1-25 of HUD.tsx to check imports and interface.
Let's edit HUD.tsx to add viewMode: 'TOP_DOWN' | 'FIRST_PERSON', onToggleViewMode: () => void, and import Eye or Camera or Video from lucide-react. Let's import Eye and Camera from lucide-react.
Let's edit src/components/HUD.tsx now.
Now let's add the view mode button to the bottom bar of HUD.tsx. Let's check lines 175-200 of HUD.tsx.
Let's edit HUD.tsx to add the Camera / View Mode button next to Auto-Aim. Let's do this edit now.
Now let's work on GameCanvas.tsx to add:
viewMode state (const [viewMode, setViewMode] = useState<'TOP_DOWN' | 'FIRST_PERSON'>('TOP_DOWN');).
- Update
gameRef.current to store viewMode: 'TOP_DOWN' | 'FIRST_PERSON', headBob: number, and weaponRecoil: number.
- In
initGame(), set viewMode: 'TOP_DOWN', headBob: 0, weaponRecoil: 0.
- Hotkey
V or Tab in handleKeyDown to toggle viewMode!
- In Section 2 (Player Movement & Controls):
- Support First Person WASD movement (relative to
g.player.angle) when g.viewMode === 'FIRST_PERSON'.
- Support Mouse Aim turning when
g.viewMode === 'FIRST_PERSON' and !autoAim: when moving the mouse or when mouse cursor is left/right of center!
- Update
headBob and weaponRecoil animations!
- In Section 11 (Canvas Rendering):
- If
g.viewMode === 'TOP_DOWN', render our gorgeous 2D top-down view (with Tree canopies and Weather particles!).
- If
g.viewMode === 'FIRST_PERSON', render our breathtaking 3D First-Person Perspective FPS view with sky/horizon gradient, 3D perspective grid floor, depth-sorted 3D billboards for all enemies, trees, rocks, crystals, gems, and projectiles, first-person gun view-model with muzzle flash, and targeting reticle!
- Pass
viewMode and onToggleViewMode to HUD.
Let's check lines 40-75 of GameCanvas.tsx to add viewMode state and ref properties.
Let's check lines 80-100 of GameCanvas.tsx.
Let's check where gameRef.current = { is initialized in initGame(). Let's read lines 230 to 270 of GameCanvas.tsx.
Let's edit lines 48-86 and 240-265 of GameCanvas.tsx to add viewMode state and ref properties (viewMode, headBob, weaponRecoil).
Let's do this edit now.
Let's now update initGame() to initialize viewMode: 'TOP_DOWN', headBob: 0, and weaponRecoil: 0 in gameRef.current. Let's check lines 240-265.
Let's edit initGame() to add viewMode: 'TOP_DOWN', headBob: 0, and weaponRecoil: 0. Let's do this edit now.
Now let's check handleKeyDown and bind V or Tab to toggle FPV mode! Let's read lines 370 to 420 of GameCanvas.tsx.
Let's read lines 430 to 480 of GameCanvas.tsx to find handleKeyDown.
Let's edit handleKeyDown to add V or Tab hotkey to toggle viewMode.
Let's also check: when viewMode toggles, let's create a helper function toggleViewMode:
const toggleViewMode = useCallback(() => {
soundEngine.playClick();
setViewMode(prev => {
const next = prev === 'TOP_DOWN' ? 'FIRST_PERSON' : 'TOP_DOWN';
if (gameRef.current) gameRef.current.viewMode = next;
return next;
});
}, []);
Let's add this right before useEffect for keyboard listeners, and call toggleViewMode() when e.key.toLowerCase() === 'v' || e.key === 'Tab'!
Let's edit GameCanvas.tsx now around line 430-465.
Now let's check useEffect dependency array for keyboard listeners! Note that toggleViewMode should be added to the dependency array. Let's check lines 500-530 of GameCanvas.tsx.
Let's update line 523: }, [gameState, triggerSpecial, initGame, toggleViewMode]);.
Now let's check Section 2 (Player Movement & Controls) around line 680-730. Let's read lines 680-730 of GameCanvas.tsx.
Let's read lines 750 to 810 of GameCanvas.tsx to find Section 2.
Let's update Section 2 (Player Movement & Controls) to support both TOP_DOWN and FIRST_PERSON view modes!
When g.viewMode === 'FIRST_PERSON':
- For movement:
If
W/S/ArrowUp/ArrowDown/A/D/ArrowLeft/ArrowRight or joystick are pressed:
Instead of moving along world X/Y axes directly, we calculate forward (-moveY in normal keys, where pressing W gives moveY = -1, so forward = 1) and strafe (moveX, where pressing D gives moveX = 1, so strafe = 1).
Then:
const fx = Math.cos(g.player.angle) * forward + Math.cos(g.player.angle + Math.PI/2) * strafe;
const fy = Math.sin(g.player.angle) * forward + Math.sin(g.player.angle + Math.PI/2) * strafe;
g.player.x += fx * g.player.speed * (dt / 16);
g.player.y += fy * g.player.speed * (dt / 16);
- For Aiming / Turning in First Person:
If
autoAim and enemies are present: smoothly rotate g.player.angle towards closest enemy!
If !autoAim: we can rotate g.player.angle based on horizontal mouse offset from canvas center!
const cx = canvasRef.current.width / 2;
const offsetX = (g.mouse.x - cx) / cx; // -1 to 1
// If mouse is moved away from center (deadzone of 0.15), rotate smoothly!
if (Math.abs(offsetX) > 0.1) { g.player.angle += offsetX * 0.0025 * dt; }
Also allow ArrowLeft / ArrowRight or Q/E to turn if desired! Even better: if mouse cursor is anywhere on screen, moving it left or right turns the operative's head!
- When walking (
moveLen > 0), increment headBob: g.headBob += 0.015 * dt;.
- When firing weapon (in Section 3), set
g.weaponRecoil = 15;.
- In loop:
g.weaponRecoil *= 0.85;.
Let's edit Section 2 and Section 3 of GameCanvas.tsx now. Let's check lines 760-820.
Now let's check Section 3 (Weapon Firing): when a weapon is fired, let's set g.weaponRecoil = 15;.
Let's read lines 860 to 890 of GameCanvas.tsx where weapon firing occurs.
Let's check lines 845-860 of GameCanvas.tsx.
Let's edit line 849 to set g.weaponRecoil = 15;. Let's do this edit now.
Now let's check Section 11 (Canvas Rendering). Let's see where Section 11 starts. Let's use grep_files to find // --- 11. CANVAS RENDERING.
Let's read lines 1540 to 1570 of GameCanvas.tsx.
Let's check where Section 11 ends and where floating texts are drawn. Let's search for // Draw Floating Texts.
Let's read lines 1855 to 1910 of GameCanvas.tsx.
Let's check lines 1910 to 1960 of GameCanvas.tsx to see where HUD is rendered in JSX.
Let's edit the JSX in GameCanvas.tsx to pass viewMode and onToggleViewMode to HUD.
Let's check lines 1925 to 1945 and edit them.
Now let's implement the rendering for both TOP_DOWN and FIRST_PERSON view modes in Section 11 of GameCanvas.tsx, and add biomeId and viewMode to the dependency array of the loop useEffect!
Let's review Section 11 in GameCanvas.tsx. Let's read lines 1540 to 1885 of GameCanvas.tsx or use grep_files to find the exact boundaries of Section 11. Let's use grep_files for // --- 11. CANVAS RENDERING.
Let's check where Section 11 ends by checking where animId = requestAnimationFrame(loop); is called at the end of loop. Let's read lines 1860 to 1900 of GameCanvas.tsx.
Let's check lines 1820 to 1860 of GameCanvas.tsx to see where tree canopies and weather should be added for Top-Down mode. Wait, earlier when our tool was cut off, let's see what is currently in lines 1800 to 1865. Let's read lines 1800 to 1865.
Let's see: in Section 11, after const biome = getBiomeConfig(biomeId);, we can check if (g.viewMode === 'FIRST_PERSON'):
If g.viewMode === 'FIRST_PERSON', we render our 3D FPS View!
Otherwise (else), we render our 2D Top-Down View (with Tree Canopies and Weather added before Floating Texts!).
Let's design the 3D FPV Rendering Block in detail so it is rock-solid and stunning:
if (g.viewMode === 'FIRST_PERSON') {
const w = canvasRef.current.width;
const h = canvasRef.current.height;
const horizY = h / 2 + Math.sin(g.headBob) * 12 + (g.screenShake > 0.5 ? (Math.random() - 0.5) * g.screenShake : 0);
// 1. Sky & Horizon Gradient
const skyGrad = ctx.createLinearGradient(0, 0, 0, horizY);
skyGrad.addColorStop(0, biome.bgColor);
skyGrad.addColorStop(0.7, biome.bgColor);
skyGrad.addColorStop(1, biome.weatherColor);
ctx.fillStyle = skyGrad;
ctx.fillRect(0, 0, w, horizY);
// 2. Ground & Horizon Gradient
const gndGrad = ctx.createLinearGradient(0, horizY, 0, h);
gndGrad.addColorStop(0, biome.bgColor);
gndGrad.addColorStop(0.3, biome.groundTone);
gndGrad.addColorStop(1, '#020617');
ctx.fillStyle = gndGrad;
ctx.fillRect(0, horizY, w, h - horizY);
// 3. Perspective Grid Floor
ctx.strokeStyle = biome.gridColor;
ctx.lineWidth = 1;
ctx.save();
ctx.beginPath();
// Radiating lines from horizon center
const numRays = 16;
for (let i = -numRays; i <= numRays; i++) {
const rayAngle = (i / numRays) * Math.PI * 0.45;
const endX = w / 2 + Math.tan(rayAngle) * h;
ctx.moveTo(w / 2, horizY);
ctx.lineTo(endX, h);
}
// Horizontal depth lines
for (let z = 1; z <= 10; z++) {
const depthY = horizY + Math.pow(z / 10, 2) * (h - horizY);
ctx.moveTo(0, depthY);
ctx.lineTo(w, depthY);
}
ctx.stroke();
ctx.restore();
// 4. Collect & Depth-Sort 3D Entities
interface Render3DItem {
type: 'enemy' | 'prop' | 'gem' | 'proj' | 'part' | 'weather';
entity: any;
camZ: number;
screenX: number;
screenY: number;
scale: number;
}
const renderList: Render3DItem[] = [];
const focalLen = w * 0.75;
const cosA = Math.cos(-g.player.angle);
const sinA = Math.sin(-g.player.angle);
const projectItem = (entity: any, type: Render3DItem['type'], heightOffset = 0) => {
const dx = entity.x - g.player.x;
const dy = entity.y - g.player.y;
const camX = dx * sinA + dy * cosA;
const camZ = dx * cosA - dy * sinA;
if (camZ > 15 && camZ < 1800) {
const screenX = w / 2 + (camX / camZ) * focalLen;
const scale = focalLen / camZ;
const screenY = horizY + (heightOffset / camZ) * focalLen;
renderList.push({ type, entity, camZ, screenX, screenY, scale });
}
};
g.props.forEach(p => projectItem(p, 'prop', 0));
g.enemies.forEach(e => projectItem(e, 'enemy', 0));
g.gems.forEach(gm => projectItem(gem => gem, 'gem', 20)); // wait, pass gm! projectItem(gm, 'gem', 20)
g.projectiles.forEach(pr => projectItem(pr, 'proj', 15));
g.particles.forEach(pt => projectItem(pt, 'part', 10));
g.weather.forEach(wp => projectItem(wp, 'weather', -50 + Math.sin(wp.wobbleOffset) * 30));
// Sort back-to-front
renderList.sort((a, b) => b.camZ - a.camZ);
// 5. Draw Depth-Sorted 3D Billboards
renderList.forEach(item => {
const { type, entity, screenX, screenY, scale } = item;
const drawRad = (entity.radius || entity.size || 5) * scale;
if (screenX + drawRad < -100 || screenX - drawRad > w + 100) return;
ctx.save();
if (type === 'prop') {
const prop: EnvironmentProp = entity;
const isHit = timestamp < prop.hitFlashUntil;
ctx.fillStyle = isHit ? '#ffffff' : prop.color;
ctx.shadowColor = prop.color;
if (prop.type === 'tree') {
// Trunk
ctx.fillStyle = '#271710';
ctx.fillRect(screenX - drawRad * 0.25, screenY - drawRad * 0.2, drawRad * 0.5, drawRad * 1.2);
// Canopy
ctx.fillStyle = isHit ? '#ffffff' : prop.color;
ctx.shadowBlur = 10;
ctx.beginPath();
ctx.arc(screenX, screenY - drawRad * 0.8, drawRad, 0, Math.PI * 2);
ctx.fill();
// Glow moss
ctx.fillStyle = prop.glowColor || '#34d399';
ctx.beginPath();
ctx.arc(screenX + drawRad * 0.3, screenY - drawRad * 0.9, drawRad * 0.2, 0, Math.PI * 2);
ctx.fill();
} else if (prop.type === 'rock') {
ctx.fillStyle = prop.color;
ctx.strokeStyle = prop.detailColor;
ctx.lineWidth = Math.max(1, 2 * scale);
ctx.beginPath();
ctx.arc(screenX, screenY, drawRad, Math.PI, Math.PI * 2);
ctx.closePath();
ctx.fill();
ctx.stroke();
} else if (prop.type === 'water_pool') {
ctx.fillStyle = prop.color;
ctx.globalAlpha = 0.65;
ctx.beginPath();
ctx.ellipse(screenX, screenY + drawRad * 0.3, drawRad * 1.5, drawRad * 0.4, 0, 0, Math.PI * 2);
ctx.fill();
} else if (prop.type === 'crystal_cluster' || prop.type === 'spore_bush') {
ctx.shadowBlur = 15;
ctx.beginPath();
if (prop.type === 'crystal_cluster') {
ctx.moveTo(screenX, screenY - drawRad * 1.4);
ctx.lineTo(screenX + drawRad * 0.6, screenY);
ctx.lineTo(screenX - drawRad * 0.6, screenY);
ctx.closePath();
} else {
ctx.arc(screenX, screenY - drawRad * 0.4, drawRad * 0.8, 0, Math.PI * 2);
}
ctx.fill();
} else if (prop.type === 'grass_tuft') {
ctx.strokeStyle = prop.color;
ctx.lineWidth = Math.max(1, 2 * scale);
ctx.beginPath();
ctx.moveTo(screenX - drawRad * 0.5, screenY);
ctx.quadraticCurveTo(screenX, screenY - drawRad, screenX + drawRad * 0.5, screenY);
ctx.stroke();
}
} else if (type === 'enemy') {
const e: Enemy = entity;
const isHit = timestamp < e.hitFlashUntil;
ctx.fillStyle = isHit ? '#ffffff' : e.color;
ctx.shadowColor = e.color;
ctx.shadowBlur = e.isBoss ? 25 : 10;
// Draw Health Bar above head in 3D
const barW = drawRad * 1.8;
const barH = Math.max(3, 6 * scale);
const barY = screenY - drawRad * 1.6;
ctx.fillStyle = 'rgba(15, 23, 42, 0.8)';
ctx.fillRect(screenX - barW / 2, barY, barW, barH);
ctx.fillStyle = e.isBoss ? '#ef4444' : '#38bdf8';
ctx.fillRect(screenX - barW / 2, barY, barW * Math.max(0, e.hp / e.maxHp), barH);
ctx.fillStyle = isHit ? '#ffffff' : e.color;
if (e.isBoss) {
ctx.beginPath();
ctx.moveTo(screenX, screenY - drawRad * 1.4);
ctx.lineTo(screenX + drawRad, screenY - drawRad * 0.2);
ctx.lineTo(screenX, screenY + drawRad);
ctx.lineTo(screenX - drawRad, screenY - drawRad * 0.2);
ctx.closePath();
ctx.fill();
ctx.lineWidth = Math.max(1, 3 * scale);
ctx.strokeStyle = '#ffffff';
ctx.stroke();
} else if (e.type === 'brute') {
ctx.fillRect(screenX - drawRad, screenY - drawRad * 1.2, drawRad * 2, drawRad * 2);
} else if (e.type === 'spitter') {
ctx.beginPath();
ctx.moveTo(screenX, screenY - drawRad * 1.3);
ctx.lineTo(screenX + drawRad, screenY + drawRad * 0.4);
ctx.lineTo(screenX - drawRad, screenY + drawRad * 0.4);
ctx.closePath();
ctx.fill();
} else {
ctx.beginPath();
ctx.arc(screenX, screenY - drawRad * 0.5, drawRad, 0, Math.PI * 2);
ctx.fill();
}
} else if (type === 'gem') {
const gem: XpGem = entity;
ctx.fillStyle = gem.color;
ctx.shadowColor = gem.color;
ctx.shadowBlur = 12;
const bob = Math.sin(timestamp * 0.005) * 6 * scale;
ctx.beginPath();
ctx.arc(screenX, screenY - drawRad + bob, drawRad, 0, Math.PI * 2);
ctx.fill();
} else if (type === 'proj') {
const p: Projectile = entity;
ctx.fillStyle = p.color;
ctx.shadowColor = p.color;
ctx.shadowBlur = 15;
if (p.type === 'slash') {
ctx.strokeStyle = p.color;
ctx.lineWidth = Math.max(2, 5 * scale);
ctx.beginPath();
ctx.arc(screenX, screenY - drawRad, drawRad * 1.5, 0, Math.PI);
ctx.stroke();
} else {
ctx.beginPath();
ctx.arc(screenX, screenY - drawRad * 0.5, drawRad, 0, Math.PI * 2);
ctx.fill();
}
} else if (type === 'part') {
const p: Particle = entity;
ctx.globalAlpha = Math.max(0, p.alpha);
ctx.fillStyle = p.color;
ctx.beginPath();
ctx.arc(screenX, screenY - drawRad * 0.5, Math.max(1, drawRad), 0, Math.PI * 2);
ctx.fill();
} else if (type === 'weather') {
const wp: WeatherParticle = entity;
ctx.globalAlpha = Math.max(0, wp.alpha);
ctx.fillStyle = wp.color;
ctx.shadowColor = wp.color;
if (biome.weatherType === 'fireflies' || biome.weatherType === 'embers') {
ctx.shadowBlur = 8;
}
ctx.beginPath();
ctx.arc(screenX, screenY, Math.max(1, drawRad), 0, Math.PI * 2);
ctx.fill();
}
ctx.restore();
});
// 6. First Person Weapon View-Model & Muzzle Flash
ctx.save();
const bobX = Math.cos(g.headBob) * 14;
const bobY = Math.sin(g.headBob * 2) * 8 + g.weaponRecoil * 1.8;
const gunX = w * 0.7 + bobX;
const gunY = h * 0.85 + bobY;
if (g.weaponRecoil > 2) {
// Muzzle Flash
ctx.fillStyle = heroClass.id === 'engineer' ? '#fbbf24' : '#38bdf8';
ctx.shadowColor = ctx.fillStyle;
ctx.shadowBlur = 30;
ctx.beginPath();
ctx.arc(gunX - 40, gunY - 40, 25 + Math.random() * 15, 0, Math.PI * 2);
ctx.fill();
}
ctx.fillStyle = '#1e293b';
ctx.strokeStyle = heroClass.accentColor;
ctx.lineWidth = 4;
ctx.shadowColor = heroClass.accentColor;
ctx.shadowBlur = 10;
ctx.beginPath();
if (heroClass.id === 'ninja') {
// Katana blade extending upwards to the left
ctx.moveTo(w * 0.8 + bobX, h + bobY);
ctx.lineTo(w * 0.6 + bobX - g.weaponRecoil * 2, h * 0.5 + bobY + g.weaponRecoil);
ctx.lineTo(w * 0.58 + bobX - g.weaponRecoil * 2, h * 0.52 + bobY + g.weaponRecoil);
ctx.lineTo(w * 0.75 + bobX, h + bobY);
} else {
// Cannon / Rifle
ctx.moveTo(w * 0.85 + bobX, h + bobY);
ctx.lineTo(gunX, gunY);
ctx.lineTo(gunX - 50, gunY - 30);
ctx.lineTo(gunX - 45, gunY - 10);
ctx.lineTo(w * 0.75 + bobX, h + bobY);
}
ctx.closePath();
ctx.fill();
ctx.stroke();
// 7. Sci-Fi FPV Crosshair / Targeting Reticle
ctx.strokeStyle = '#38bdf8';
ctx.lineWidth = 2;
ctx.beginPath();
ctx.arc(w / 2, horizY, 16, 0, Math.PI * 2);
ctx.stroke();
ctx.beginPath();
ctx.arc(w / 2, horizY, 4, 0, Math.PI * 2);
ctx.fillStyle = '#38bdf8';
ctx.fill();
// Crosshair ticks
ctx.beginPath();
ctx.moveTo(w / 2 - 24, horizY); ctx.lineTo(w / 2 - 10, horizY);
ctx.moveTo(w / 2 + 10, horizY); ctx.lineTo(w / 2 + 24, horizY);
ctx.moveTo(w / 2, horizY - 24); ctx.lineTo(w / 2, horizY - 10);
ctx.moveTo(w / 2, horizY + 10); ctx.lineTo(w / 2, horizY + 24);
ctx.stroke();
ctx.restore();
} else {
// --- 2D TOP-DOWN VIEW RENDERING ---
... existing 2D rendering ...
}
Notice in line projectItem(gem => gem, 'gem', 20), there was a small typo in our thought: it should be g.gems.forEach(gm => projectItem(gm, 'gem', 20));!
Let's check lines 1540 to 1865 in GameCanvas.tsx where Section 11 is located, and let's replace it with this clean, complete if (g.viewMode === 'FIRST_PERSON') { ... } else { ... } block!
Let's read lines 1540 to 1600 of GameCanvas.tsx to be 100% sure of the context before editing.
Let's check lines 1820 to 1880 of GameCanvas.tsx to see where Section 11 ends and // Draw Floating Texts begins.
Let's see: in Section 11, we will wrap lines 1546 to 1864 in if (g.viewMode === 'FIRST_PERSON') { ... } else { ... }.
Let's check what we put inside else (the 2D top-down view):
It starts with:
ctx.fillStyle = biome.bgColor;
ctx.fillRect(0, 0, canvasRef.current.width, canvasRef.current.height);
And ends right after drawing the player operative (line 1863), plus we add Tree canopies and Weather particles before // Draw Floating Texts!
Let's check the Tree canopies and Weather particles code for top-down:
// Draw Tree Canopies above characters for depth
g.props.forEach(prop => {
if (prop.type === 'tree') {
ctx.save();
ctx.translate(prop.x, prop.y);
const sway = prop.swayOffset;
ctx.globalAlpha = 0.88;
ctx.fillStyle = prop.color;
ctx.shadowColor = prop.detailColor;
ctx.shadowBlur = 10;
ctx.beginPath();
ctx.arc(sway, sway * 0.5, prop.radius, 0, Math.PI * 2);
ctx.fill();
ctx.fillStyle = prop.detailColor;
for (let f = 0; f < 3; f++) {
const ang = (f * Math.PI * 2) / 3 + sway * 0.2;
ctx.beginPath();
ctx.arc(Math.cos(ang) * prop.radius * 0.5 + sway, Math.sin(ang) * prop.radius * 0.5, prop.radius * 0.6, 0, Math.PI * 2);
ctx.fill();
}
ctx.fillStyle = prop.glowColor || '#34d399';
ctx.shadowColor = prop.glowColor || '#34d399';
ctx.shadowBlur = 12;
for (let f = 0; f < 4; f++) {
const ang = (f * Math.PI * 2) / 4 - sway * 0.3;
ctx.beginPath();
ctx.arc(Math.cos(ang) * prop.radius * 0.6 + sway, Math.sin(ang) * prop.radius * 0.6, 3.5, 0, Math.PI * 2);
ctx.fill();
}
ctx.restore();
}
});
// Draw Atmospheric Weather Particles
g.weather.forEach(wp => {
ctx.save();
ctx.globalAlpha = Math.max(0, wp.alpha);
ctx.fillStyle = wp.color;
ctx.shadowColor = wp.color;
if (biome.weatherType === 'fireflies' || biome.weatherType === 'embers') {
ctx.shadowBlur = 10;
}
ctx.beginPath();
ctx.arc(wp.x, wp.y, wp.size, 0, Math.PI * 2);
ctx.fill();
ctx.restore();
});
Now let's check the First-Person 3D rendering code:
Let's make sure projectItem(gm, 'gem', 20) is used for gems, and that all variables are well-scoped.
Let's review the 3D projection logic:
if (g.viewMode === 'FIRST_PERSON') {
const w = canvasRef.current.width;
const h = canvasRef.current.height;
const horizY = h / 2 + Math.sin(g.headBob) * 12 + (g.screenShake > 0.5 ? (Math.random() - 0.5) * g.screenShake : 0);
// 1. Sky & Horizon Gradient
const skyGrad = ctx.createLinearGradient(0, 0, 0, horizY);
skyGrad.addColorStop(0, biome.bgColor);
skyGrad.addColorStop(0.7, biome.bgColor);
skyGrad.addColorStop(1, biome.weatherColor);
ctx.fillStyle = skyGrad;
ctx.fillRect(0, 0, w, horizY);
// 2. Ground & Horizon Gradient
const gndGrad = ctx.createLinearGradient(0, horizY, 0, h);
gndGrad.addColorStop(0, biome.bgColor);
gndGrad.addColorStop(0.3, biome.groundTone);
gndGrad.addColorStop(1, '#020617');
ctx.fillStyle = gndGrad;
ctx.fillRect(0, horizY, w, h - horizY);
// 3. Perspective Grid Floor
ctx.strokeStyle = biome.gridColor;
ctx.lineWidth = 1;
ctx.save();
ctx.beginPath();
const numRays = 16;
for (let r = -numRays; r <= numRays; r++) {
const rayAngle = (r / numRays) * Math.PI * 0.45;
const endX = w / 2 + Math.tan(rayAngle) * h;
ctx.moveTo(w / 2, horizY);
ctx.lineTo(endX, h);
}
for (let z = 1; z <= 10; z++) {
const depthY = horizY + Math.pow(z / 10, 2) * (h - horizY);
ctx.moveTo(0, depthY);
ctx.lineTo(w, depthY);
}
ctx.stroke();
ctx.restore();
// 4. Collect & Depth-Sort 3D Entities
interface Render3DItem {
type: 'enemy' | 'prop' | 'gem' | 'proj' | 'part' | 'weather';
entity: any;
camZ: number;
screenX: number;
screenY: number;
scale: number;
}
const renderList: Render3DItem[] = [];
const focalLen = w * 0.75;
const cosA = Math.cos(-g.player.angle);
const sinA = Math.sin(-g.player.angle);
const projectItem = (entity: any, type: Render3DItem['type'], heightOffset = 0) => {
const dx = entity.x - g.player.x;
const dy = entity.y - g.player.y;
const camX = dx * sinA + dy * cosA;
const camZ = dx * cosA - dy * sinA;
if (camZ > 15 && camZ < 1800) {
const screenX = w / 2 + (camX / camZ) * focalLen;
const scale = focalLen / camZ;
const screenY = horizY + (heightOffset / camZ) * focalLen;
renderList.push({ type, entity, camZ, screenX, screenY, scale });
}
};
g.props.forEach(p => projectItem(p, 'prop', 0));
g.enemies.forEach(e => projectItem(e, 'enemy', 0));
g.gems.forEach(gm => projectItem(gm, 'gem', 20));
g.projectiles.forEach(pr => projectItem(pr, 'proj', 15));
g.particles.forEach(pt => projectItem(pt, 'part', 10));
g.weather.forEach(wp => projectItem(wp, 'weather', -50 + Math.sin(wp.wobbleOffset) * 30));
renderList.sort((a, b) => b.camZ - a.camZ);
// 5. Draw Depth-Sorted 3D Billboards
renderList.forEach(item => {
const { type, entity, screenX, screenY, scale } = item;
const drawRad = (entity.radius || entity.size || 5) * scale;
if (screenX + drawRad < -100 || screenX - drawRad > w + 100) return;
ctx.save();
if (type === 'prop') {
const prop: EnvironmentProp = entity;
const isHit = timestamp < prop.hitFlashUntil;
ctx.fillStyle = isHit ? '#ffffff' : prop.color;
ctx.shadowColor = prop.color;
if (prop.type === 'tree') {
ctx.fillStyle = '#271710';
ctx.fillRect(screenX - drawRad * 0.25, screenY - drawRad * 0.2, drawRad * 0.5, drawRad * 1.2);
ctx.fillStyle = isHit ? '#ffffff' : prop.color;
ctx.shadowBlur = 10;
ctx.beginPath();
ctx.arc(screenX, screenY - drawRad * 0.8, drawRad, 0, Math.PI * 2);
ctx.fill();
ctx.fillStyle = prop.glowColor || '#34d399';
ctx.beginPath();
ctx.arc(screenX + drawRad * 0.3, screenY - drawRad * 0.9, drawRad * 0.2, 0, Math.PI * 2);
ctx.fill();
} else if (prop.type === 'rock') {
ctx.fillStyle = prop.color;
ctx.strokeStyle = prop.detailColor;
ctx.lineWidth = Math.max(1, 2 * scale);
ctx.beginPath();
ctx.arc(screenX, screenY, drawRad, Math.PI, Math.PI * 2);
ctx.closePath();
ctx.fill();
ctx.stroke();
} else if (prop.type === 'water_pool') {
ctx.fillStyle = prop.color;
ctx.globalAlpha = 0.65;
ctx.beginPath();
ctx.ellipse(screenX, screenY + drawRad * 0.3, drawRad * 1.5, drawRad * 0.4, 0, 0, Math.PI * 2);
ctx.fill();
} else if (prop.type === 'crystal_cluster' || prop.type === 'spore_bush') {
ctx.shadowBlur = 15;
ctx.beginPath();
if (prop.type === 'crystal_cluster') {
ctx.moveTo(screenX, screenY - drawRad * 1.4);
ctx.lineTo(screenX + drawRad * 0.6, screenY);
ctx.lineTo(screenX - drawRad * 0.6, screenY);
ctx.closePath();
} else {
ctx.arc(screenX, screenY - drawRad * 0.4, drawRad * 0.8, 0, Math.PI * 2);
}
ctx.fill();
} else if (prop.type === 'grass_tuft') {
ctx.strokeStyle = prop.color;
ctx.lineWidth = Math.max(1, 2 * scale);
ctx.beginPath();
ctx.moveTo(screenX - drawRad * 0.5, screenY);
ctx.quadraticCurveTo(screenX, screenY - drawRad, screenX + drawRad * 0.5, screenY);
ctx.stroke();
}
} else if (type === 'enemy') {
const e: Enemy = entity;
const isHit = timestamp < e.hitFlashUntil;
ctx.fillStyle = isHit ? '#ffffff' : e.color;
ctx.shadowColor = e.color;
ctx.shadowBlur = e.isBoss ? 25 : 10;
const barW = drawRad * 1.8;
const barH = Math.max(3, 6 * scale);
const barY = screenY - drawRad * 1.6;
ctx.fillStyle = 'rgba(15, 23, 42, 0.8)';
ctx.fillRect(screenX - barW / 2, barY, barW, barH);
ctx.fillStyle = e.isBoss ? '#ef4444' : '#38bdf8';
ctx.fillRect(screenX - barW / 2, barY, barW * Math.max(0, e.hp / e.maxHp), barH);
ctx.fillStyle = isHit ? '#ffffff' : e.color;
if (e.isBoss) {
ctx.beginPath();
ctx.moveTo(screenX, screenY - drawRad * 1.4);
ctx.lineTo(screenX + drawRad, screenY - drawRad * 0.2);
ctx.lineTo(screenX, screenY + drawRad);
ctx.lineTo(screenX - drawRad, screenY - drawRad * 0.2);
ctx.closePath();
ctx.fill();
ctx.lineWidth = Math.max(1, 3 * scale);
ctx.strokeStyle = '#ffffff';
ctx.stroke();
} else if (e.type === 'brute') {
ctx.fillRect(screenX - drawRad, screenY - drawRad * 1.2, drawRad * 2, drawRad * 2);
} else if (e.type === 'spitter') {
ctx.beginPath();
ctx.moveTo(screenX, screenY - drawRad * 1.3);
ctx.lineTo(screenX + drawRad, screenY + drawRad * 0.4);
ctx.lineTo(screenX - drawRad, screenY + drawRad * 0.4);
ctx.closePath();
ctx.fill();
} else {
ctx.beginPath();
ctx.arc(screenX, screenY - drawRad * 0.5, drawRad, 0, Math.PI * 2);
ctx.fill();
}
} else if (type === 'gem') {
const gem: XpGem = entity;
ctx.fillStyle = gem.color;
ctx.shadowColor = gem.color;
ctx.shadowBlur = 12;
const bob = Math.sin(timestamp * 0.005) * 6 * scale;
ctx.beginPath();
ctx.arc(screenX, screenY - drawRad + bob, drawRad, 0, Math.PI * 2);
ctx.fill();
} else if (type === 'proj') {
const p: Projectile = entity;
ctx.fillStyle = p.color;
ctx.shadowColor = p.color;
ctx.shadowBlur = 15;
if (p.type === 'slash') {
ctx.strokeStyle = p.color;
ctx.lineWidth = Math.max(2, 5 * scale);
ctx.beginPath();
ctx.arc(screenX, screenY - drawRad, drawRad * 1.5, 0, Math.PI);
ctx.stroke();
} else {
ctx.beginPath();
ctx.arc(screenX, screenY - drawRad * 0.5, drawRad, 0, Math.PI * 2);
ctx.fill();
}
} else if (type === 'part') {
const p: Particle = entity;
ctx.globalAlpha = Math.max(0, p.alpha);
ctx.fillStyle = p.color;
ctx.beginPath();
ctx.arc(screenX, screenY - drawRad * 0.5, Math.max(1, drawRad), 0, Math.PI * 2);
ctx.fill();
} else if (type === 'weather') {
const wp: WeatherParticle = entity;
ctx.globalAlpha = Math.max(0, wp.alpha);
ctx.fillStyle = wp.color;
ctx.shadowColor = wp.color;
if (biome.weatherType === 'fireflies' || biome.weatherType === 'embers') {
ctx.shadowBlur = 8;
}
ctx.beginPath();
ctx.arc(screenX, screenY, Math.max(1, drawRad), 0, Math.PI * 2);
ctx.fill();
}
ctx.restore();
});
// 6. First Person Weapon View-Model & Muzzle Flash
ctx.save();
const bobX = Math.cos(g.headBob) * 14;
const bobY = Math.sin(g.headBob * 2) * 8 + g.weaponRecoil * 1.8;
const gunX = w * 0.7 + bobX;
const gunY = h * 0.85 + bobY;
if (g.weaponRecoil > 2) {
ctx.fillStyle = heroClass.id === 'engineer' ? '#fbbf24' : '#38bdf8';
ctx.shadowColor = ctx.fillStyle;
ctx.shadowBlur = 30;
ctx.beginPath();
ctx.arc(gunX - 40, gunY - 40, 25 + Math.random() * 15, 0, Math.PI * 2);
ctx.fill();
}
ctx.fillStyle = '#1e293b';
ctx.strokeStyle = heroClass.accentColor;
ctx.lineWidth = 4;
ctx.shadowColor = heroClass.accentColor;
ctx.shadowBlur = 10;
ctx.beginPath();
if (heroClass.id === 'ninja') {
ctx.moveTo(w * 0.8 + bobX, h + bobY);
ctx.lineTo(w * 0.6 + bobX - g.weaponRecoil * 2, h * 0.5 + bobY + g.weaponRecoil);
ctx.lineTo(w * 0.58 + bobX - g.weaponRecoil * 2, h * 0.52 + bobY + g.weaponRecoil);
ctx.lineTo(w * 0.75 + bobX, h + bobY);
} else {
ctx.moveTo(w * 0.85 + bobX, h + bobY);
ctx.lineTo(gunX, gunY);
ctx.lineTo(gunX - 50, gunY - 30);
ctx.lineTo(gunX - 45, gunY - 10);
ctx.lineTo(w * 0.75 + bobX, h + bobY);
}
ctx.closePath();
ctx.fill();
ctx.stroke();
// 7. Sci-Fi FPV Crosshair
ctx.strokeStyle = '#38bdf8';
ctx.lineWidth = 2;
ctx.beginPath();
ctx.arc(w / 2, horizY, 16, 0, Math.PI * 2);
ctx.stroke();
ctx.beginPath();
ctx.arc(w / 2, horizY, 4, 0, Math.PI * 2);
ctx.fillStyle = '#38bdf8';
ctx.fill();
ctx.beginPath();
ctx.moveTo(w / 2 - 24, horizY); ctx.lineTo(w / 2 - 10, horizY);
ctx.moveTo(w / 2 + 10, horizY); ctx.lineTo(w / 2 + 24, horizY);
ctx.moveTo(w / 2, horizY - 24); ctx.lineTo(w / 2, horizY - 10);
ctx.moveTo(w / 2, horizY + 10); ctx.lineTo(w / 2, horizY + 24);
ctx.stroke();
ctx.restore();
}
Let's check: how do floating texts look in First Person vs Top Down?
Wait! Notice that in our code, // Draw Floating Texts is AFTER if (g.viewMode === 'FIRST_PERSON') { ... } else { ... }!
In First Person Mode, should floating texts be projected in 3D or drawn in screen space?
Wait! What if we include g.floatingTexts in the 3D projection list when in First Person Mode?! Or even simpler: if we project floating texts in 3D in FPV mode, they pop right over the enemy's head in 3D space!
Let's check: in our projectItem function, we can add g.floatingTexts.forEach(ft => projectItem(ft, 'text', -20));!
And in renderList.forEach:
} else if (type === 'text') {
const ft: FloatingText = entity;
ctx.font = `900 ${Math.max(10, ft.fontSize * ft.scale * 1.2)}px 'Orbitron', sans-serif`;
ctx.fillStyle = ft.color;
ctx.shadowColor = '#000000';
ctx.shadowBlur = 6;
ctx.fillText(ft.text, screenX, screenY - drawRad * 1.5);
And then when drawing Floating Texts at the bottom of Section 11, we only do if (g.viewMode === 'TOP_DOWN') { g.floatingTexts.forEach(...) }!
That way, damage numbers pop dynamically in 3D space right above the aliens in First Person Mode, and normal screen space in Top-Down Mode!
Let's do this complete, clean edit to Section 11 of GameCanvas.tsx now!
Let's read lines 1540 to 1885 to be completely certain of the exact lines to replace.
Let's read lines 1660 to 1750 of GameCanvas.tsx.
Let's read lines 1750 to 1880 of GameCanvas.tsx.
Let's read lines 1540 to 1575 to see the start of Section 11.
Let's check lines 1860 to 1890 to check where // Draw Floating Texts is and where useEffect dependency array is.
Let's see: we will replace from line 1546 (ctx.fillStyle = biome.bgColor; ...) up to line 1863 (ctx.restore(); // end of weapon cannon turret).
Let's make sure our replacement is clean, complete, and contains zero syntax or type errors.
Let's do this edit now on GameCanvas.tsx.
Let's check if there are any errors or if we need to update the dependency array of the loop useEffect!
Let's check lines 2200 to 2235 of GameCanvas.tsx to find useEffect dependency array and resize handler. Let's use grep_files to find [gameState, autoAim.
Let's edit line 2216 to include biomeId and viewMode in the dependency array:
}, [gameState, autoAim, viewMode, biomeId, heroClass, credits, onUpdateCredits, runStats.currentCombo, runStats.comboTimer, runStats.timeSurvivedSec, settings.screenShake]);
Let's do this edit now.
Now let's run build_project to check for any TypeScript or Vite build compilation errors!
The build succeeded cleanly with 0 errors!
Let's summarize the natural environments and First Person 3D Mode that we added to XENO-CORE: Alien Invasion Action RPG:
🌍 1. Immersive Natural Environments & Biomes
We added 4 distinct interactive natural biomes that can be chosen directly on the Start Screen before deploying on a mission:
- 🌿 Bioluminescent Jungle (Amazon Primeval Forest): Glowing cyan fireflies, alien spore trees with bioluminescent canopy moss, mossy boulders, reflective forest water pools, and swaying wild grass tufts.
- 🏜️ Crystalline Canyon (Sonora Red Dunes): Terracotta earth with drifting dust storms, thorny desert scrub, sandstone rock formations, and purple amethyst crystal clusters.
- ❄️ Aurora Glacial Tundra (Arctic Sapphire Rift): Frosty midnight permafrost with drifting snowstorms, frozen pine trees, sapphire ice crystals, and glacial ice ponds.
- 🌋 Volcanic Ashlands (Obsidian Magma Basin): Charred obsidian badlands with rising glowing thermal embers, burnt timber, obsidian boulders, ruby fire crystals, and glowing lava pools.
🎮 2. Interactive Ecosystem Mechanics
- Solid Tactical Cover: Trees and Boulders act as physical cover against alien spitter acid balls and boss projectiles! When alien shots hit them, they absorb the blast and chip off sparks/leaves, allowing operatives to take tactical defensive cover!
- Destructible Flora & Crystals: Amethyst / Ruby crystal clusters and bulbous spore bushes can be shattered with your weapons! Destructible props flash and spawn debris when hit. When destroyed, they burst into ~15 colorful particles and drop bonus Cyber-Alloy Credits or XP Crystals!
- Wind & Foliage Sway: Tree canopies, spore pods, and grass blades sway organically with atmospheric wind. Walking through water pools or grass tufts triggers shimmering water ripple rings and rustle particles!
🎥 3. Full 3D First-Person Perspective (FPV) Mode!
We implemented a real-time depth-projected 3D First-Person FPS camera mode that can be toggled instantly during gameplay!
- Live Camera Toggle: Click the
🎥 VIEW: FIRST-PERSON 3D / 🎥 VIEW: TOP-DOWN 2D button on the bottom HUD bar, or press the V or Tab hotkey at any time during combat!
- Depth-Sorted 3D World: When in First-Person Mode, the game transforms:
- Sky & Horizon Atmosphere: A dynamic dual linear gradient rendering the biome sky, glowing horizon mist, and shaded ground floor plane.
- Perspective Floor Grid: Radiating perspective rays and exponentially spaced depth lines creating an authentic retro 3D floor.
- 3D Billboards: All environment props (trees, boulders, water pools, crystal formations), enemies (drones, crawlers, brutes, spitters, and towering diamond Alpha Bosses with floating 3D health bars), projectiles, XP gems, and weather particles are projected into camera space and sorted back-to-front for true 3D depth!
- First-Person Weapon View-Model: Your operative's weapon is rendered in first person at the bottom right of your screen (Vanguard's Plasma Rifle, Ninja's Katana Blade, Engineer's Shotgun Cannon) featuring rhythmic walking head-bob, weapon recoil animations, and bright muzzle flashes!
- FPV Controls & Aim Assist: Move forward/back and strafe left/right through the 3D world relative to your facing angle using WASD or touch joystick. Aim smoothly by moving your cursor across the field of view, or engage Auto-Aim to have your operative's visor automatically track the closest alien swarm threat in 3D!
Files built: src/components/HUD.tsx, src/components/GameCanvas.tsx