On this page
  1. Fields

rmp::behavior::Ball

behavior #include <rmp/behavior.h> include/rmp/behavior.h:242
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.

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

FieldTypeDefaultWhat it is
speedfloat300

The pace it KEEPS, not the one it leaves at

max_bounce_degfloat60

How far a hit near the end of a paddle tilts it

speed_upfloat1.02f

Per bounce off a solid. 1 = constant