# gizgame/ball

Universal sports ball physics, parabolic shot solver, and goal-volume scoring.

```gizlang
import * as Ball from "gizgame/ball";
```

## Types

### `Ball`

```gizlang
type Ball = { pos: Point3; vel: Point3; rot: f64; radius: f64; bounced: bool; }
```

Physical state of a sports ball.

- `pos`: `gizlang_geometry.Point3`
- `vel`: `gizlang_geometry.Point3`
- `rot`: `f64`
- `radius`: `f64`
- `bounced`: `bool`

### `BallConfig`

```gizlang
type BallConfig = { gravity: f64; bounce: f64; drag: f64; floorY: f64; maxX: f64; maxZ: f64; wallBounce: f64; }
```

Arena physics parameters for a ball.

- `gravity`: `f64`
- `bounce`: `f64`
- `drag`: `f64`
- `floorY`: `f64`
- `maxX`: `f64`
- `maxZ`: `f64`
- `wallBounce`: `f64`

### `GoalBox`

```gizlang
type GoalBox = { name: string; minX: f64; maxX: f64; minY: f64; maxY: f64; minZ: f64; maxZ: f64; }
```

Axis-aligned goal or hoop scoring volume.

- `name`: `string`
- `minX`: `f64`
- `maxX`: `f64`
- `minY`: `f64`
- `maxY`: `f64`
- `minZ`: `f64`
- `maxZ`: `f64`

## Functions

### `makeBall`

```gizlang
function makeBall(pos: Point3, radius: f64 = 0.35): Ball
```

A ball of RADIUS at rest at POS.

### `stepBall`

```gizlang
function stepBall(b: Ball, cfg: BallConfig, dt: f64): Ball
```

Steps a ball under gravity, ground restitution, linear drag, and field bounds.

Effects: fail.

### `kickBall`

```gizlang
function kickBall(b: Ball, dirX: f64, dirZ: f64, power: f64, lift: f64): Ball
```

Applies a directional impulse kick or strike to a ball.

### `shootArc`

```gizlang
function shootArc(origin: Point3, target: Point3, gravity: f64, flightSeconds: f64): Point3
```

Solves an initial velocity that arcs a ball from origin to target with a given flight time.

### `inGoal`

```gizlang
function inGoal(b: Ball, g: GoalBox): bool
```

Checks whether the ball center lies inside a goal volume.

### `checkGoals`

```gizlang
function checkGoals(b: Ball, goals: Vec<GoalBox>): string
```

Returns the name of the first goal volume the ball entered, or empty string if none.

Effects: fail.

