Animating things

Started by Rd27, Sun 01/08/2004 16:02:43

Previous topic - Next topic

Rd27

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!


Scummbuddy

AnimateObject
AnimateObjectEx

look these up in the manual
- Oh great, I'm stuck in colonial times, tentacles are taking over the world, and now the toilets backing up.
- No, I mean it's really STUCK. Like adventure-game stuck.
-Hoagie from DOTT

Rd27

I have looked those too, but I did not fully understand them:(

Maybe I will take a one more look at them.

jrl2222

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.

Radiant

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,
Code: ags

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!

jrl2222

I got mine figured out.

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

The room works great now.
Later

Rd27

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

jrl2222

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.

Rainbow Guy

#8
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)

jrl2222

In your script after everything else is done put a Objectoff(#);
# would equal the actual number of your object in the room.

Rd27

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.

Rd27

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!

Ashen

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 know what you're thinking ... Don't think that.

Rd27

Ok, thanks!

I try that when I get back home. If it don't work, I will most likely post again  ;)

Rd27

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.

Ashen

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;
}
I know what you're thinking ... Don't think that.

Rd27

What do I put in those (door_is_open) things? I don't understand nothing about this :'(  I'm gonna give up soon  :(

Radiant

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.

Ashen

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.
I know what you're thinking ... Don't think that.

Rd27

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!!!

SMF spam blocked by CleanTalk