⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 particlesystem.pde

📁 This is processing for java examples.
💻 PDE
字号:
// An ArrayList is used to manage the list of Particles class ParticleSystem {  ArrayList particles;    // An arraylist for all the particles  PVector origin;        // An origin point for where particles are birthed  ParticleSystem(int num, PVector v) {    particles = new ArrayList();              // Initialize the arraylist    origin = v.get();                        // Store the origin point    for (int i = 0; i < num; i++) {      // We have a 50% chance of adding each kind of particle      if (random(1) < 0.5) {        particles.add(new CrazyParticle(origin));       } else {        particles.add(new Particle(origin));       }    }  }  void run() {    // Cycle through the ArrayList backwards b/c we are deleting    for (int i = particles.size()-1; i >= 0; i--) {      Particle p = (Particle) particles.get(i);      p.run();      if (p.dead()) {        particles.remove(i);      }    }  }  void addParticle() {    particles.add(new Particle(origin));  }  void addParticle(Particle p) {    particles.add(p);  }  // A method to test if the particle system still has particles  boolean dead() {    if (particles.isEmpty()) {      return true;    }     else {      return false;    }  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -