falling/raining objects

I’m trying to make objects fall from the top of the screen as if they were raining down and then have them stop at a certain point on the screen. Does anyone know how to do this? Thanks!

you simply want an object to fall don the screen, or you want to imitate rain, particles are good fro rain, but that may be overcomplicating your problem.

This is not complete code but maybe will give you an idea.

first give your objects, variable to store a position.

something like this:

GLfloat objects[10][3]; 10 is number of objects, 3 is your xyz storage.

example view, top left (-8, 8), bottom right (8,-8)

glOrtho(-8.0, 8.0, -8.0, 8.0, 1.0, 60.0);

use a random number to pick at top X starting point for the drop.

object[0][0] = "X starting point random between -8 to 8.
object[0][1] = "Y starting point 8, top of screen.
object[0][2] = "Z starting point, zero is fine for 2D.

Then just subtract from the ‘Y’ in a loop redrawing the screen after each subtraction.

When Y is less then -8, reset the object variable again to top of screen.

Let me know if you do not understand…

Originally posted by aj3732:
I’m trying to make objects fall from the top of the screen as if they were raining down and then have them stop at a certain point on the screen. Does anyone know how to do this? Thanks!