For a school assignment, I am trying to simulate snow by having a number of ellipses move down the screen. I tried it with just one at first and it worked but what I´m having a hard time figuring out is how to continuously have it fall over and over in random places.
I wanna keep it as simple as possible as I only have a few days to complete it. I tried using an if-sentence to determine the Y-axis and so forth but I can´t seem to get it working.
CODE:
int size = 3;
float xpos, ypos;
float xspeed = 1.0; // Speed of the shape
float yspeed = 1.0; // Speed of the shape
int xdirection = 0; // Left or Right
int ydirection = 1; // Top to Bottom
void setup()
{
size(640, 200);
noStroke();
frameRate(30);
smooth();
// Set the starting position of the shape
xpos = random(0,640);
ypos = 0;
}
void draw()
{
background(0);
// Update the position of the shape
xpos = xpos + ( xspeed * xdirection );
ypos = ypos + ( yspeed * ydirection );
snow();
}
void snow() {
// Draw the shape
ellipse(xpos+size/2, ypos+size/2, size, size);
println(ypos);
}
Any help is appreciated