Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simulating rain

I am making a game in java and I want to create a simulation of a cloud that is pouring rain. The cloud is supposed to move to the right while raining. Moving the cloud is no problem. It's the rain that I am struggling with.

What I was thinking of doing was with a timer to draw a rectangle, thats supposed to look like falling rain at a random x value inside of the cloud. And then add 1 to the y value of the drop each 100 millisecond. But I don't want to create 100 different rectangles, x variables and y variables for each rain drop.

Any idea how I can accomplish this? Suggestions appreciated!


It is a 2d game.. Sorry.

like image 715
Thobias Nordgaard Avatar asked Jul 02 '12 14:07

Thobias Nordgaard


People also ask

Can you simulate rain?

A rainfall simulator is used in soil science and hydrology to study how soil reacts to rainfall. Natural rainfall is difficult to use in experimentation because its timing and intensity cannot be reliably reproduced. Using simulated rainfall significantly speeds the study of erosion, surface runoff and leaching.

How do you simulate rainfall in the laboratory?

Pressure nozzles are used to spray water corresponding to rainfall intensities ranging from 45 to 105 mm h−1. The simulator produces rainfall with uniformity coefficient changing between 82 and 89%. The raindrops falling with an initial velocity from a height of 2.43 m have median diameters of 2.2–3.1 mm.

What is rainfall stimulation?

Any form of weather modification, usually involving cloud seeding, where the objective is to induce the formation of precipitation or to enhance the amount. Copyright 2022 American Meteorological Society (AMS).

How does rainfall simulator work?

Rainfall simulators (RS) are device designed to model the characteristics of natural rainfall to the nearest possible. It can be used to determine inter-rill erosion rates and their dependent rainfall and soil parameters [1].


2 Answers

One approach would be to consider a marquee on a theater. You take a series of bulbs and, by lighting and extinguishing them in sequence, you can simulate linear motion.

In the same way, rather than creating raindrops and animating their movement, why not creating multiple raindrops that are invisible and show and hide them in sequence to simulate downward motion. Then, you would have a series of arrays representing a raindrop track and you simply need to cycle through then, hiding the current one, incrementing the array pointer and displaying that one.

like image 55
Dancrumb Avatar answered Sep 17 '22 11:09

Dancrumb


Is it a requirement that the rain drops be programmed? Traditionally, this would be done with a few rain sprites that you place under the cloud and animate so that it looks like the rain is falling.

like image 32
dcow Avatar answered Sep 18 '22 11:09

dcow