Last Light Outpost: a Godot zombie base-defense game for Android and the browser

Last Light Outpost is a top-down zombie base-defense game. You are the last soldier at a small outpost at night, and you have to keep the HQ bunker standing through 10 waves with a rifle, auto-turrets and sandbag walls. It is written in GDScript for Godot 4.7, and every sprite and sound is generated by code. It runs in the browser and is on Google Play.
- Google Play: Last Light Outpost
- In the browser: friendlyuser.github.io/last-light-outpost
- Source: github.com/FriendlyUser/last-light-outpost

How a game goes
Section titled “How a game goes”Each wave starts with a build phase: 30 seconds before the first wave and 25 before the others, or less if you start the wave early. In the build phase you spend cash in the armory and place structures anywhere within 320 pixels of the HQ. Then zombies spawn off-screen on all four edges and walk to the HQ, switching to you if you come close. Kills pay cash, and clearing a wave pays a bonus of 50 + 15 × the wave number. The game is lost when the HQ reaches 0 HP and won when wave 10 is cleared.
The numbers live as constants at the top of the scripts. The main ones:
| Thing | Value |
|---|---|
| Starting cash | $200 |
| HQ | 1,500 HP; repair +250 HP for $75 between waves |
| Player | 100 HP, regenerates 4 HP/s after 3 s without damage, back on their feet 5 s after going down |
| Rifle | 20 damage, a shot every 0.16 s, 15-round magazine, 1.2 s reload |
| Auto-turret | $150, plus $30 for each turret you already own; 160 HP, range 240, 12 damage every 0.45 s |
| Sandbag wall | $40, 260 HP |
| Rifle upgrades | Damage and fire rate ($80, +$60 per level, 5 levels each), magazine ($60, +$40 per level, 4 levels) |
Going down doesn’t end the game: the turrets have to hold the line for five seconds. The rising turret price is what keeps a game from turning into turret spam. By the fifth turret, each one costs $270.
Building the waves
Section titled “Building the waves”Four kinds of zombie share one script. Their stats sit in a single dictionary in scripts/zombie.gd:
| Kind | HP | Speed | Damage | Reward | First wave |
|---|---|---|---|---|---|
| Walker | 40 | 60 | 10 every 1.0 s | $10 | 1 |
| Runner | 22 | 120 | 6 every 0.7 s | $12 | 3 |
| Brute | 220 | 36 | 30 every 1.4 s | $40 | 5 |
| Abomination | 2,200 | 32 | 50 every 1.6 s | $300 | 10 (boss) |
Every zombie except the boss gets 18% more HP per wave (×(1 + 0.18 × (wave − 1))), and each one’s speed varies by ±10% so the horde doesn’t move in lockstep. build_wave in main.gd decides who comes:
func build_wave(w: int) -> Array[String]: var total := 8 + 5 * w if w >= MAX_WAVES: # The Abomination is the final wave's centrepiece; fewer regulars keep the finale fair. total -= 10 var runners := 0 if w >= 3: runners = roundi(total * minf(0.35, 0.1 + 0.04 * w)) var brutes := 0 if w >= 5: brutes = (w - 3) / 2 var walkers := total - runners - brutes # ...fill the list with walkers, runners and brutes, then shuffle it if w >= MAX_WAVES: list.insert(list.size() / 2, "boss") return listWave 1 is 13 walkers. The share of runners grows by 4 points a wave up to a cap of 35%. Wave 5 brings one brute, and the count rises to three by wave 9. The final wave has 48 regulars and puts the Abomination in the middle of the queue, not at the end, so it arrives while the defences are still busy. Spawns speed up as waves go on: the gap between spawns is max(0.4, 1.4 − 0.1 × wave) seconds, and later waves spawn in small bursts from several sides at once.

No asset files
Section titled “No asset files”The repository has no sprite sheets or audio files. Every visual is drawn in _draw() calls. The design document says no image or audio generation model was connected while it was made, so code-drawn art was the agreed substitute. Sounds are synthesized when the game starts: scripts/sfx.gd fills PackedFloat32Array buffers for the rifle, turret, hits, zombie deaths, groans, HQ impacts, building, reloading, the wave siren and an error buzz. It wraps each buffer in a 16-bit AudioStreamWAV at 22,050 Hz and plays them through a pool of 16 AudioStreamPlayer voices.
Drawing everything in code makes it easy to end up with hundreds of draw calls a frame, so the expensive parts are baked once. The ground and the blood decals are rendered into textures through SubViewports, and every zombie shares one sprite atlas built at startup (scripts/zombie_art.gd). The design document reports a 50-zombie horde at about 340 draw calls and 3 ms of physics on desktop.
The project uses the GL Compatibility renderer on both desktop and mobile, with a fixed 1280 × 720 arena and the canvas_items stretch mode with keep aspect. So a phone, a tablet and a browser window all show the same field, letterboxed if needed.
Touch controls and Android quirks
Section titled “Touch controls and Android quirks”On a phone the game is played twin-stick style. A floating stick on the left half of the screen moves, and one on the right half aims and fires while it’s pushed past a small dead zone. WALL, TURRET and RELOAD buttons sit in the corner. To build, you drag on the map to move the preview and lift your finger to place it. The touch controls appear at launch on mobile or after the first touch, and a real mouse hides them again.
Two details took explicit handling:
- Emulated mouse events. Godot turns touches into mouse events by default, which the menus rely on. During play, a stick touch would then also count as a click and fire a stray shot. So gameplay input ignores emulated mouse events, and only the touch-control script reads screen touches.
- The back button. The code’s comment says Godot 4.7 on Android delivers each back press twice within a few milliseconds, so presses within 300 ms count once:
elif what == NOTIFICATION_WM_GO_BACK_REQUEST: # Godot 4.7 on Android delivers each back press twice within a few ms; act on the first only. var now := Time.get_ticks_msec() if now - _last_back_ms < BACK_DEBOUNCE_MS: return _last_back_ms = now if is_playing(): toggle_pause() elif is_over() and hud.end_visible(): restart() elif state == State.TITLE: get_tree().quit()The same _notification handler pauses the game on NOTIFICATION_APPLICATION_PAUSED, so the base doesn’t fall while the phone is in a pocket.
The Android export uses Godot’s Gradle build to produce an .aab. It targets SDK 36, ships arm64-v8a and armeabi-v7a, runs in immersive mode and has the Internet permission turned off; the game needs no permissions at all. The upload key is passed in through Godot’s GODOT_ANDROID_KEYSTORE_RELEASE_* environment variables and is never stored in the repository. The design document records a check on an Android 16 emulator covering launch, touch building, combat, the back button and auto-pause.
Tests that play the game
Section titled “Tests that play the game”tests/autotest.gd drives the real game through input events and checks the rules: building, costs, invalid placements, the armory, shooting, reloading, touch sticks, pause, waves, game over and victory. It is excluded from the web export.
godot --headless --path . -- --autotest # rule checksgodot --headless --path . -- --autotest --full # plus a full 10-wave rungodot --headless --path . -- --autotest --balance --human # balance probeThe balance probe plays a fair run from $200 and logs the HQ’s health and the cash after each wave. According to the design document, an aim bot that spends sensibly wins with the HQ at 58–96%, while a player who only builds turrets and never shoots falls at wave 3. That was the check that the rifle matters. tools/store_art.gd renders the Play icon, feature graphic and screenshots from the game itself, which is where the screenshots in this post come from.
Outpost Z, the PixiJS sibling
Section titled “Outpost Z, the PixiJS sibling”Outpost Z (play in the browser) is the same premise built with PixiJS 8, TypeScript and Vite. Its first commit landed about 50 minutes before Last Light Outpost’s, on the same morning. It is the bigger design:
- 20 waves instead of 10.
- A choice of three heroes (Commando, Engineer, Sharpshooter), each with an ability.
- Five structures with three levels each, including barbed wire, cannons and gold mines.
- Zombies that follow a Dijkstra flow field around walls.
- A night lightmap multiplied over the battlefield during waves.
It is keyboard and mouse only, and it isn’t on Google Play. Last Light Outpost is the smaller game, with touch controls, an Android build and the automated playtests.
© 2026 David Li · Home · Blog · RSS ·Classic site · Built with Astro, Starlight and three.js · Logos:Font Awesome Free (CC BY 4.0)