I’m stuck on something and I’m sure the answer is a simple one but I can’t seem to find the issue. Using the p5js Array of Objects, I’m essentially trying to exactly that, with squiggly objects instead of ellipses. However, whenever I think I’m putting the shape’s function where I think it should go, it only renders one shape, squiggling at width/2, height/2 (center of screen). I did comment out that line but it just rendered in the corner.
I know the variable names are a little off and there are still artifacts of the p5js solution but I was wondering if someone could point me in the right direction. Thank you!
All the objects have the same x and y values each frame so they are all drawn in exactly the same place…
At this line this.y = sin(i - 90) * 120;, all the y values assigned are exactly the same for the same point on any of the carrots and at this line this.x = cos(i - 90) * 80 * noise((frameCount * 100 + i) * 0.008), the frameCount doesn’t change between the drawing of each carrot so they get the same x values too.
You can fix this by having a unique noise seed/offset for each of the Jitters in the bugs array.
e.g. this.noiseOffset = random(10000); and this.x = cos(i - 90) * 80 * noise((frameCount * 100 + i) * 0.008, this.noiseOffset).
Also you are missing quite a few semi-colons!
And make sure you’re code is properly indented (press shift + tab in the p5 web editor).
The carrots look pretty cool BTW!
Edit: Oh yeah (as @GoToLoop said), I forgot to mention you need to change translate(width/2, height/2) to translate(this.x, this.y) and use some other variables in the lines I first mentioned as otherwise you are overwriting the position of the carrot (see GoToLoop’s reply for a better answer to this part).