Yes, tis true I'm having some problems with rain effects.. (Not because I lied when I was 17)
Basically when I'm moving left/right for a while and have gained velocity, the raindrops gather together at the edge of the screen (like in a string). So the rain is concentrated on the edge of the screen instead of the width of the window.
"raindrop" represents the active object for the rain (¬_¬) and "rainsource" is where the rain is created.
***Always
-raindrop speed = 20
-raindrop direction = 25
-rainsource Ypos = Y Top Frame + 1
-make rainsource invisible
***every 00"-16
-create raindrop at 0,0 from rainsource
***raindrop is out of the area
-destroy
__
I've tried changing this next bit to lots of different settings and random calculations involving the window's width etc.
__
***Speed of character is less than/equal to 150
-Set Xpos of rainsource to "Random(3000)"
__
3000 being the width of the entire area (yeah, not the window width, since I've tried that..) and 200 is the max velocity for the character. There's probably a simple way of doing this, but no method I've tried is yet to work.. So if you're out there Mr Knowledgeable Klik .. guy(s).. I'd much appreciate the help
Well, first of all, don't use timer events. Second of all, it'd probably look a bit more natural if you had it spread the rain randomly, instead of creating raindrops at fixed rainsources. You might also not want to have it rain over the whole playfield, that'd be a waste of objects.
But to solve your problem, simply place the rainsources at the top left corner of your playfield, only as many as you need to cover the visible window width, ie 640 or whatever resolution you're using. Then just modify the rainsources' and raindrops' properties, and un-tick "follow playfield". That way, the raindrops and rainsources will follow the screen while scrolling. Then, to destroy the raindrops, you can either test their position, or use the "is object getting close to window edge" condition.
If you want the raindrops to fall a bit more randomly, you can do something like this:
* [condition]
- Create raindrop at (0;0) from rainsource
- Raindrop: Set X position to X("Raindrop") + (Random(5)-2)
Or something like that.
Edit: Radix also wrote an article on this. I don't know how he does it, but it must be good.
I forgot to mention I'm using 1.5 :\ But I'll have a look for that, thanks for your help Axel
Yeah, I was about to search TDC for something on it ... before it went down again :| So I'm gunna have a look at Radix' article whilst I can too.. hehe.
I think the main thing I missed before was the "follow the frame" option :\ *hides in embarrassment*
I've implemented your:
" - Raindrop: Set X position to X("Raindrop") + (Random(5)-2) " too, which gives quite a nice effect
Only problem now, is that the rain follows with the movement of the character.. so if I'm walking right, the rain falls right. And having said that I've just figured out how I might do it! LOL.. I'll make the direction of the rain a variable perhaps? hehe, I'll try it anyways, thanks alot!
- Always
... Create Raindrop at (-16, -16)
... Raindrop: Set X Position to X Left Frame + Random(X Right Frame - X Left Frame)
... Raindrop: Set Y Position to Y Top Frame
- X Position of Raindrop < X Left Frame
... Raindrop: Set X Position to X Right Frame
- X Position of Raindrop > X Right Frame
... Raindrop: Set X Position to X Left Frame
If your frame scrolls vertically too:
- Y Position of Raindrop < Y Top Frame
... Raindrop: Set Y Position to Y Bottom Frame
- Y Position of Raindrop > Y Bottom Frame
... Raindrop: Set Y Position to Y Top Frame
Destroy the raindrops if they leave the frame area or hit something, and check the "Follow the frame" option if you do it this way. You could also try wind and sudden gushes of rain when the wind picks up.
Hmm, the only problem with that technique is that if the camera moves very fast somewhere, then all raindrops will be aligned at one side of the window. But you could probably fix it somehow, using some math and the modulus function etc etc, but I'm too lazy to figure that out for you
-Always
... Raindrop: Set X Position to X("Raindrop") + (((X Left Frame + X Right Frame) / 2 - X("Raindrop")) / ((X Right Frame - X Left Frame) / 2) * (X Right Frame - X Left Frame))