【问题标题】:Randomly moving circles in processing加工中的随机移动圆圈
【发布时间】:2014-11-23 06:30:00
【问题描述】:

我已经想出了如何让一个圆圈随机移动,但现在我想要有 100 个圆圈,但不知道如何添加它们,帮助!

float my_num = 10;
float n = random(5, 60); 
void setup() {
  size(500, 500);
  background(0);
  fill(255);
  noStroke();
  smooth();
  rectMode(CENTER);
}
void draw() {
  background(0);

  translate(width * noise(my_num + 80), height * noise(my_num + 100));

  rotate(10 * noise(my_num + 40));

  ellipse(n, n, n, n);

  my_num = my_num + 0.02;
}

【问题讨论】:

    标签: functional-programming processing


    【解决方案1】:

    听起来您应该创建一个包含圆的位置、大小、颜色等的 Circle 类。

    然后创建一个包含 100 个圆的 ArrayList 或数组,并在您想要更新或绘制这些圆时循环遍历它们。

    推荐阅读:http://staticvoidgames.com/tutorials/objects/fireworks

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-25
      • 1970-01-01
      相关资源
      最近更新 更多