Been only using Processing for five weeks and I need help with falling snowflakes!
in
Programming Questions
•
8 months ago
Hey everyone, I'm new to this forum and to Processing and would like some help with a falling snowflake project that is due on Monday. What I have already is falling snowflakes that change color and change shape as they fall (someone mentioned to me that it looks like glitter.) And wherever the mouse moves, there is also an umbrella that moves with it.
I would like to have the snow accumulate on top of the umbrella and stay there as the umbrella moves to collect more snow. I'm taking a mandatory Computer Science class that uses Processing and have been only at it for five weeks.
Here's my code so far (
note that the images will not show up on your processing. I've attached a screenshot.)
float[] xValues = new float[500];
float[] yValues = new float[500];
PImage img;
PImage img2;
void setup()
{
noStroke();
img2 = loadImage ("wintersky.jpg");
img = loadImage("umbrella.png");
size(700,500);
for(int i=0;i < xValues.length;i++)
{
xValues[i] = random(0,width);
yValues[i] = random(0,height);
}
}
void draw()
{
image(img2,0,0,700,500);
for(int i=0;i < xValues.length;i++)
{
fill (random(0,255),random(0,255),random(0,255));
ellipse(xValues[i],yValues[i], random(1,10), random(1,10));
yValues[i] = yValues[i] + 2;
xValues[i] = xValues[i] + random(-2.5,2.5);
if(yValues[i] > height + 5)
{
yValues[i] = -5;
xValues[i] = random(0,width);
}
image(img, mouseX, mouseY);
}
}
Thanks, any help is appreciated!
1