A game loosely based on the original Spacewar

PySpaceWar is an open-source game, loosely inspired by Spacewar, Gravity Wars, and a bit by Star Control (I and II).

Two ships duel in a gravity field. Gravity doesn't affect the ships themselves (which have spanking new anti-gravity devices), but it affects missiles launced by the ships.

You can play against the computer, or two players can play with one keyboard. There is also a Gravity Wars mode, where the two ships do not move, and the players repeatedly specify the direction and velocity of their missiles.


Screenshot of the title screen Screenshot of the menu screen Screenshot in the middle of a game Screenshot of gravity wars mode


September 17, 2016: Released version 1.0.0:

February 10, 2016: Released version 0.9.8:

March 8, 2010: Released version 0.9.7:

See full changelog


The latest release is 1.0.0. You can download it from the Python Package Index.

Dependencies that you have to install before you can play:

I would appreciate it if someone could build Windows or Mac OS X packages.

You can also check out the latest version from Github:

git clone

Quick Start

Download the game, and make sure you have all the dependencies installed (Python, PyGame). Unpack the tarball or zip file, and run pyspacewar. There is no need to compile anything.

Default Controls

Player 1 (white)
LEFT, RIGHT rotate
UP accelerate in the direction you're facing
DOWN accelerate in the opposite direction
RCTRL launch a missile
RALT brake (lose 5% speed)
1 enable/disable computer control
Player 2 (green)
A, D rotate
W accelerate in the direction you're facing
S accelerate in the opposite direction
LCTRL launch a missile
LALT brake (lose 5% speed)
2 enable/disable computer control
F toggle full-screen mode
ALT+ENTER toggle full-screen mode
O hide/show missile orbit trails (speeds up drawing)
PAUSE pause the game (useful for taking screenshots)
ESC escape to menu
F12 show frame rate and a bunch of timings for optimisation work
+, - zoom in/out
mouse wheel zoom in/out
left click escape to menu
right drag drag the viewport around


PySpaceWar was written by Marius Gedminas (physics, graphics) and Ignas Mikalaj┼źnas (AI). It is released under the terms of the GNU GPL.

Planet images are borrowed from an open-source on-line strategy game IGE - Outer Space.

The background image is a darkened version of a public domain Hubble Space Telescope picture of the NGC 3949 galaxy.

Icons were contributed by Jakub Szypulka and licenced under the Creative Commons Share-Alike 3.0 licence.


Report bugs on Github.