Rotating Circles Around Centre - URGENT HELP!
in
Programming Questions
•
1 year ago
Hi I'm in desperate need of help!
I have an arraylist of 15 objects, let's say flowers, that each have a specified position on the screen. These flowers each have a core that also has 10 other objects, petals, each that rotate around them 360 degrees, are connected to the centre flower by a line and each petal contains its id number.
I need major help in 1) getting the line to attach to the petal, 2) making more than one petal for each flower and 3) displaying the id number in each of the 15 flowers.
What I mean is that each flower should have a petal that says 1, 2, 3, 4, 5 etc. up to 10.
This is the current code I have, it only shows one petal as I am clueless as to how I make more. Also the petal isn't attached to the line.
I've modified code from OpenProcessing as well as trying to use my own knowledge.
- int num = 10;
- float[] x = new float[num];
- float[] s = new float[num];
- float[] rote = new float[num];
- float[] speed = new float[num];
- color[] c = new color[num];
- void setup(){
- size(500, 500);
- smooth();
- for(int i = 0; i < num; i++) {
- x[i] = 80;
- s[i] = 30;
- rote[i] = (radians(360));
- speed[i] = 4;
- c[i] = color(random(255), random(255), random(255));
- }
- }
- void draw() {
- background(17);
- for(int i = 0; i < num; i++) {
- pushMatrix();
- translate(250,250);
- rotate(rote[i]);
- rote[i] = rote[i] + radians(speed[i]);
- //noStroke();
- fill(c[i]);
- stroke(255);
- line(x[i], x[i],0,0);
- ellipse(x[i], 0, s[i], s[i]);
- popMatrix();
- }
- for(int i = 0; i < 360; i+= 36){
- pushMatrix();
- rotate(radians(i));
- translate(250, 250);
- ellipse(0,0, 30, 30);
- popMatrix();
- }
- }
I'm very desperate, so could you guide me along the way please. I need this as soon as possible.
Oh, can you tell me what I am doing wrong
Thanks
1