Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: vpresrufus on Wed 06/04/2005 23:12:53

Title: animating objects?
Post by: vpresrufus on Wed 06/04/2005 23:12:53
basically, i want smoke to appear in a building wen i do a certain action? how can i accomplish this?

thanks in advance:)
Title: Re: animating objects?
Post by: stuh505 on Thu 07/04/2005 00:35:10
i dont have AGS right next to me so my response won't be super detailed...

but basically, you need to make an object in the room editor where you want the smoke to be.  you can draw all the frames of the smoke animation and then import them and make them into an animation loop.  then you can use script to set the view and loop of the object to cause it to animate that loop whenever you want.  look up the functions for Object and you should find the exact ones that pertain to animating it.  hope that helps
Title: Re: animating objects?
Post by: FrogMarch on Thu 07/04/2005 00:57:48
Yeah, what Stuh505 said, basically, but don't forget that you'll need something to trigger the smoke object coming on.

It would look something like this in the script (put it in repeteadly execute):

if(getglobalint(1)==1){
objecton(1);
setglobalint(1,0);
)

Where globalint 1 is a variable, which starts at 0, and object 1 is the smoke. Basically, when you set globalint 1 to 1, it will make the smoke appear. The globalint is then turned off to stop it from causing the game to skip from this point forward.

Don't forget to set object 1 to start as 'off' in the editor.
Title: Re: animating objects?
Post by: vpresrufus on Thu 07/04/2005 01:03:52
i am unsure how to make object animation loops. i can do character animation loops but not sure how to do objects its confusing me:S
Title: Re: animating objects?
Post by: FrogMarch on Thu 07/04/2005 01:08:00
You make the loops in the same way as with characters, by linking frames together in the editor.

To assign them to the object you just use:

setobjectview(1,1);
animateobject(1,1,1,1);

This is a rough example. Paste this into your script and hit F1 to get better help.

The help file is your friend  ;)
Title: Re: animating objects?
Post by: stuh505 on Thu 07/04/2005 01:54:05
frog,

i would not recommend using a global int or code in the repeatedly executed section.  both of those should be used sparingly.  you should keep you variables as local as possible to reduce confusion (even to yourself).  and you should avoid repeatedly executing commands that don't need to be repeatedly executed.  if you programmed everything this way, your game could really chug...and it could get confusing to have code spread out in unexpected places like this.

if all he wants to do is see smoke when he leaves the room,  then why not turn the object on THEN...run the animation...then turn the object off?  no need for any global vars, no need for any script being executed 60 times a second for the duration of the game.
Title: Re: animating objects?
Post by: Khris on Thu 07/04/2005 09:24:16
in the 'player enters screen (before fadein)' event, you put:

SetObjectView (int object, int view);
AnimateObject (int object, int loop, int delay, int repeat);

that's it.

So given the smoke is the first object (#0) and you are using loop 0 of the 2nd view, it could like this:

SetObjectView (0, 2);
AnimateObject (0, 0, 2, 1);
Title: Re: animating objects?
Post by: FrogMarch on Thu 07/04/2005 10:56:36
Stuh505,

Yeah I guess that's true, but I didn't have much info to go on. I thought he may have th character in a different room at the time, or something like that.

With a globalint, it can be triggered a any time, but yeah, I guess it could get a bit confusing if you used too many.
Title: Re: animating objects?
Post by: Khris on Thu 07/04/2005 17:50:05
Sorry, seems like I was asleep while reading this thread...