模拟粒子系统,粒子的组成,粒子系统的组成,粒子系统的多样性;
粒子的设计:
class Particle{
PVector location; //粒子的位置
PVector velocity; //粒子的速度
PVector acceleration; //粒子的加速度
float mass; //粒子的质量
float lifespan; //粒子的生命周期
float R = random(255); //粒子的颜色
float G = random(255);
float B = random(255);
//粒子的初始化方式,给定位置的初始化,和随机位置的初始化
Particle(){
location = new PVector(random(width), random(height));
velocity = new PVector(random(-1, 1), random(-2, 0));
acceleration = new PVector(0, 0);
mass = 1;
lifespan = 255;
}
Particle(PVector l){
location = l.get();
acceleration = new PVector(0, 0);
velocity = new PVector(random(-1, 1),random(-2, 0));