SFML community forums
Help => Graphics => Topic started by: aBallofWin on January 05, 2012, 12:28:54 am
-
Hey, for my game's main menu, i've been trying to find out how i could simulate rainfall, either with little sprites or even just drawing lines. After a lot of searching and experimenting (newbie here) i couldn't come up with anything.
Here's how it would be wanted (http://www.youtube.com/watch?v=2EJxlkTJ1nE&feature=related)
I'd like to ask how I could implement this, and any source code would be greatly appreciated :)
jake.
-
I would do it as a very simple particle system (so look that up to find out how to do it efficiently). Create particles off-screen and give them their velocity.
You can draw them as a line from position to position - velocity or just a sprite oriented to match the velocity.
Interacting with objects can be as complex as you want, but will probably always use the same basic system.
-
Fastest solution would most likely be a simle animation using 2 or 3 (maybe 4) frames with the raindrops that is repeatable, so you're able to draw it using just a single quad.
If you'd like constant rain drops it might even be enough to just use one frame and move the whole texture each frame (just like a huge sprite).
It's a bit hard to decide, without actually knowing what you#ve got in mind (e.g. just raindrops passing by vs. raindrops dripping on some ground).
-
Cheers for the replies :) Ill post back tomorrow with what i've got, gunna look at particle emitters tonight
-
If you search for something existing, you might have a look at Thor's particle systems. An alternative is SPARK.
-
Couldn't really understand the particle system, and it wouldn't compile anyway :/ I would try doing a sprite and moving it, but I wouldn't know how to, looked at sparks, pretty complex, but going to take a look at Thor now
-
UPDATE: Finally set up rain, it's with AniSprite, so it's pretty basic but it works! If you have the same problem and need a step by step guide on how to do it, visit http://aballofwin.blogspot.com/2012/01/basic-but-working-rain-sfml.html