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

📄 crazyparticle.pde

📁 This is processing for java examples.
💻 PDE
字号:
// A subclass of Particleclass CrazyParticle extends Particle {  // Just adding one new variable to a CrazyParticle  // It inherits all other fields from "Particle", and we don't have to retype them!  float theta;  // The CrazyParticle constructor can call the parent class (super class) constructor  CrazyParticle(PVector l) {    // "super" means do everything from the constructor in Particle    super(l);    // One more line of code to deal with the new variable, theta    theta = 0.0;  }  // Notice we don't have the method run() here; it is inherited from Particle  // This update() method overrides the parent class update() method  void update() {    super.update();    // Increment rotation based on horizontal velocity    float theta_vel = (vel.x * vel.mag()) / 10.0f;    theta += theta_vel;  }  // Override timer  void timer() {    timer -= 0.5;  }    // Method to display  void render() {    // Render the ellipse just like in a regular particle    super.render();    // Then add a rotating line    pushMatrix();    translate(loc.x,loc.y);    rotate(theta);    stroke(255,timer);    line(0,0,25,0);    popMatrix();  }}

⌨️ 快捷键说明

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