Mechanic · environment · space flight simulation, multidirectional shooter
Gravity well
A body in the playfield pulls nearby craft and shots toward itself, bending their paths.
On this page
A gravity well pulls whatever comes near a body toward it, and with inertia the craft keeps the speed the pull gives it. In Star Control II a Melee planet adds the same small pull every frame to anything within 255 display units of it, however near1. Inside that pull, thrust may take a ship past its usual top speed2.
- Constant pullStar Control II (1992). A Melee planet adds 1 world unit per frame toward itself to anything within 255 display units.1
Games
| Game | Year | How | Note |
|---|---|---|---|
| Star Control II | 1992 | Constant pull | a Melee planet adds 1 world unit per frame toward itself to anything within 255 display units |
Every claim about this mechanic, by game (1)
References
- ^ abcA Melee planet is an element with 200 hit points and a mass of 200, above
GRAVITY_MASS's threshold of 100 (10 timesMAX_SHIP_MASS), whose per-frame postprocess isCalculateGravity. That routine pulls every other colliding element without such mass that lies within 255 display units of the planet (GRAVITY_THRESHOLD, tested on each axis and then as a radius, measured the short way across the arena's wrapped edges): it adds 1 world unit per frame to the element's velocity, aimed at the planet, whatever the distance, and flags a ship as in a gravity well. A block under#ifdef NEVER, never compiled, works out a pull from the distance, capped at 6, and only prints it.CodeThe Ur-Quan Masters (2002 import)How we know
22spawn_planet (void) ⋮ 34 PlanetElementPtr->hit_points = 200; ⋮ 42 PlanetElementPtr->postprocess_func = 43 (void (*) (struct element *ElementPtr))CalculateGravity; ⋮ 54 PlanetElementPtr->mass_points = PlanetElementPtr->hit_points;
sc2/src/sc2code/misc.c lines 22–54 at 2f5b2c3 · upstream ↗ 131#define MAX_SHIP_MASS 10 132#define GRAVITY_MASS(m) ((m) > MAX_SHIP_MASS * 10) 133#define GRAVITY_THRESHOLD (COUNT)255
sc2/src/sc2code/element.h lines 131–133 at 2f5b2c3 · upstream ↗ 28 HasGravity = (BOOLEAN)(CollidingElement (ElementPtr) 29 && GRAVITY_MASS (ElementPtr->mass_points + 1)); ⋮ 38 && CollidingElement (TestElementPtr) 39 && (TestHasGravity = 40 GRAVITY_MASS (TestElementPtr->mass_points + 1)) != HasGravity) ⋮ 66 dx = WRAP_DELTA_X (dx); 67 dy = WRAP_DELTA_Y (dy); ⋮ 74 abs_dx = WORLD_TO_DISPLAY (abs_dx); 75 abs_dy = WORLD_TO_DISPLAY (abs_dy); ⋮ 80 if (abs_dx <= GRAVITY_THRESHOLD 81 && abs_dy <= GRAVITY_THRESHOLD) ⋮ 87 if (dist_squared <= (DWORD)(GRAVITY_THRESHOLD ⋮
sc2/src/sc2code/gravity.c lines 28–131 at 2f5b2c3 · upstream ↗ 131#define WRAP_DELTA_X(dx) ((dx)<0 ? \ 132 ((-(dx)<=LOG_SPACE_WIDTH>>1)?(dx):(LOG_SPACE_WIDTH+(dx))) : \
sc2/src/sc2code/units.h lines 131–136 at 2f5b2c3 · upstream ↗ Checked against the evidence by its author, an AI model, 2026-10-22.
Checked by a second AI model, 2026-10-22.
- ^
inertial_thrustcaps the speed itself, not each axis: after adding a thrust step it compares the sum of the squared components withMAX_THRUSTsquared, so a ship is no faster on a diagonal. Asteroids clamps each axis of its ship's velocity apart, so its diagonal is faster (asteroids/top-speed). A step that would pass the cap still applies if the result is slower than the current speed. At the cap, a step along the line of travel sets the velocity to exactlyMAX_THRUSTalong the facing (if the ship isn't above the cap); a step off the line instead adds half a thrust step along the facing and takes a whole step off along the line of travel, kept if that ends within the cap or slower than before, so the course swings toward the facing. While the ship is flagged in a gravity well, a thrust step may take it past the cap up toMAX_ALLOWED_SPEED, 18 display units per frame.CodeThe Ur-Quan Masters (2002 import) · Computer Archeology, AsteroidsHow we know
75 desired_speed = (DWORD)((long)delta_x * delta_x) 76 + (DWORD)((long)delta_y * delta_y); 77 max_speed = (DWORD)WORLD_TO_VELOCITY (max_thrust) 78 * WORLD_TO_VELOCITY (max_thrust); 79 if (desired_speed <= max_speed) 80 SetVelocityComponents (VelocityPtr, delta_x, delta_y); 81 else ⋮ 83#define MAX_ALLOWED_SPEED WORLD_TO_VELOCITY (DISPLAY_TO_WORLD (18)) ⋮ 86 if (((StarShipPtr->cur_status_flags & SHIP_IN_GRAVITY_WELL) 87 && desired_speed <= 88 (DWORD)MAX_ALLOWED_SPEED * (DWORD)MAX_ALLOWED_SPEED) 89 || (current_speed = ⋮
sc2/src/sc2code/ship.c lines 75–128 at 2f5b2c3 · upstream ↗ 56 else if ((TravelAngle = 57 GetVelocityTravelAngle (VelocityPtr)) == CurrentAngle 58 && (StarShipPtr->cur_status_flags 59 & (SHIP_AT_MAX_SPEED | SHIP_BEYOND_MAX_SPEED)) 60 && !(StarShipPtr->cur_status_flags & SHIP_IN_GRAVITY_WELL))
sc2/src/sc2code/ship.c lines 56–62 at 2f5b2c3 · upstream ↗ BMI $7130 ; {} CMP #$40 BCC $7138 ; {} LDX #$FF LDA #$3F RTS CMP #$C0 BCS $7138 ; {} LDX #$01 LDA #$C0
content/Arcade/Asteroids/Code.md#L1135-L1145 · upstream ↗ Checked against the evidence by its author, an AI model, 2026-10-22.
Checked by a second AI model, 2026-10-22.
Sources
Code
- Reiche, Paul, Fred Ford, and The Ur-Quan Masters project. 2002. “The Ur-Quan Masters: Star Control II's 3DO source, the project's initial import.” Commit 2f5b2c3. sc2/uqm @ 2f5b2c3 · licence, all uses
- Howell, Lonnie, Mark McDougall, and Christopher Cantrell. 2026. “Computer Archeology: Asteroids.” Commit 1adc2a7. topherCantrell/computerarcheology @ 1adc2a7 · licence, all uses