A few weeks ago I shipped AgentSlash - a free, instant-play browser game where you slice rogue AI agents out of the air before they take over, while being careful not to touch the humans mixed in. One wrong cut and the run's over. No build step, no game engine, no download - just a element and vanilla JavaScript. Here's how it's put together.
The core loop
Every run spawns a steady stream of objects - some AI agents, some humans — that arc across the screen under simple projectile motion: an initial velocity plus constant gravity. The player has well under a second to read which is which before it's gone.
function spawnObject() {
const isHuman = Math.random() < HUMAN_RATIO;
objects.push({
type: isHuman ? 'human' : 'agent',
x: randomX(),
y: canvas.height,
vx: randomVX(),
vy: -LAUNCH_SPEED,
radius: HIT_RADIUS,
sliced: false,
});
}
function update(dt) {
for (const obj of objects) {
obj.vy += GRAVITY * dt;
obj.x += obj.vx * dt;
obj.y += obj.vy * dt;
}
}
No physics engine needed - just enough math to make the arcs feel natural.
Why skip a game engine
AgentSlash is meant to load instantly inside portals and embeds, not after a multi-megabyte engine download. Vanilla Canvas plus a requestAnimationFrame loop keeps the whole game lightweight and keeps the mental model simple: one render loop, one array of active objects, one collision pass per frame.
Hit detection
A swipe is tracked as a sequence of points. Each frame, the game checks whether any new segment of that swipe path crosses an object's hit circle:
function swipeHitsObject(trail, obj) {
for (let i = 1; i < trail.length; i++) {
if (segmentIntersectsCircle(trail[i - 1], trail[i], obj)) return true;
}
return false;
}
Miss the timing and the segment check simply never fires — no special-case code needed for a "whiff."
The stakes
Two power-ups change the rhythm: Freeze briefly slows every object in the air for precision cuts, and Overclock Frenzy floods the screen with extra agents for a short, high-scoring window. But the real tension isn't either of those - it's that slicing a single human ends the run immediately, and missing three agents ends it too. No lives, no mid-run retries. That one rule did more for the game's tension than any amount of difficulty tuning.
If you want to try it, AgentSlash is free and instant at https://instantgames.in/games/agentslash/. I'd love to know - what's your longest streak before you accidentally slice a human?

Top comments (0)