# rmp::behavior::Ball

> Bounces, keeps its pace, and leaves a paddle at an angle that depends on where it hit.

Source: https://omardev29.github.io/rmp-docs/reference/behaviors/Ball.html

behavior `#include <rmp/behavior.h>` [include/rmp/behavior.h:242](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/behavior.h#L242-L250)

struct Ball

Bounces, keeps its pace, and leaves a paddle at an angle that depends on where it hit. STARTS STILL — see the note at the top of this file.

```cpp
ball.add<rmp::behavior::Ball>({ .speed = 320 });
ball.apply_force({ 1, 0.35f });   // the serve, and it is the game's
```

_update normalises the velocity to `speed` ONLY when it is not zero, and the two properties that fall out of that are what make the serve one line: only the DIRECTION of the push counts, so nobody has to think about magnitudes, and `velocity = {}` is a stable state, so stopping the ball between points is one assignment rather than removing the behavior.

Added to an object with `add<rmp::behavior::Ball>()`; the framework calls its `_ready`, `_collision`, `_update` with the object it is on.

## Fields

| Field | Type | Default | What it is |
|---|---|---|---|
| `speed` | `float` | `300` | The pace it KEEPS, not the one it leaves at |
| `max_bounce_deg` | `float` | `60` | How far a hit near the end of a paddle tilts it |
| `speed_up` | `float` | `1.02f` | Per bounce off a solid. 1 = constant |
