Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: kaputtnik on Sun 08/05/2005 11:02:52

Title: Animating Backgrounds
Post by: kaputtnik on Sun 08/05/2005 11:02:52
Hey there.
I'm expecting a "no", but I'll ask anyway.

Is there any way of animating backgrounds with more than just the four additional sprites? Or: Is there any way to set the delay between the different sprites separately?
Title: Re: Animating Backgrounds
Post by: RyRayer on Sun 08/05/2005 11:29:03
I don't know about that, but you can add characters, which animate repeatedly and set their Idling delay 0 like THAT:

character[*your character's name*].SetIdleView(3,0);

3 is view. Change it to your own view.
0 means that it animates repeatedly.

Put this code to your room's "Player enters screen(before fadein)" -  run script.

You can change sprite changing delay in views section.

I hope this helps.

I made a template just in case. here (http://www.zone.ee/ryrayer/Testing.agt)

Title: Re: Animating Backgrounds
Post by: Ubel on Sun 08/05/2005 13:04:21
The answer is no (for version 2.62 anyway). But of course you can use animated objects. That would probably be easier than using characters.
Title: Re: Animating Backgrounds
Post by: RyRayer on Sun 08/05/2005 13:06:37
I use character my self because i have problems using objects. They keep blocking my game and if I set Eblocking no, object stops animating.
Title: Re: Animating Backgrounds
Post by: strazer on Sun 08/05/2005 20:15:26
Quote from: egalotron on Sun 08/05/2005 11:02:52Or: Is there any way to set the delay between the different sprites separately?

If you really need the whole background to be animated, you could do it like this:

In a room with 3 background frames, to let the frames stay for 8, 10 and 7 game loops respectively:


// room script file

#define NUM_BACKGROUNDFRAMES 3 // including normal background (maximum 5)

int BackgroundFrameDelay[NUM_BACKGROUNDFRAMES]; // stores the delays of each background frame (in game loops)
int CurrentBackgroundFrame = 0; // stores currently displaying background frame (start with first one)
int CurrentDelay; // stores current delay before displaying next frame


function repeatedly_execute_always() {
  //...

  if (IsGamePaused() == 0) { // if game is not paused

    if (CurrentDelay) CurrentDelay--; // if delay has not expired yet, decrease it
    else { // if delay until next frame has expired
      SetBackgroundFrame(CurrentBackgroundFrame); // display selected background frame
      CurrentDelay = BackgroundFrameDelay[CurrentBackgroundFrame]; // set delay until next frame
      CurrentBackgroundFrame++; // select next background frame
      if (CurrentBackgroundFrame >= NUM_BACKGROUNDFRAMES) CurrentBackgroundFrame = 0; // if reached last background frame, select first one (loop)
    }

  }

  //...
}


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

  //...

  BackgroundFrameDelay[0] = 8;
  BackgroundFrameDelay[1] = 10;
  BackgroundFrameDelay[2] = 7;


  //...
}
Title: Re: Animating Backgrounds
Post by: kaputtnik on Tue 10/05/2005 15:25:16
Thanks a lot strazer, that was just what I was looking for.