We are about to switch to a new forum software. Until then we have removed the registration on this forum.
So i'm trying to create raindrops with ripples at the end and I have it so that when the drop hits a random area between 400 and 500 on the y axis it resets back to -10. I want to have it so the ripples originate from that spot so I need to be able to save that random number for the ellipses but I can't figure it out.
I know this is a very basic question but I haven't been able to find any solutions..
Also what would be the best way to have a load of the raindrops at random values of x, falling at different times? I know that's a very basic question too.. but I tried a few things and nothing was working haha
Thanks for any help. This is the code I've got so far
int i;
float y=0;
float x =100;
int j=0;
float speed = 0;
int k;
void setup() {
size(500, 500);
frameRate(25);
}
void draw() {
background(0);
moveRaindrop(0.7);
raindrop(100, 5);
}
void moveRaindrop (float gravity) {
background(0);
y = y +speed;
speed = speed + gravity;
float base = random(400, 500);
if (y > base ) {
noFill();
stroke(255);
ellipse(x, base, 200, 100);
y=-10;
speed = 0;
}
}
void raindrop (float x, int size) {
for (i=0; i<=5; i++) {
j = i*7;
fill(255-(j*7));
noStroke();
rectMode(CENTER);
rect(x, y-j, size, size);
//println(y);
}
}
Answers
https://Processing.org/tutorials/objects/
http://studio.SketchPad.cc/sp/pad/view/ro.9l84$2z--gWui/latest
https://www.Reddit.com/r/processing/comments/5psdct/question_beginner_how_to_save_a_random_number/
@siobhannx --
The best way is to:
Raindrop
classraindrop
objectsFor more on this approach (to particles, cars, enemy spaceships, raindrops, etc.) see the Objects and Classes tutorials, e.g.: