Class: BHell_Mover_Spline

BHell.BHell_Mover_Spline()

new BHell_Mover_Spline()

Uniform Catmull-Rom spline movement class. Given four points, determines a smooth path which passes between the two innermost ones.

Source:

Extends

Methods

initialize(p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y)

Sets up the four control points. Since the spline is uniform, no further parameters are needed.

If P0 == P1 and P2 == P3, the trajectory is a straight line between P1 and P2, otherwise a curved path (passing between P1 and P2) is determined by the relative position of P0 from P1 and P3 from P2 (e.g. if P0 is above-right of P1 and P3 is below-left of P2, the overall trajectory will be an "S").

Parameters:
Name Type Description
p0x

X coordinate of the first point.

p0y

Y coordinate of the first point.

p1x

X coordinate of the second point. The movement starts from here.

p1y

Y coordinate of the second point. The movement starts from here.

p2x

X coordinate of the third point. The movement ends here.

p2y

Y coordinate of the third point. The movement ends here.

p3x

X coordinate of the last point.

p3y

Y coordinate of the last point.

Overrides:
Source:

move(oldX, oldY, speed) → {Array}

Moves along the initialised spline, unless P2 is already reached.

Parameters:
Name Type Description
oldX

Old x coordinate.

oldY

Old y coordinate.

speed

Movement speed (in thousandths of distance between P1 and P2 per frame).

Overrides:
Source:
Returns:
Type
Array