Processing 数组仅显示1个对象,而不是全部变量
我对编码是新手(我相信你可能会知道)。程序运行并生成1个Tubble,但其他对象不显示 这是我的班级:Processing 数组仅显示1个对象,而不是全部变量,processing,Processing,我对编码是新手(我相信你可能会知道)。程序运行并生成1个Tubble,但其他对象不显示 这是我的班级: class Tubble { float x; float y; float diameter; float yspeed; float tempD = random(2,86); Tubble() { x = random(width); y = height-60; diameter = tempD; yspeed = ran
class Tubble {
float x;
float y;
float diameter;
float yspeed;
float tempD = random(2,86);
Tubble() {
x = random(width);
y = height-60;
diameter = tempD;
yspeed = random(0.1, 3);
}
void ascend() {
y -= yspeed;
x = x + random(-2, 2);
}
void dis() {
stroke(0);
fill(127, 100);
ellipse(x, y, diameter, diameter);
}
void top() {
if (y < -diameter/2) {
y = height+diameter/2;
}
}
}
class-Tubble{
浮动x;
浮动y;
浮子直径;
浮动速度;
浮动温度=随机(2,86);
Tubble(){
x=随机(宽度);
y=高度-60;
直径=tempD;
Y速度=随机(0.1,3);
}
无效上升(){
y-=y速度;
x=x+随机(-2,2);
}
无效dis(){
冲程(0);
填充(127100);
椭圆(x,y,直径,直径);
}
空顶(){
如果(y<-直径/2){
y=高度+直径/2;
}
}
}
阶级
类粒子{
浮动x,y;
浮子r;
浮动速度=2.2;
int方向=1;
皮梅格气泡;
粒子(浮动x、浮动y、浮动r){
x=x;
y=y;
r=r;
}
无效显示(){
冲程(#F5D7D7);
冲程重量(2.2);
noFill();
椭圆(x,y,r*2,r*2);
}
布尔重叠(粒子其他){
float d=距离(x,y,other.x,other.y);
如果(d(宽度-r))| |(x(高度-r))| |(y
主要草图:
Tubble[] tubbles = new Tubble [126];
PImage bubbles;
Particle p1;
Particle p2;
Particle p3;
Particle p4;
Particle p5;
float x,y;
float speed;
int total = 0;
int i;
//int direction = 1;
void setup() {
size(800, 925);
bubbles = loadImage("purple_bubbles.png");
p1 = new Particle (100, 100, 50);
p2 = new Particle (500, 200, 100);
p3 = new Particle (600, 600, 82);
p4 = new Particle (height/2, width/2, 200);
p5 = new Particle ((height/3), (width/3), 20);
for (int i = 0; i < tubbles.length; i++); {
tubbles[i] = new Tubble();
}
}
void mousePressed() {
total = total + 1;
}
void keyPressed() {
total = total - 1;
}
void draw() {
image(bubbles, 0, 0, 800, 925);
//background(0);
for (int i = 0; i < tubbles.length; i++); {
tubbles[i].ascend();
tubbles[i].dis();
tubbles[i].top();
}
if ((p2.overlaps(p1)) && (p2.overlaps(p4))) {
background(#BF55AB, 25);
}
if ((p3.overlaps(p2)) && (p3.overlaps(p4))) {
background(#506381, 80);
}
p2.x = mouseX;
p3.y = mouseY;
p1.display();
p2.display();
p3.display();
p4.display();
p5.display();
p4.move();
p5.updown();
// for (int i = 0; i < tubbles.length; i++); {
// tubbles[i].dis();
// tubbles[i].ascend();
// tubbles[i].top();
// }
}
Tubble[]tubbles=新Tubble[126];
泡沫;
粒子p1;
颗粒p2;
颗粒p3;
颗粒p4;
颗粒p5;
浮动x,y;
浮动速度;
int-total=0;
int i;
//int方向=1;
无效设置(){
尺寸(800925);
气泡=加载图像(“紫色泡泡.png”);
p1=新粒子(100,100,50);
p2=新粒子(500200100);
p3=新粒子(600,600,82);
p4=新粒子(高度/2,宽度/2200);
p5=新粒子((高度/3),(宽度/3),20);
for(int i=0;i
行中有多余的分号
for (int i = 0; i < tubbles.length; i++); {
for (int i = 0; i < tubbles.length; i++); {
// for (int i = 0; i < tubbles.length; i++); {
行中有额外的分号
for (int i = 0; i < tubbles.length; i++); {
for (int i = 0; i < tubbles.length; i++); {
// for (int i = 0; i < tubbles.length; i++); {
for (int i = 0; i < tubbles.length; i++) {
for (int i = 0; i < tubbles.length; i++) {
// for (int i = 0; i < tubbles.length; i++) {