terrain-shapes.ts
Purpose
Defines the master TERRAIN_SHAPES table — geometric/visual parameters for every terrain entity kind (asteroids, city buildings, obsidian pillars). Consumed by terrain generation/spawn code to build polygon, circle, rect, or sprite-based obstacles. Header comment notes this is an exact match of archive 01-config.js TERRAIN_SHAPES.
Exports
interface TerrainShapeDef
| Field | Type | Notes |
|---|---|---|
type | 'polygon' | 'circle' | 'rect' | 'sprite' | Rendering/collision primitive |
verts | number | Vertex count for polygon edge irregularity |
baseRadius | number | Base size in screen px before scaling |
scaleMin | number | Lower bound of scale multiplier applied to baseRadius |
scaleMax | number | Upper bound of scale multiplier applied to baseRadius |
jitter | number | Edge irregularity factor (0 = clean, higher = jagged) |
w? | number | Width — rect type only |
h? | number | Height — rect type only |
spriteId? | string | Sprite identifier (sprite type) |
spriteAspect? | number | Sprite aspect ratio (sprite type) |
const TERRAIN_SHAPES: Record<string, TerrainShapeDef>
Keyed master table of shape definitions.
Entries
Asteroids (polygon)
Collision is circle with radius = baseRadius × scale. Visual polygon matches collision radius. v1.50 balance pass: 50% smaller than original.
| Key | verts | baseRadius | scale range | jitter | Final px range |
|---|---|---|---|---|---|
asteroid_sm | 5 | 75 | 1.0–1.5 | 0.20 | 75–112 |
asteroid_md | 6 | 85 | 1.0–1.6 | 0.18 | 85–136 |
asteroid_lg | 7 | 98 | 1.0–1.6 | 0.15 | 98–156 |
asteroid_xl | 8 | 100 | 1.0–1.8 | 0.12 | 100–180 |
rock_shard | 5 | 60 | 1.0–1.3 | 0.25 | 60–78 |
City buildings (sprite)
4 standard footprints, no scale variance (scaleMin = scaleMax = 1.0), jitter = 0, verts = 4.
| Key | baseRadius |
|---|---|
building_1x1 | 277 |
building_2x1 | 322 |
building_1x2 | 284 |
building_2x3 | 385 |
building_sm (legacy alias) | 277 |
building_md (legacy alias) | 322 |
Obsidian pillars (sprite)
Square-topped columns with gradient fade. 4.8× original size. No scale variance, jitter = 0, verts = 4.
| Key | baseRadius |
|---|---|
pillar_sm | 576 |
pillar_md | 768 |
pillar_lg | 960 |
Behavioral notes
scaleMin/scaleMaxmultiplybaseRadiusat generation time to produce per-instance size.jitteronly meaningful forpolygontype — applied to vertex offsets to randomize edges.- All
spritetype entries (buildings, pillars) lock scale to 1.0 and jitter to 0 to keep sizes exact/consistent. - Building legacy aliases (
building_sm,building_md) duplicatebuilding_1x1andbuilding_2x1values respectively.
Dependencies
- Consumed by: terrain generation/spawn modules (callers index
TERRAIN_SHAPES[key]). - No imports.