1 min
As always, the best way to create a system is to plan out the desired uses of said system. Firstly I must disclaim that the model I based it after is Unity’s particle system. However, the implimentation was desired to cover the following:
The defininig parts of a particle are it’s components, and having multiple components that can be attached to a particle allows for interesting manipulation. The primary method I used to have a value move towards another over lifetime was through a lerp.
void OpacityOverTime::update(float delta_time)
{
lifetime -= delta_time;
sprite->opacity(end_opacity * (max_lifetime - lifetime) +
start_opacity * lifetime);
}
This way opacity will move towards end_opacity over the sprite’s lifetime! However this is very limited in how it models change over time. In the future I might make a model for exponential decay, however for now I want to focus on adding more components.
Subscribe to this blog via RSS.
Blog 17
Snake 4
Birdman 2
Blog (17) Low-level programming (17) Snake (4) Endless runner (2) Birdman (2) Chess-com (6)