orbi2d
A 2D orbital-mechanics game in Python + Qt (PySide6). Your rocket starts on a random orbit around a planet. Put it on the dashed green target orbit, to within 2% (the largest radial gap between the two curves, relative to the target).
This started as a vibe-coding project. The first few prompts are documented for posterity in claude_session.txt.
Install and run
pip install orbi2d
orbi2d
From a clone of this repository:
pip install -r requirements.txt
python -m orbi2d # or: python -m orbi2d --seed 42
Controls
| Key | Action |
|---|---|
| ← / → | Side thrusters: rotate the ship (orientation only) |
| ↑ | Main engine |
| Shift (held) | Fine control: 10% thrust, slower rotation |
| 1–6 | Time warp presets ×0.25 / ×0.5 / ×1 / ×2 / ×4 / ×8 |
| + / − | Time warp ×1.25 / ÷1.25 (range ×0.1 – ×16) |
| P | Pause |
| R / N | New random level |
| H | Toggle help |
| Esc / Q | Quit |
The yellow circle next to the ship marks the prograde direction (where the ship is moving). The red ✕ marks retrograde. Pe/Ap mark periapsis and apoapsis.
The game starts at ×0.5 time warp. Turning always happens in real time, but orbital motion and engine thrust follow the warp. Slow motion therefore also makes burns finer: at ×0.25 a tap on ↑ changes your speed 4× less.
Physics
- The rocket and planet form a two-body Kepler system. Coasting uses the analytic universal-variable solution, so the ship follows the drawn conic exactly with no numerical drift. This works for ellipses, parabolas and hyperbolas.
- The main engine is modelled as a finite burn. Each frame is split into short sub-steps, and each sub-step uses kick, exact Kepler coast, kick. After each frame the osculating orbit is recomputed from the state vector and redrawn. So a burn in any direction at any point of the orbit changes the orbit the way it would in reality. For example, a prograde burn at one apsis raises the other apsis, and a radial burn rotates the line of apsides.
- You win when the engine is off and your orbit is within the tolerance of the target. Only the shape of the orbit counts, not the direction of travel. You lose if you hit the planet or escape.
Tuning constants are at the top of orbi2d/game.py.
Tests
python -m pytest
License
MIT. See LICENSE.
Metadata
Release files for orbi2d 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| orbi2d-0.1.0.tar.gz | 15.8 kB | Without provenance | Details for orbi2d-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| orbi2d-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for orbi2d-0.1.0-py3-none-any.whl |
Total release size: 29.9 kB
Release files / orbi2d-0.1.0.tar.gz
| Download URL | orbi2d-0.1.0.tar.gz |
|---|---|
| Size | 15.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
331cbd900c2cb161fb8e38eb084e13ba543de3711a732792af2b7651558fd4ae
|
|
BLAKE2b-256 checksum How to use checksums |
8da97a9cbce4802f804bb86d649a8681b1e2e54f259f2567902d2784160fa74a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.3
|
Release files / orbi2d-0.1.0-py3-none-any.whl
| Download URL | orbi2d-0.1.0-py3-none-any.whl |
|---|---|
| Size | 14.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bf25e38799681b7296d853c01a7c1859cf6fd2eeb062929ee1776f0c9ac9d873
|
|
BLAKE2b-256 checksum How to use checksums |
26f448af3e6280ec83f832604222f4c6a8acfbdb0f8d46c4374d36b8064eb7bf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.3
|
Security for orbi2d 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.