How to create rainy clouds with lighting on background?

Started by Massad, Tue 11/06/2013 06:19:13

Previous topic - Next topic

Massad

I have a problem with animation on the background. I need more than 5 images to animate my idea. I want create rain, wind and lighting in clouds at one room, but i need some delay between lightings flashes for more realistic fx and between movement of trees to simulate wind. I can do any of this but separately.
Thank you!

Snarky

Welcome, Massad.

Instead of using the animated background option, make the things you want to animate (rain, clouds, lightning flashes, trees) into separate graphic sprites.

Draw a version of the background without any of these moving things, and make that the room background. (If you want the whole background to light up when there's a lightning flash, draw two version, a regular and a bright one.) Assign the graphic sprites you made for the animated elements to room objects. Now you can animate the clouds and trees and rain separately. (Read in the manual about sprites, views and objects.)

In order to do the lightning, you will need to do a little bit of scripting to change the background to the bright version for a split second (and also change the graphics for the room objects and anything else that needs to be lit, and to draw a lightning flash if you want). Then change everything back right afterwards.

You probably want the lightning to occur randomly, maybe with a minimum and maximum interval. The easiest way to do this is to use a timer that you set to some random value between min and max, and when the timer is done, do the lightning and start the timer over.

Finally, you probably don't need to do the rain animation yourself. There are modules that will do it for you (for example, one of these: 1, 2), and that's much easier.

If this all sounds difficult, I recommend first getting the animation to work without lightning, but without using multiple background frames. Please ask if you have further questions.

Massad

Thank you! Its sounds difficult, but i`m gonna try anyway.

PS
I thunk what multiple background images could give better quality of animation fx (because bitmap).
Maybe i can change the number of uploading images for backround animation in programm code?

Thank you again!

Khris

No, the limit is 5. You would have to change AGS's source code to change that limit.

You can have more than 5 background frames by drawing them to the background manually though. Import them as sprites (in sequence!), and use this code in the room script:
Code: ags
int bg_frame, bg_timer;

function repeatedly_execute_always() {

  int frames = 10;            // CHANGE THESE TO APPROPRIATE VALUES
  int delay = 5;
  int first_frame_slot = 25;

  bg_timer++;
  if (bg_timer == delay) {
    bg_frame++;
    if (bg_frame == frames) bg_frame = 0;
    bg_timer = 0;
  }
  DrawingSurface *ds = Room.GetDrawingSurfaceForBackground();
  ds.DrawImage(0, 0, bg_frame + first_frame_slot);
  ds.Release();
}

Snarky

Well don't encourage him, Khris! You know that's almost certainly not the best approach.  (wrong)

Quote from: Massad on Tue 11/06/2013 09:20:42
I thunk what multiple background images could give better quality of animation fx (because bitmap).

You're wrong. Sprites are bitmaps too, and you can use exactly the same graphics so it looks exactly the same. But with the animated elements as objects, you have a lot more flexibility and can achieve more advanced effects. It also uses much less storage and memory.

In this case, the most obvious thing has to do with the lightning flashes. Using your method, the lightning will happen at completely regular intervals, like the tick of a clock. That will seem unrealistic very quickly.

Eric

If I'm reading all of this correctly, I want to also point out the mistake I made when making a rainy room and setting the rain as part of the background animation. Your characters will be drawn over the rain, it will look silly, and you'll feel foolish. Let my foolishness inspire you to not do the same thing!


Lewis

I would probably consider doing it with GUIs, too, if these weather effects are going to be fairly consistent across a few rooms.

Create two slightly different 'rainy' animation that are the same size as the room. Create two GUIs, with buttons. Position one behind the characters, and one in front, then animate both buttons.

Though that's probably more difficult than using one of the many excellent weather plugins. :-)
Returning to AGS after a hiatus. Co-director of Richard & Alice and The Charnel House Trilogy.

Khris


Lewis

Quote from: Khris on Fri 14/06/2013 10:25:00
GUIs are always on top of everything else.

Can you not put them behind characters? I am going insane.
Returning to AGS after a hiatus. Co-director of Richard & Alice and The Charnel House Trilogy.

Slasher

No. GUI's are always written above everything else.

In one game I had fog, rain and lightning. It really boils down to how you want it to appear.

I used object animations for lightning, moving fog and usedthe snow/rain plugin. I needed to play around with object delay and timings to make it passable.

Good luck


Mehrdad

I wish snow/rain plugin work with D3D.It's really good plugin.Isn't any suggestion for improve it?
My official site: http://www.pershaland.com/

johanvepa

I'm toying with the idea for a pet project, so I'm eavesdropping a bit here   :)

Wouldn't the simplest solution for lightning effect be to position an all-white GUI, over the game screen, make it slightly transparent, then use a timer to make it visible and non-visible for a split second? Clouds could be made with objects, right? Rain perhaps with an almost entirely transparent animated black object? Fog could be made with the same all-white GUI and a dark region to hamper visibility.

Slasher, how did you use objects for lightning and moving fog?

SMF spam blocked by CleanTalk