Impulses

class Impulses(capacity: Int = 64)

The last hits, each with a place, for rings, shocks and eddies that spread from where a hit landed. The newest is index 0. Ages count heard seconds, so a pause holds every ring where it is.

Positions are in the drawings' centred units: 0,0 is the middle and one unit is half the screen height, so x runs to about plus or minus the aspect ratio. A shader reads the same list as a 64 by 2 picture through impulseA and impulseB in the shared header.

Constructors

Link copied to clipboard
constructor(capacity: Int = 64)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
var count: Int

How many hits the list holds now.

Functions

Link copied to clipboard
fun add(kind: Int, strength: Float, x: Float, y: Float, seed: Float)

Adds a hit of kind (LOW, BODY or HIGH) at x, y as the newest, dropping the oldest when full.

Link copied to clipboard
fun advance(heardSeconds: Float)

Ages every impulse by heardSeconds and drops those older than MOST_AGE.

Link copied to clipboard
fun ageOf(i: Int): Float

Heard seconds since hit i landed.

Link copied to clipboard
fun bindTo(program: ShaderProgram)

Writes the picture and hands it to program under the header's names.

Link copied to clipboard
fun kindOf(i: Int): Int

The kind of hit i: LOW, BODY or HIGH.

Link copied to clipboard
fun reset()

Empties the list.

Link copied to clipboard
fun seedOf(i: Int): Float

The random number 0 to 1 that came with hit i.

Link copied to clipboard

How hard hit i was, 0 to 1.

Link copied to clipboard
fun xOf(i: Int): Float

Where hit i landed across, in centred units.

Link copied to clipboard
fun yOf(i: Int): Float

Where hit i landed up, in centred units.