Desktop browser with a keyboard (Chrome, Edge or Firefox). The first load takes a moment: it downloads the Python runtime and the game.
A StarCraft II themed vertical shooter: fly a Terran Viking from a Terran Starport, through an asteroid field and the Protoss outposts, to the Protoss Stargate and its Carrier. See the game intro (中文介绍) for more screenshots.
In motion:
Desktop (Python 3.10 with pygame 2.1 or later):
pip install -r requirements.txt
python LostViking.pyWeb (with pygbag), then open http://localhost:8000:
python -m pygbag --template static/lostviking.tmpl --icon static/favicon.png .Add --build to only build build/web without starting the test server.
| Key | Action |
|---|---|
| WASD or arrow keys | Move |
| Space | Shoot |
| E | Switch weapon (the Viking transforms) |
| Q | Nuclear bomb |
| Esc or P | Pause |
| Tab | Show / hide equipment panel |
| F3 | Show / hide FPS |
Volume, screen shake, screen flashes and the FPS counter can be changed in Settings (main menu or pause menu).
They are saved with the best score in settings.json (desktop) or the browser storage (web).
The Viking flies from a Terran Starport to a Protoss Stargate. The route, shown on the left edge of the screen, has stages, each announced by its name:
- Launch: the Viking takes off from the launch pad of the Terran Starport.
- Asteroid field: spinning rocks drift down, a large rock breaks into two medium rocks, a medium rock into two small ones. Flying into a rock hurts. Large and medium rocks are armored. Rocks are cover: enemy shots stop at them (beams go through), and enemy fire chips them too.
- Protoss patrol: Scout formations, Phoenixes, an Oracle.
- Protoss outposts: floating platforms with a Pylon and Photon Cannons (fixed turrets firing at you). The Pylon powers the cannons of its platform: destroy it and they go dark. Destroy everything on a platform for a bonus. You fly over the structures (they do not ram you).
- Stargate (WARNING): it builds ships (Scouts warp out of its portal, an Oracle, Phoenixes), releases rings of photon orbs, and two cannons stand on its wings. Before it falls it warps out the Carrier, then blows up.
- Carrier: destroy it to win.
- Two weapons, as the StarCraft II Viking, switched with E (no shot while the Viking transforms):
- Twin gatling: fast straight shots, the best against light ships (Interceptors, Phoenixes) and shields. From weapon level 4 its shots turn green and go through ships: one ship at level 4, two at level 5, 30% less damage after each. A shield stops them.
- Lanzer Torpedoes: homing torpedoes in salvos of pairs, extra damage against armored targets (Scouts, Oracles, large and medium rocks, structures, the Carrier).
- Supplies: weapon upgrade (5 levels, for both weapons), nuclear bomb, repair (or one more life when not damaged). They blink before they leave and fly to you once you are close.
- Losing a life costs the weapon upgrades: they drop from the wreck, pick them up again.
- Scouts weave, dive at you, strafe across the screen or stop to fire aimed bursts, alone or in formations.
- Phoenixes use a Graviton Beam: a dashed line shows where they aim, it locks and blinks, then fires. If it catches you, you are pulled toward the Phoenix and hard to steer: break its shield to get free.
- Oracles warp in and stay a while:
- Pulsar Beam: the Oracle stops above you, a dashed line shows the beam charging, then it burns and follows you slowly. Move sideways.
- Stasis Ward: dropped ahead of you, faint at first; once armed a dashed ring turns around it. Touching an armed ward freezes you in a crystal for almost a second: no move, no shot, no bomb, but no damage either. Shoot the wards down.
- The Carrier has an energy shield (the cyan bar under its health): it takes the hits first and recharges when the Carrier is left alone for a moment; once broken it comes back a few seconds later. Torpedoes get no armor bonus against it: use the gatling.
- The Carrier gets angry below half health: its attacks come faster.
- The nuclear bomb goes through shields.
Choose Test Mode in the main menu to play with a test panel (press ` to show / hide it).
Each action has a key and can also be clicked: spawn any enemy or the boss, damage the boss,
level up the weapon, add bombs and lives, god mode, turn automatic spawning off and show hitboxes.
"Scout wave" brings a random Scout formation, "Oracle" warps one in, "Asteroid" and "Outpost" bring
a rock or a platform, "Stargate" starts the boss fight, "Next stage" jumps along the route.
Test mode scores do not count as best score.
- One codebase for the desktop and the browser. The game runs in WebAssembly through
pygbag: the main loop is
asyncand gives control back to the browser every frame. The web build keeps the settings inlocalStorage, stops the sound when the tab is hidden, and has its own pixel-art loading page. - Fixed-timestep game loop. The logic runs 60 times per second of real time: after a slow frame the missed updates run without drawing, and a long freeze (a hidden tab) is skipped instead of fast-forwarded.
- Pixel art drawn in code, on the same 2x pixel grid as the sprites:
- Effects: explosions (value noise and ordered dithering, fire cooling into smoke), the Carrier laser, the Graviton and Pulsar beams, warp-ins, screen flashes.
- Planets: a random planet each time one appears (five kinds, lit, with craters, storms and rings).
- Sprites: generators for the chibi sprites.
- No first-use stutter: slow images are made ahead of time, a little each frame.
- RotSprite rotation in 32 directions for the ships that turn: pixel outlines stay clean.
- Game feel: hit stop, trauma-based screen shake (the HUD stays still), hit flashes and smooth steering for enemies and supplies.
Tests run without a window or a sound card (SDL dummy drivers). They drive the real game: menus, whole rounds, every stage, the bosses and the effects.
pip install -r requirements-dev.txt
python -m pytestGitHub Actions (.github/workflows/ci.yml) runs the tests on every
push and pull request. On main it then builds the web version with pygbag and publishes it to
GitHub Pages.
The GIFs in this README are recorded headless by python tools/record_gifs.py (needs Pillow).
python tools/bench.py [frames] [--boss-at FRAME] [--god] lets a bot play a round headless and prints the
time of the update and draw of each frame (mean, 95th percentile, worst). Set LOSTVIKING_DEBUG=1 to log every
loaded asset and spawned enemy.
The Viking, the Scouts, Interceptors, Phoenixes and the Carrier, the bullets and the nuke keep
their original art, drawn in Aseprite: the sources are in
LostViking-pixel_art. The Oracle, the asteroids, the structures (Terran Starport, outposts, Stargate)
and the supplies are chibi pixel art (round shapes, cel shading, big 2x pixels, a white rim around
ships and targets), made by the generators in tools/pixel_art (see its README).








