Case study · Browser game
IBAMA Chopper, a complete game in 341 KB
A satirical Choplifter-style helicopter game in plain JavaScript and Canvas. Pixel art that stays sharp on any screen, sound synthesized in code, a seeded level and controls designed for a thumb.
Gameplay
Menu
On a phone
- Stack
- JavaScript, Canvas 2D, Web Audio
- Dependencies
- None
- Size
- 341 KB, 65 asset files
- Target
- Mobile first, portrait
- JavaScript
- Canvas
- Web Audio
- Pixel art
- Antigravity
Play it here
The full game, in the page

Arrows or WASD to fly, Space to fire, B for a bomb, P to pause. On a phone, use the controls under the game.
Pixel art, sharp on any screen
Art-pixel world, scaled into a high-res canvas
Problem
The same pixel-art world had to look crisp in a 270-wide desktop column and on phones of many heights, while the HUD text stayed readable.
Solution
The world is drawn in art pixels (270 × 480 by default) and scaled by a factor K into a canvas sized for the real screen and capped at 3× pixel ratio. Sprites stay hard-edged with image-rendering: pixelated.
function fit() {
const W = innerWidth, H = innerHeight;
let s;
if (TOQUE) {
const zona = clamp(H * 0.27, 150, 230);
s = Math.min((H - zona) / AREA_JOGO, W / 240);
VW = Math.min(W / s, 420);
VH = H / s;
const livre = H - AREA_JOGO * s;
document.documentElement.style.setProperty('--ctrlH', Math.round(Math.min(livre, 300)) + 'px');
} else {
VW = 270;
VH = Math.round(clamp(VW * H / W, 380, 620));
s = Math.min(W / VW, H / VH);
}
cv.style.width = Math.floor(VW * s) + 'px';
cv.style.height = Math.floor(VH * s) + 'px';
const kk = clamp(s * (window.devicePixelRatio || 1), 1, 3);
cv.width = Math.round(VW * kk); cv.height = Math.round(VH * kk);
K = cv.width / VW;
}Tinted variants, built once
When the sprites load, each one gets two precomputed copies: a burnt version (dark overlay at 72%) for destroyed machines and a white flash (80%) for hit feedback. The tint uses source-atop compositing, so it respects the sprite's alpha without reading pixels.
The distant forest layer is the same tile tinted toward sky blue, which gives atmospheric depth with no extra art.
// pinta por cima do sprite respeitando o alpha (sem ler pixels => funciona em file://)
function tingir(img, cor, a) {
const c = document.createElement('canvas');
c.width = img.width; c.height = img.height;
const g = c.getContext('2d');
g.drawImage(img, 0, 0);
g.globalCompositeOperation = 'source-atop';
g.globalAlpha = a; g.fillStyle = cor;
g.fillRect(0, 0, c.width, c.height);
return c;
}The cast, at native size
Helicopter · 72×24
Miner · 17×22
Armed guard · 24×22
Surrendered · 10×22
Tractor · 40×26
Boss robot · 124×117
Sound with zero audio files
Web Audio oscillators, noise and a chiptune loop
Every sound effect and the music are synthesized at runtime. The game ships no audio files.
- A 25% pulse wave built with
PeriodicWavegives the NES timbre, next to square, triangle and sawtooth oscillators. - Explosions are a low-pass filtered noise burst plus a falling triangle tone, scaled by the size of the target.
- The music is a loop with a triangle bass, a pulse melody and a noise snare. The boss fight swaps the melody and raises the tempo from 138 to 168 BPM.
- Repeating effects are rate-limited, so a held trigger never turns into a wall of noise.
- The mute choice is stored in
localStorage.
function tom(f0, f1, dur, vol, tipo, quando, destino) {
if (!ac || !ligado) return;
const t = quando || ac.currentTime, o = ac.createOscillator(), g = ac.createGain();
if (tipo === 'pulso') o.setPeriodicWave(pulso); else o.type = tipo || 'square';
o.frequency.setValueAtTime(f0, t);
if (f1 !== f0) o.frequency.exponentialRampToValueAtTime(Math.max(20, f1), t + dur);
g.gain.setValueAtTime(vol, t); g.gain.exponentialRampToValueAtTime(0.0008, t + dur);
o.connect(g); g.connect(destino || sfxG); o.start(t); o.stop(t + dur + 0.02);
}Game feel
Shake, hit-stop and combos
Screen shake
Every kill, boss step and drill charge adds shake, with a cap so it never gets unreadable. A bigger machine shakes the screen more.
Hit-stop
A kill freezes the simulation for 3 frames, which makes explosions land harder with no extra art.
Combos
Chain kills within 2.5 seconds and the score multiplier climbs to 8. Delivering prisoners uses the same multiplier.
Flying right, firing and dropping bombs
A seeded level
The same 16,500 px world on every run
The level is generated once from a fixed seed, so every run has the same layout, and it stays tunable by changing one number. The generator lays targets along the world and gets denser as the player nears the boss.
- 58 targets drawn from 18 types, each with its own HP and points. Ground machines go on land and boats only in rivers.
- 11 rivers and 3 IBAMA posts. Landing on a post refills ammo and bombs and repairs the helicopter.
- Spacing shrinks, and guards and turrets show up more often as the player nears the boss, so the last stretch feels busier without extra rules.
- Guards never spawn in rivers or next to a post.
// gerador pseudoaleatório com semente (mulberry32)
function semente(s) {
return () => {
s = s + 0x6D2B79F5 | 0;
let t = Math.imul(s ^ s >>> 15, 1 | s);
t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t;
return ((t ^ t >>> 14) >>> 0) / 4294967296;
};
}
const R = semente(2026); // layout fixo: mesma fase em toda partidaSurrender, not slaughter
An arrest loop and a boss with two phases
Armed guards that are hit surrender instead of dying. Arresting them is the main way to score.
The arrest loop
Hit an armed guard
He surrenders, hands up
Land nearby
He runs to the helicopter
Board
Up to 6 at a time
Land on a post
One prisoner every ~1/3 s
300 × combo
Points per delivery
If the player waits too long, about 25 seconds, the prisoner runs away and jumps into the river. Taking off while he runs makes him wait again.
A robot with 1000 HP
Three attacks: aimed shots, a drill charge that ends in a dash, and a shovel that lobs shots in an arc. It never picks the same attack twice in a row.
Under 50% HP
It walks faster, shoots more often, charges sooner and throws one extra shovel shot.
Warnings first
An alarm and a screen shake announce the boss. The charge shakes and revs before the dash, which gives the player time to move.
Built for a thumb
Mobile-first controls
The control strip lives below the play area
On a phone, the controls get their own zone, so a thumb never covers the action.
- The strip is 27% of the screen height, between 150 and 230 px. The world is scaled so the whole play area fits above it. Below the ground there is only river, which is where the buttons sit.
- The joystick is floating: it appears wherever the thumb lands in the left half of the strip.
- Hold FIRE for the nose-down diagonal shot. Tap BOMB to drop one under the helicopter. Pause and mute are in the same strip.
- Some events vibrate the phone. The page asks for fullscreen on start and tells the player to rotate to portrait.
- A web app manifest sets fullscreen portrait for "Add to home screen".
A tutorial that points at the real buttons
The five-step tutorial has separate copy for touch and keyboard, and on a phone it highlights the actual button it is talking about while the strip is locked. Steps cover flying, firing, bombs, arrests, and ammo and posts.
Tutorial, step 1 of 5
Iteration
Straight from the commit history
05 Nov, 12:54
First playable: IBAMA helicopter against illegal mining.
05 Nov, 15:32
Phone controls move to their own zone below the play area (joystick + FIRE / BOMB).
05 Nov, 15:52
Miners replace soldiers. 8-bit sound, screen shake, combos, and a slower boss.
05 Nov, 16:17
Satire notice added. Armed guards surrender instead of dying. Generic sign at the posts.
05 Nov, 16:46
Arrests: surrendered miners board the helicopter and are delivered to the posts. IBAMA sign back.
It was built with Antigravity, an AI IDE. Five commits between 12:54 and 16:46 on the same day took it from first playable to the arrest loop.
The game is clearly labelled as satire. The menu and the end screen both carry the notice that it is an independent work of fiction with no link to IBAMA or any public body.
- Whole game
- 341 KBWhole game
- Dependencies
- 0Dependencies
- Audio files
- 0Audio files
- Targets in the level
- 58Targets in the level
Takeaway
Small on purpose. Complete anyway.
One HTML page, one 1,765-line script and a folder of sprites. It loads instantly on a phone and plays from a link.