new KineticMass(position, velocity, acceleration, mass, color)
Makes a little ball that can move and adheres to proper kinematics.
Parameters:
Name |
Type |
Description |
position |
p5.Vector
|
A vector object describing the balls acceleration. |
velocity |
p5.Vector
|
A vector object describing the ball's velocity. |
acceleration |
p5.Vector
|
A vector object describing the ball's acceleration. |
mass |
number
|
A scalar quantity indicating the mass. |
color |
color
|
The color of the ball. |
Properties:
Name |
Type |
Description |
limit |
number
|
This sets the limit for the maximum speed. (default: 10000) |
tail |
bool
|
Displays a tail of little dots that trail behind the KineticMass as it moves. |
outline |
color
|
The color of the KineticMass object. |
tailLength |
number
|
The number of tailbits following the KineticMass object. (note: 70 is a good number) |
tailFill |
color
|
The tail color. |
tailStroke |
color
|
Thickness of the tail stroke. |
tailSpacing |
number
|
How many frames to skip before leaving a tailbit. |
- Source:
Examples
function setup() {
//make a position vector
pos = createVector(width/2,height/2)
// make a velocity vector (5 px/fr in x, 2 px/fr in y)
vel = createVector(5,2);
// no acceleration
accel = createVector(0,0);
// create the ball. Give it a mass of 10, and let's make it red.
ball = new KineticMass(pos,vel,accl,10,'red');
}
function draw(){
// update the ball's parameters
ball.update();
//display changes
ball.display();
}
function setup() {
//make a position vector
pos = createVector(width/2,height/2)
// make a velocity vector (5 px/fr in x, 2 px/fr in y)
vel = createVector(5,2);
// no acceleration
accel = createVector(0,0);
// create the ball. Give it a mass of 10, and let's make it red.
ball = new KineticMass(pos,vel,accl,10,'red');
}
function draw(){
// update the ball's parameters
ball.update();
//display changes
ball.display();
}