update method
void
update(
- Size bounds
)
Implementation
void update(Size bounds) {
// Update the position by adding the velocity.
position += velocity;
// If the particle was accelerated, gradually reduce its velocity to the default.
if (wasAccelerated) {
velocity = computeVelocity(velocity, defaultVelocity, 0.01);
// If velocity has returned to default, reset the accelerated flag.
if (velocity == defaultVelocity) {
wasAccelerated = false;
}
}
// Handle collisions with the screen boundaries.
handleScreenBoundaries(bounds);
// Update the visibility status of the particle.
updateVisibility(bounds);
}