NAME

Physics::Balls::Strike - one shot, as the integers a client sends

VERSION

Version 0.01

SYNOPSIS

my $strike = Physics::Balls::Strike->new(ball => 0, dx => 707107, dy => -707107, power => 640, sx => 0, sy => 300);
my $out = $strike->play($world, \@layout);

DESCRIPTION

The direction is dx, dy in plus or minus 1,000,000 (normalised inside the engine with one square root), power 0 to 1000 (the speed is 0.3 + (power/1000)^2 (vmax - 0.3) so low power is fine-grained), and the tip offset sx, sy in thousandths of the radius, clamped to half a radius. Integers, so that a client cannot send a float two encoders would spell differently. validate refuses anything else with a Physics::Balls::Error rather than dying.

ATTRIBUTES

ball

The id struck, default 0.

dx

dy

power

sx

sy

trace

When true the outcome carries the energy after every event.

METHODS

validate

my $err = $strike->validate($world, \@layout);

Undef when the shot and the layout are acceptable, else the error. Two balls may sit touching, and a tenth of a millimetre inside each other, because a tight rack rounded to hundredths does that and the engine treats it as contact; any closer is overlap.

rows

The layout as plain rows, whatever it was given as.

play

my $out = $strike->play($world, \@layout);

A Physics::Balls::Outcome, or the Physics::Balls::Error that refused it.