Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Hobbes on Sat 23/04/2005 18:53:37

Title: Rain on the map screen (solved)
Post by: Hobbes on Sat 23/04/2005 18:53:37
Hey all,

I've been connecting a few rooms together in Buc2 which play at night in the countryside... and, it's raining.

This all looks rather good thanks to the awesome RainSnow plugin. However, on the mapscreen it's suddenly not raining anymore.

I'm looking for a way to make it rain there too. Now, I can use the animated background thingy and have 1x1 pixelated raindrops appear at random on several points of the map, since the rain will fall down flat like this:

(http://www.unosar.com/gk2/scrnshot4.gif)

Now it would be neat if I could randomize it a bit more than the animated background stuff. Plus, it would take up a whole lot of unneeded space just to have a few pixels change.

Can anyone think of an easier way to achieve this effect?
Title: Re: Rain on the map screen
Post by: Sektor 13 on Sat 23/04/2005 19:12:38
you can use rain drops as object and then use random function in repeaditly execute script (if random number 1 Animate object XX ...) You must add last fram of object animation to be transparent.... if you get my point.
Title: Re: Rain on the map screen
Post by: Hobbes on Sat 23/04/2005 19:32:14
Uhm.. I don't, really.

You mean having each raindrop be an individual object?

Or have it randomly appear on the map at certain times?
Title: Re: Rain on the map screen
Post by: strazer on Sat 23/04/2005 22:03:10
You could do something like this for example:

Make a view with each loop containing a different animation of a rain drop falling down, then:


// room script file

#define RAINDROP_AMOUNT 100 // number of rain drops to draw
#define RAINDROP_VIEW 21 // view number containing animation loops
#define RAINDROP_ANIMDELAY_MIN 5 // animation speed will be randomized between these two values
#define RAINDROP_ANIMDELAY_MAX 20

struct RainDrop {
  int loop; // stores current loop
  int frame; // stores current frame
  int framedelay; // stores delay until next frame
  int animationdelay; // stores overall animation speed
  int x; // stores x-location
  int y; // stores y-location
};

RainDrop raindrops[RAINDROP_AMOUNT];


function room_a() {
  // script for room: Player enters screen (before fadein)

  RawSaveScreen(); // save default (clean) background frame

}


function repeatedly_execute_always() {

  RawRestoreScreen(); // restore clean background frame

  int dropid = 0; // start with first drop
  while (dropid < RAINDROP_AMOUNT) { // loop for each drop

    if (raindrops[dropid].framedelay) raindrops[dropid].framedelay--; // if delay until next frame has not elapsed, decrease it
    else { // if delay until next frame has elapsed

      if (raindrops[dropid].frame >= GetGameParameter(GP_NUMFRAMES, RAINDROP_VIEW, raindrops[dropid].loop, 0)) // if animation has finished
        raindrops[dropid].frame = 0; // go to first frame

      if (raindrops[dropid].frame == 0) { // if at first frame (new animation)
        raindrops[dropid].loop = Random(GetGameParameter(GP_NUMLOOPS, RAINDROP_VIEW, 0, 0) - 1); // randomly select new loop from rain drop view
        raindrops[dropid].animationdelay = RAINDROP_ANIMDELAY_MIN + Random(RAINDROP_ANIMDELAY_MAX - RAINDROP_ANIMDELAY_MIN); // randomize overall animation speed
        raindrops[dropid].x = Random(game.room_width); // randomize x-location
        raindrops[dropid].y = Random(game.room_height); // randomize y-location
      }

      raindrops[dropid].framedelay = raindrops[dropid].animationdelay + GetGameParameter(GP_FRAMESPEED, RAINDROP_VIEW, raindrops[dropid].loop, raindrops[dropid].frame); // set delay until next frame

      raindrops[dropid].frame++; // go to next frame
    }

    RawDrawImage(raindrops[dropid].x, raindrops[dropid].y, GetGameParameter(GP_FRAMEIMAGE, RAINDROP_VIEW, raindrops[dropid].loop, raindrops[dropid].frame - 1)); // draw rain drop on background

    dropid++; // loop to next drop
  }

}


Or you could use a single image and automatically draw it resized with RawDrawImageResized. I can whip something up later if you're interested.
Title: Re: Rain on the map screen
Post by: Akumayo on Sun 24/04/2005 00:21:45
It would probably be easiest to not have any random functions.  Just draw an object the same size as the room.  Then make about 10 frames, each with the droplets in different places.  Put the object in the room where it coveres the map, and then animate it.  If you wanted more changes, you could just add another frame.
Title: Re: Rain on the map screen
Post by: on Sun 24/04/2005 03:11:33
stazer's code ( :o ) would probably look more realistic due to the randomization, seeing as rain is sporadic, and there's not a pattern of only 10 frames repeating themselves...if realism is important...
Title: Re: Rain on the map screen
Post by: Sektor 13 on Sun 24/04/2005 17:00:59
Quote from: Hobbes on Sat 23/04/2005 19:32:14
Uhm.. I don't, really.

You mean having each raindrop be an individual object?

Or have it randomly appear on the map at certain times?

you must make few object (lets say 12) and set their animation , and the set them equaly trough out the screen.. or you could use strazer idea too  ;D
Title: Re: Rain on the map screen
Post by: Sam. on Sun 24/04/2005 19:21:59
this might eb a dumb question, but, why isn't the Snowrain plugin working? I assume the mapscreen is another room? unless its a gui, in whcih case, i understand.
Title: Re: Rain on the map screen
Post by: MrColossal on Sun 24/04/2005 19:36:21
zooty, snow/rain plugin rain falls down right? Well if you're looking down on a map which way would snow/rain plugin rain fall?

It would look like it's falling horizontally across the earth.

which AGS are you using?

here is an animated GIF that you can import right into the new ags, how does it look?

http://www.sylpher.com/kafka/junk/edits/hobbesrain.gif

eric
Title: Re: Rain on the map screen
Post by: passer-by on Sun 24/04/2005 19:49:10
Quote from: MrColossal on Sun 24/04/2005 19:36:21
Well if you're looking down on a map which way would snow/rain plugin rain fall?
It would look like it's falling horizontally across the earth.

It should look like dots? Randomly sparkling or something ?
Title: Re: Rain on the map screen
Post by: Snarky on Mon 25/04/2005 13:50:25
It would look like those starfield screensavers, except going away from you, not coming at you. It should be relatively easy to program.
Title: Re: Rain on the map screen
Post by: Kweepa on Mon 25/04/2005 15:14:26
Quote from: Snarky on Mon 25/04/2005 13:50:25
It would look like those starfield screensavers, except going away from you

You mean like this?

Quote from: MrColossal
http://www.sylpher.com/kafka/junk/edits/hobbesrain.gif

:)
Title: Re: Rain on the map screen
Post by: Hobbes on Mon 25/04/2005 17:25:01
Quote from: MrColossal on Sun 24/04/2005 19:36:21
zooty, snow/rain plugin rain falls down right? Well if you're looking down on a map which way would snow/rain plugin rain fall?

It would look like it's falling horizontally across the earth.

which AGS are you using?

here is an animated GIF that you can import right into the new ags, how does it look?

http://www.sylpher.com/kafka/junk/edits/hobbesrain.gif

eric

Oooh, this looks splendid! I don't have the latest AGS, though, since Buc2 is being developed in 2.62 and I know for sure that Proskrito's template works with that.

But I should be able to extract the seperate screens and use them as sprites, right?

Thanks, anyway. It looks really neat!
Title: Re: Rain on the map screen
Post by: MrColossal on Mon 25/04/2005 18:42:36
I suppose you could do that... Or maybe, when exporting a cha file it saves all the frames and such, I can gif import and export a .cha and give it to you

Eric
Title: Re: Rain on the map screen
Post by: Scummbuddy on Mon 25/04/2005 20:06:54
I would appreaciate that, as for some reason, I have gone this far without a gif extractor.
Title: Re: Rain on the map screen
Post by: MrColossal on Mon 25/04/2005 20:13:44
You need a top down rain image for a 640x400 game?
Title: Re: Rain on the map screen
Post by: Hobbes on Tue 26/04/2005 17:09:56
If you could do this as a .cha file, that would be fantastic!

However, I forgot to mention that the game is actually 320x200. I only enlarged the gif so it would be clearer.

I hope it's not too much of a hassle?
Title: Re: Rain on the map screen
Post by: MrColossal on Tue 26/04/2005 17:32:14
I'll just make another at that size, no worries
Title: Re: Rain on the map screen
Post by: MrColossal on Tue 26/04/2005 22:47:13
http://sylpher.com/kafka/junk/Rain.zip

try that
Title: Re: Rain on the map screen
Post by: Hobbes on Wed 27/04/2005 20:43:30
Eric, just wanted to say: thank you! I imported the character, set the transparacy value and placed it correctly on the map screen.

It looks wonderful and the transition to normal screens where it's raining looks really nice now.

Thanks again!
Title: Re: Rain on the map screen (solved)
Post by: MrColossal on Wed 27/04/2005 23:15:27
Hooray!

Glad to help.