yesterday I tried to make a program that displays a cool ellipse with ellipses around it and I made it and everything worked fine,
I made a class named DotsArray and made the ellipse array an object, I even added a feature that lets you position the object according to the mouse and everything worked great, and its steal works but then I decided to make every ellipse an object so I can have more flexibility in the colors and alphas.
so I wrote the ellipse object in a separate sketch and it worked fine but then when I tried to add it to the main code and nothing worked.
The code is not broken and will run without the class but if I change one of the ellipses to the ellipse object they just won’t be displayed.
someone can please help me with the code? I’m new to coding (1 week since I started
doing things) and I have beginner knowledge but I’m a fast learner so don’t be afraid to use more advanced level code.
the code -
MAIN FOLDER -
DotsArray ar1 = new DotsArray(50,50,0,0);
void setup()
{
fill(random(0,255),random(0,255),random(0,255));
size(1000,800);
background(0);
strokeWeight(2.5 );
ellipseMode(RADIUS);
}
void draw()
{
ar1.display();
ar1.DAMove();
}
void mousePressed()
{
fill(random(0,255),random(0,255),random(0,255));
}
The Folder With The Object
class DotsArray
{
//The variables
float Xpos; //the Middle X
float Ypos; //the Middle Y
float Xsize;//the ellipse X size
float Ysize;//the ellipse Y size
float XposDelta; //delta from Xmouse position for multi objects array.
float YposDelta; //delta from Xmouse position for multi objects array.
//end of the variables
//start of the elipse construction
Ellipse ellipse0 = new Ellipse(Xpos,Ypos,Xsize,Ysize);
//end of the elipse construction
//start of the Variable setup
DotsArray (float IXsize, float IYsize, float IXposDelta, float IYposDelta)
{
Ysize = IYsize;
Xsize = IXsize;
XposDelta = IXposDelta;
YposDelta = IYposDelta;
//end of the Variable setup
}
//
/ THE ELLIPSE OBJECT /
//
class Ellipse
{
float XEpos,YEpos;
float XEsize,YEsize;
Ellipse (float IXEpos, float IYEpos,float IXEsize, float IYEsize)
{
XEpos = IXEpos; //The Chain - Dots Array XPos>ELlipse IXEpos>ellipse XPos>ellipse setup
YEpos = IYEpos; //The Chain - Dots Array YPos>ELlipse IYEpos>ellipse YPos>ellipse setup
XEsize = IXEsize; //The Chain - Dots Array Xsize>ELlipse IXEsize>Ellipse Xsize>ellipse setup
YEsize = IYEsize; //The Chain - Dots Array Ysize>ELlipse IYEsize>Ellipse YEsize>ellipse setup
}
void display() //draws the ellipse
{
ellipse(XEpos,YEpos,XEsize,YEsize);
}
}
//
/ END OF THE ELLIPSE OBJECT /
//
void display() {
ellipse(Xpos,Ypos,Xsize,Ysize); //middle
ellipse(Xpos - Xsize1.7,Ypos,Xsize/1.5,Ysize/1.5); //left
ellipse(Xpos + Xsize1.7,Ypos,Xsize/1.5,Ysize/1.5); //right
ellipse(Xpos ,Ypos - Ysize2 ,Xsize/1.5 ,Ysize/1.5); // high
ellipse(Xpos ,Ypos + Ysize2,Xsize/1.5 ,Ysize/1.5); // low
ellipse(Xpos - Xsize1.7,Ypos - Ysize1.7,Xsize/1.5,Ysize/1.5); // top left
ellipse(Xpos + Xsize1.7,Ypos - Ysize1.7 ,Xsize/1.5 ,Ysize/1.5); // top right
ellipse(Xpos + Xsize1.7 ,Ypos + Ysize1.7 ,Xsize/1.5 ,Ysize/1.5); // low right
ellipse(Xpos - Xsize1.7 ,Ypos + Ysize1.7,Xsize/1.5 ,Ysize/1.5); // low left
}
void DAMove()
{
Xpos = mouseX + XposDelta;
Ypos = mouseY + YposDelta;
}
}