We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
Splash! (Read 438 times)
Splash!
Mar 25th, 2010, 12:29pm
 
I'm relatively new to Processing, and I'm about to bite off more than is strictly advisable for me to chew on a school project in which I'm hoping to simulate boots splashing through a puddle. Right now I'm looking for water simulation code to tinker with. I've found a lot of great ripple simulations, but so far I haven't been able to find any actual splashes (water droplets flying up in some way). Has anyone seen any good splash simulations I might be able to play with? I plan to make my simulation extremely abstract, so realism is not a priority.
Re: Splash!
Reply #1 - Mar 25th, 2010, 12:48pm
 
here's a start:

float[] explX = new float[1000];
float[] explY = new float[1000];
float[] explXVel = new float[1000];
float[] explYVel = new float[1000];


void setup(){
size(400,400);
randomExplosionSet();
}
void draw(){
background(255);
explosionDraw();
}



void randomExplosionSet(){
     for (int i=0; i<=999; i++){
 explX[i] = random(-5,5);
 explY[i] = random(-5,0);
 explXVel[i] = random(-5,5);
 explYVel[i] = random(-5,0);
}
}
void explosionDraw(){
 for (int i=0; i<=999; i++){
 explYVel[i] += .1;
 explX[i] += explXVel[i];
 explY[i] += explYVel[i];
   noStroke();
 fill(100,100,255);
 ellipse(width/2+explX[i],height/2+explY[i],random(3),random(3));
 }
}


I took this from an explosion thing I made for a lunar lander game.

mess around with it and see if it can help you work out how to do what you want to do.

sorry if a side view isn't really what you wanted. It's also set up so that the effect makes a rectangle-sh shape. I'll let you mess with it to make it more realistic.

anyway hope this helps.
Page Index Toggle Pages: 1