Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Rainfall  (Read 4395 times)

0 Members and 1 Guest are viewing this topic.

aBallofWin

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
Rainfall
« 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.

Walker

  • Full Member
  • ***
  • Posts: 181
    • View Profile
Rainfall
« Reply #1 on: January 05, 2012, 01:14:47 am »
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.

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Rainfall
« Reply #2 on: January 05, 2012, 01:32:52 am »
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).

aBallofWin

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
Rainfall
« Reply #3 on: January 05, 2012, 01:44:01 am »
Cheers for the replies :) Ill post back tomorrow with what i've got, gunna look at particle emitters tonight

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Rainfall
« Reply #4 on: January 06, 2012, 12:19:20 pm »
If you search for something existing, you might have a look at Thor's particle systems. An alternative is SPARK.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

aBallofWin

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
Rainfall
« Reply #5 on: January 07, 2012, 03:40:57 pm »
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

aBallofWin

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
Rainfall
« Reply #6 on: January 09, 2012, 03:24:50 pm »
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