Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Rd27 on Sun 01/08/2004 16:02:43

Title: Animating things
Post by: Rd27 on Sun 01/08/2004 16:02:43
Hi

I have this problem with animating things, like doors and so on. I have tried to look other posts, but they have not helped me :(

Let's say, that I have a room with a door and the door is closed. If a player interacts the door, it will open. I don't know how to make the animation to make it open.

I have tried but had no luck.
If somebody could do a little example for me???

Thanks!

Title: Re: Animating things
Post by: Scummbuddy on Sun 01/08/2004 16:04:50
AnimateObject
AnimateObjectEx

look these up in the manual
Title: Re: Animating things
Post by: Rd27 on Sun 01/08/2004 19:11:21
I have looked those too, but I did not fully understand them:(

Maybe I will take a one more look at them.
Title: Re: Animating things
Post by: jrl2222 on Sun 01/08/2004 21:25:45
me too.
I have figured out most everything else but I can't seem to get a sprite to animate. I have it all set up in views but can't seem to get the thing to work right. isn't their a tutorial for setting up an actual animated sprite?
I can use the whole background but that seems like a big waste of resource for a 10x10 sprite that isn't an npc.
Title: Re: Animating things
Post by: Radiant on Mon 02/08/2004 12:26:23
Create a view that has all the sprites for the door opening, in correct order.
Make an object 0 that corresponds to the door.

In enter_room,
SetObjectView (0, DOORVIEW);

if player clicks hand on door,

if (door_is_open == 0) AnimateObjectEx (0, 0, 5, 0, 0, 1);
else AnimateObjectEx (0, 0, 5, 0, 1, 1);
door_is_open = 1 - door_is_open


Tadah!
Title: Re: Animating things
Post by: jrl2222 on Mon 02/08/2004 14:21:31
I got mine figured out.

I had the SetObjectView correct but was messing up the AnimateObject.

The room works great now.
Later
Title: Re: Animating things
Post by: Rd27 on Mon 02/08/2004 15:13:08
Do you guys mean, that when I make the room, I should make the door as an object? Now I have made the room graphic and painted the door as well to the graphic.

Do I have to make the door graphic later and then import it as a object

Thanks
Title: Re: Animating things
Post by: jrl2222 on Mon 02/08/2004 17:31:47
Thats exactly what you need to do. Your background needs to be painted with the door open and then the door needs to be an object over the top of the background. Then when the player interacts with the door in the way you decide(either by clicking the hand or using a key or something like that) you either turn on a new sprite or invoke an animation. Their are a few ways to do it now that I figured out my little problem I realize that.
Actually on second though you don't need to paint the door open if you don't want to. You just need to turn on an object that goes in place of the door that shows the door open. The tradtional way though would be to have the door open draw your walkable areas that go through the open door creating a seperate walkable area behind the door opening. Then in the room interactions in the player enters screen (after fadein)
Run script and put
RemoveWalkableArea(3); where as the 3 needs to be the # of your walkable area behind the door. Then create a hotspot and set the interaction to run script when interacted with and put
restorewalkablearea(3);
Then you either call an animation which is set up as a view (ex. above in my other post) Or turn on an open door object and turn off the closed door object. I found no good tutorials on this but was able to pull enough apart from the demo game to figure it out.
Title: Re: Animating things
Post by: Rainbow Guy on Tue 03/08/2004 02:16:28
Hi,

i been following this thread, and was wondering how i can Remove the door object after the Animation ( and get it to stay got )

(i want the animation to finish before, the door is removed)
Title: Re: Animating things
Post by: jrl2222 on Tue 03/08/2004 13:19:42
In your script after everything else is done put a Objectoff(#);
# would equal the actual number of your object in the room.
Title: Re: Animating things
Post by: Rd27 on Wed 04/08/2004 20:39:42
I got mine working guite well now. It's not quite what I was looking for, but it is fine for now :). If I want to make better animation in future, I will come back to this topic.
Title: Re: Animating things
Post by: Rd27 on Thu 05/08/2004 12:36:41
I think, that it is best if I learn to make better animation  :)

The problem is this:
When the player opens the door, the animation works, but the sprites are in wrong place ??? the animation and the final sprite is a little in wrong position, not much, but enough. Why is it doing so, is there way to place them in proper position?

And what do I have to do, to make the door closing work? If player now interacts with the opended door nothing happends?

if (door_is_open == 0) AnimateObjectEx (0, 0, 5, 0, 0, 1);
else AnimateObjectEx (0, 0, 5, 0, 1, 1);
door_is_open = 1 - door_is_open

Is that the solution? I don't quite understand it >:(

Thanks again!
Title: Re: Animating things
Post by: Ashen on Thu 05/08/2004 12:46:13
if (door_is_open == 0) {
  AnimateObjectEx (0, 0, 5, 0, 0, 1);
  door_is_open = 1;
}
else {
  AnimateObjectEx (0, 0, 5, 0, 1, 1);
  door_is_open = 0
}

As it was, the value of door_is_open never changed, so the close door animation would never run. Also, make sure door_is_open is a valid variable.
Title: Re: Animating things
Post by: Rd27 on Thu 05/08/2004 15:53:53
Ok, thanks!

I try that when I get back home. If it don't work, I will most likely post again  ;)
Title: Re: Animating things
Post by: Rd27 on Sun 08/08/2004 23:11:32
Ok, I just dont't get this thing.

When the player interacts the door, it opens, but when he interacts again, nothing happends and I want that the door closes the.

if (door_is_open == 0) {
  AnimateObjectEx (0, 0, 5, 0, 0, 1);
  door_is_open = 1;
}
else {
  AnimateObjectEx (0, 0, 5, 0, 1, 1);
  door_is_open = 0
}

As it was, the value of door_is_open never changed, so the close door animation would never run. Also, make sure door_is_open is a valid variable.

I don't understand a bit about that.
Title: Re: Animating things
Post by: Ashen on Mon 09/08/2004 00:25:54
Hmm, odd, worked for me. Try the slightly longer way:

if (door_is_open == 0) {
  AnimateObjectEx (0, 0, 5, 0, 0, 1);
  door_is_open = 1;
}
else if (door_is_open == 1) {
  AnimateObjectEx (0, 0, 5, 0, 1, 1);
  door_is_open = 0;
}
Title: Re: Animating things
Post by: Rd27 on Mon 09/08/2004 11:19:07
What do I put in those (door_is_open) things? I don't understand nothing about this :'(  I'm gonna give up soon  :(
Title: Re: Animating things
Post by: Radiant on Mon 09/08/2004 11:36:20
That would be a variable.
At the top of your script, add
int door_is_open;

If you don't understand variables, I'd recommend googling a beginner's course to programming.
Title: Re: Animating things
Post by: Ashen on Mon 09/08/2004 11:37:21
Darn, radiant replied while I was typing. Still:

I'm not sure which bit you're having the problem with, so here's a step-by-step. Feel free to ignore any bits you already understand.

1. If you haven't already, create the int door_is_open. Add this line to the room script (Ctrl-E or the {} button on the Room Settings panel):
      int door_is_open;

2. Again, if you haven't already, create the door object, and set its view.

3. Add this to the door object's 'Interact object' interaction:
      if (door_is_open == 0) {
        AnimateObjectEx (0, 0, 5, 0, 0, 1);
        door_is_open = 1;
      }
      else if (door_is_open == 1) {
        AnimateObjectEx (0, 0, 5, 0, 1, 1);
        door_is_open = 0;
      }

4. Test the game, you should have an opening and closing door.

Hope this helps.
Title: Re: Animating things
Post by: Rd27 on Mon 09/08/2004 23:44:36
Thanks a lot, it finally works  ;D ;D ;D

I didn't know that I had to make it a variable, but now I know!!!