Skip to main content

Boundary System

The boundary defines the arena in which orbs interact.

Configuration Parameters

ParameterDescriptionEffect
shapeArena geometryCollision math and visuals
radiusCircle boundary radius in pixelsLarger = more open arena
restitutionEnergy multiplier on wall bounce>1.0 accelerates, <1.0 dampens
tangentImpulseSideways kick on wall collisionHigher = more chaotic bounces
minSpeedFloor velocity magnitudePrevents stalling
maxSpeedCeiling velocity magnitudeCaps maximum speed
twoOrbsMaxSpeedElevated speed cap for endgameFaster final confrontations
twoOrbsRampFramesTransition durationSmooths speed increase

Current Configuration

Shape:           Circle
Radius: 190px
Restitution: 1.02 (slightly accelerating)
Tangent Impulse: 0.01 (minimal sideways kick)
Min Speed: 2.0
Max Speed: 8.0 (normal), 20.0 (endgame)
Endgame Ramp: 400 frames (~3.3 seconds)
Direction: Random per bounce (CW/CCW)

Wall Collision Physics

When an orb hits the boundary:

1. Detect Collision

distance_from_center > radius - orb_radius

2. Calculate Response

normal = normalize(position - center)  // For circle
velocity_normal = dot(velocity, normal)
velocity_tangent = velocity - (velocity_normal * normal)

3. Apply Restitution

new_velocity_normal = -velocity_normal * restitution
new_velocity = new_velocity_normal * normal + velocity_tangent

4. Apply Tangent Impulse

tangent_direction = perpendicular(normal)
direction_sign = random_per_bounce() // +1 or -1, deterministic per orb
new_velocity += tangent_direction * tangentImpulse * direction_sign

The tangent direction is randomized per bounce (clockwise or counter-clockwise), creating varied orbital patterns while maintaining determinism through per-orb PRNGs.

Next Steps