Array confuses translate?
in
Programming Questions
•
2 years ago
OK my final aim is to create a panel where 20 of this blobs bounce.
My problem at the moment is uhm...
not so easy to explain and I already messed a bit around while trying to fix it...
What I think it should do at the moment is creating 20 blobs on the same space(pretty dumb but its for test reasons)
that move with the mouse (X-axis only).
My Problems is now, that they are all created on a different point.
I think the problem is, that the "new blob(...)" values are added to a new blob
instead of "taking them as they are".
But I have found no solution for this so far,
does somebody know how to fix this?
My problem at the moment is uhm...
not so easy to explain and I already messed a bit around while trying to fix it...
What I think it should do at the moment is creating 20 blobs on the same space(pretty dumb but its for test reasons)
that move with the mouse (X-axis only).
My Problems is now, that they are all created on a different point.
I think the problem is, that the "new blob(...)" values are added to a new blob
instead of "taking them as they are".
But I have found no solution for this so far,
does somebody know how to fix this?
- int ebinner=0;
color colour=color(255,255,0);
blob[] BLOB=new blob[20];
void setup() {
size(500,500);
background(255);
smooth();
for(int h=0;h<20;h++)
{
BLOB[h]=new blob(100, 100, color(255,0,0), 45, 1);
//BLOB[h].drawBlob();
}
}
void draw(){
for(int i=0;i<20;i++)
{
BLOB[i].drawBlob();
BLOB[i].blobx=mouseX;
}
}
class blob
{
int blobx;
int bloby;
color col;
int rot;
float big;
blob(int x, int y, color c, int r, float s)
{
background(255);
blobx=x;
bloby=y;
col=c;
rot=r;
big=s;
}
void drawBlob()
{
translate(blobx,bloby);
rotate(radians(rot));
scale(big);
fill (col);
ellipse(0,0,50,50);
fill(255);
ellipse(-10,-5,10,10);
fill(255);
ellipse(10,-5,10,10);
fill(0);
ellipse(-12+mouseX/40,-7+mouseY/40,5,5);
fill(0);
ellipse(8+mouseX/40,-7+mouseY/40,5,5);
}
}
1
