Attach a flower to the stem - follow mouse movement
in
Programming Questions
•
2 years ago
Hi everyone, i was wondering if anyone can help me....i developed this code where i intend to have a plant following my mouse movement but i only succeeded if the plant is separated from the stem.....is there anyway to attach them? Thank you so much
- void setup() {
- size(600, 600);
- smooth();
- strokeWeight(55);
- stroke(10,130,20, 200);
- x[x.length-1] = width-200;
- y[x.length-1] = height-200;
- }
- void draw() {
- background(226);
- reachSegment(0, c, d);
- for(int i=1; i<numSegments; i++) {
- reachSegment(i, targetX, targetY);
- }
- for(int i=x.length-1; i>=1; i--) {
- positionSegment(i, i-1);
- }
- for(int i=0; i<x.length; i++) {
- segment(x[i], y[i], angle[i], (i+1)*2);
- }
- float dx = mouseX - c;
- if(abs(dx) > 1) {
- c += dx * easing;
- }
- float dy = mouseY - d;
- if(abs(dy) > 1) {
- d += dy * easing;
- if(d >270){
- d = 270;
- }
- }
- if (mode == 0)
- {
- Flower();
- }
- else if (mode ==1)
- {
- Fly();
- }
- }
1