Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Play_Pretend on Tue 29/11/2005 11:15:56

Title: Animating certain frames of animated background at a time?
Post by: Play_Pretend on Tue 29/11/2005 11:15:56
Update: (I read back through my original post, which was really long and confusing, so I'm not surprised no one responded.  This one's had all the fat trimmed off it. :) 

I have an animated character in my game so large in size that despite having only two frames of animation, it seriously slows the game down.  I tried replacing it with an animated background that instantly takes over the spot where the character was, but I couldn't figure out how to get the background frames to cycle *only* through frames 1 & 2, and skip the 0 frame where the background is blank.

Would this be possible using an if-else loop in the Repeatedly_Execute script of the room?  I tried one and it crashed the game, saying that the loop had no way out, basically.  I'm pretty sure I tried:

If (Cloudgone == 0) {
    SetBackgroundFrame(1);
    SetBackgroundFrame(2);
}
else if (Cloudgone == 1) {
     SetBackgroundFrame(0);
}

When the player does a certain thing, it SetGlobalInt's Cloudgone to 1.  Is this badly scripted?  Can anyone think of a better way to do it?  Thanks!
Title: Re: Animating certain frames of animated background at a time?
Post by: Elliott Hird on Wed 30/11/2005 12:49:34
Don't setglobal int.

At top of global script:

int Cloudgone;

and then use Cloudgone = 1;
Title: Re: Animating certain frames of animated background at a time?
Post by: Ashen on Wed 30/11/2005 14:53:00
I'm not sure what you mean by "it SetGlobalInt's Cloudgone to 1". You mean like SetGlobalInt(Cloudgone, 1)? Because that doesn't make much sense ... Rather than changing the value of Cloudgone - which you actually want - it'll be changing the GlobalInt that has the current value of Cloudgone (most likely 0, i.e. SetGlobalInt(0, 1)). It sounds like this might be the case - Cloudgone never changes, so the else condition is never met. Also, did you say in your original post you might've used a while loop? In that case, it'd definately give an infinite loop crash.

You need to be consistant in how you use ints - if you're using SetGlobalInt, you need to use GetGlobalInt in the conditionals. If you're using your own ints (i.e. Cloudgone) you need to set them like Elliott said - and make sure you're exported/imported them properly, if you want them to be global.

I'm also not sure if the two SetBackgroundFrame() commands back-to-back like that would work, but first things first.
Title: Re: Animating certain frames of animated background at a time?
Post by: Play_Pretend on Thu 01/12/2005 07:29:34
Sorry about being unclear. . .I meant that I have a global variable called Cloudgone, to determine whether or not the animated rain cloud is gone (1) or not (0).  When my character does a certain thing to make the cloud go away, it runs SetGlobalInt(2, 1); (2 being the same global value as Cloudgone, like you said).  Although it just occurred to me that I never did use GetGlobalInt in the loop, just if (Cloudgone == 0);, etc.

Unfortunately I already made this huge workaround to the problem using two identical rooms, one with animated background, one without, (all characters and objects jump between them. . .it works, but there's a momentary blink in the animation, which I don' t like, it looks unprofessional) and I can't even remember what my exact scripting of the original if-else loop was.

I'll experiment a bit more with it, and let you know how it turns out.  Thanks for the advice, guys.