procesingで円をランダムに二つ画面に置いて、その二つともクリックして消した場合、boolean型変数をfalseにする方法を教えてください。
円が1個ならできますか?
であれば論理和をとるだけです。
boolean showCircles = showCircle1 || showCircle2;
[|| (logical OR) / Reference / Processing.org](https://processing.org/reference/logicalOR.html)
class Ball {
int size=50;
float x=int(random(size/2, width-size/2));
float y=int(random(size/2, height-size/2));
float a=int(random(size/2, width-size/2));
float b=int(random(size/2, height-size/2));
boolean isClicked;
void display() {
if (!isClicked) {
ellipse(x, y, size, size);
}
}
void move() {
x = lerp(x, width / 2, 0.01);
y = lerp(y, height / 2, 0.01);
}
void Goal() {
if (isClicked) {
fill(0);
textAlign(CENTER);
textSize(40);
text("goal", 400, 400, 200, 200);
}
}
void judgeClicked() {
if (dist(x, y, mouseX, mouseY)<=size/2&&mousePressed) {
isClicked=true;
}
}
}
Ball[] b;
void setup() {
size(800, 800);
int N=2;
b=new Ball[N];
for (int i=0; i<N; i++) {
b[i]= new Ball();
}
}
void draw() {
background(255);
int i=2;
for (i=0; i<2; i++) {
b[i].move();
b[i].display();
b[i].judgeClicked();
b[i].Goal();
}
}
この場合に二つのボールの判定がわかりません。
この欄はインデントされず見にくいので、質問を編集しコードブロックを使って提示していただきますようお願いします。
[teratail【テラテイル】|ITエンジニア特化型Q&Aサイト](https://teratail.com/help/question-tips#questionTips37)