Object / Character animations (SOLVED)

Started by Bhup, Mon 20/12/2004 18:04:47

Previous topic - Next topic

Bhup

One more thing as well as needing a reply to the escaping an animation could you also please tell me how to detect whether an inventory item exists in the inventory?
Merry Xmas to one and all.
Bhup

strazer

Quote
What happened is that it went through the animate sequence once then stopped.

Try the above code with

  AnimateObject (7, 0, 40, 1);

This way, the animation is looped. You can skip it with the ESC key (ASCII code 27).

Quotehow to detect whether an inventory item exists in the inventory

If you want to know if a character is carrying a specific item, do

  if (character[EGO].inv[11]) { // if character EGO carries inv item 11 (one or more)
    // do stuff
  }

Bhup

Dear Strazer,

Thanks.  Your a genius!!!!
I tried your first answer to my first question that is :

Animate(0,0,40,0);

Initially before you told me I used this to loop my animation but the escape wouldn't work because I was using Animate(0,0,40,0) in side the while loop that is :

while ((IsKeyPressed(27) == 0) && (IsObjectAnimating(7) == 1)) {
      Animate(0,0,40,1);
      Wait(1);
}

But I realise now that your supposed to use it after the Animate command.  I did not realise that the while loop containing the IsKeyPressed(27) command could be executed after Animate because I thought the animation sequence would finish before the while was executed.  It is a little confusing.

Anyway I used the second command you gave me after the animate sequence.  Before I run the command you gave me I actually go into another room. (NewRoom(2)).

Room 1 contains a picture without the rope and room 2 contains a rope tied to the pole on the boat.   What I want to do is display the new picture (the rope tied on the pole on the boat ) after the animation is over and I want it to have  the same objects that were not put in inventory in the first room or picture.

The only way I could think of displaying the new picture was by going into a new room( Room 2).
And then I thought how do I display the same objects that were not in inventory in room 1, I figured I needed some way of knowing what was in inventory allready and then use Object off to delete the object if it was allready in the inventory.

Hence the command you kindly gave me:

if (character[TOMSCRIPT].inv[0]) { // if character EGO carries inv item 11 (one or more)
    ObjectOff(0);   


This however does not work the way I want it to.

Sorry for the laborious explanation, bascially do you know of a better way I could display the new picture after the animation sequence in room 1 containing the same objects that are currrently in room 1.

Hope you or anyone else don't mind answering this tedious question.
Bhup

strazer

The code got mangled, I suppose you were doing
Code: ags

if (character[TOMSCRIPT].inv[0]) {
    ObjectOff(0);   
} 

?
If so, it doesn't work because there's no inventory item 0! :P

However, there's no need to change rooms!
Why don't you stay in the room and just turn on another object that shows the rope tied to the boat?
You could also draw another frame for the background and set it with SetBackgroundFrame.

Bhup

Dear Strazer.
Do you know what?...when you come up with an answer...it then seems soooo ::) obvious.
Again I am eternally greatful for your help.  But Herr Strazer I 'yust'(just) have wan leeetle question..err..sort of.

I tried changing background because I allready had one and wanted to avoid the task of creating a single object.  Anyway I went into Room Editor, Settings. Animating background and imported the background I wanted.  I then added the the statement SetBackgroundFrame(1) at the end of the runscript code of the of the hotspot.  I ran it

Ishmael

Sounds like the background started flicking those two frames right away, or? If this is the case, adding SetBackgoundFrame(0); to the Player enters screen (before fadein) room interaction should fix it.
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

Bhup

Dear Strazer.
Do you know what?...when you come up with an answer...it then seems soooo ::) obvious.
Again I am eternally greatful for your help. Ã, But Herr Strazer I 'yust'(just) have wan leeetle question..err..sort of.

I tried changing the background because I allready had one and wanted to avoid the task of creating a single object. Ã, Anyway I went into Room Editor, Settings. Animating background and imported the background I wanted. Ã, I then added the statement:

SetBackgroundFrame(1)

at the end of the runscript code of the of the hotspot. Ã, I executed the game and immediately from the start, the background kept animating/looping between the two background. I couldn't for the life of me find out what is causing this.

Secondly, I finally forced myself to create an object and use the 'object'approach. Ã, My code only seems to respond to 'escape' if there is 'NewRoom' command at the end of the while statement, thus:

SetObjectView(7,3);
ObjectOn(7);


AnimateObject(7,0,40,1);


while ((IsKeyPressed(27) == 0) && (IsObjectAnimating(7) == 1)) {
Ã,  Wait(1);
}
NewRoom(2);

If I put anything else there such as : ObjectOn(8) the animation sequence continues to loop when I press escape.

I am curious to know the answer using the background 'and' the object method. Could you please help once again Herr Strazer????
Fraulein Bhup

strazer

QuoteI executed the game and immediately from the start, the background kept animating/looping between the two background. I couldn't for the life of me find out what is causing this.

Like Ishmael said, if you import additonal background frames into your room, they are being animated by default.
So setting the room background to the first frame (the normal background) when you enter the room should disable this animation. See above post.

Quotethe animation sequence continues to loop when I press escape.

Hehe, yes it does since you don't tell it to stop.
What we're doing is starting a looping object animation, then stopping the script to wait for the ESC keypress. Otherwise the object would just keep animating non-blocking in the background.
After the keypress we have to tell it to stop this animation:

while (IsKeyPressed(27) == 0) Wait(1); // wait for ESC keypress
SetObjectView(7, 3); // does this stop object animation?

(We don't need IsObjectAnimating anymore as it will always be true since the animation loops.)

I don't remember what the proper way to stop an object animation is, you can try re-setting the object view as I have done above or simply re-starting the animation, but this time non-repeating so it only animates once then stops.
Try a few things and please let us know how it turned out.

QuoteAgain I am eternally greatful for your help.

Gern geschehen. :)

Bhup

Herr Strazer,
Ich begruBe sie alle..es freut mich, sie kennenzulernen
(she writes, after quickly going through a German phrase book she once used in Germany after working there for two weeks and no longer uses..cause it's too **** hard.) :D

I tried my hardest to look for an alternative to stopping the animation midway within the allotted time I have.  I used SetObjectView(7,14) as you said and it did stop the animation but how do I retrieve my current room i.e. room 1 which contains all my objects and background that i still need.  I tried putting NewRoom(1) after SetObjectView but it does not seem to execute past SetObjectView.  It stays on view 14 and basically does nothing.  What am I missing here???

If there is no answer then I will have to stick to running the animation once and allowing the user to click on the hotspot and that way they can run the animation again. 

Bhup

strazer

I'm afraid you've lost me here. "Retrieving current room"? Are you changing rooms after all? ???
Maybe you could post the whole script you have written for this interaction. I'm confused...

Bhup

Strazer,
No problem. p.s. Hope I got the German correct...yes I know no chatting in the forum  :-[.

Here is the code it is in response to the interaction button of a hotspot.  This hotspot is a lifebuoy on a beach.  The character is in a boat and can't get out of it due to killer jellyfish surrounding the boat.  The player has to combine the rope object with the Sword object which are in the boat.  After combining the two, a picture appears in the inventory of the sword attached to the rope.  Then in order to get out of the boat the player must click the sword attached to the rope, on the lifebuoy.  A short animation then follows of the character throwing the sword at the lifebuoy.  I want to show the final picture "after" the animation of the rope tied to the boat and the other end attached to the lifebuoy(that is, the sword in the middle of the lifebuoy), with the same objects displayed in the boat that have not yet been put in the inventory.   I also wanted to loop the animation and allow the user to quit/escape the aimation at any time and for the next scene not room to be displayed. 

The only way I can think of stopping the animation is by using SetObjectView after the while loop.  (With hindsight I realise now that I did not explain myself very well in th last reply..I was not very focussed at the time. ),  however I can't seem to display the final picture after the animation containing the objects that had not been pu tin inventory.  The code follows:

SetObjectView(7,3);
ObjectOn(7);


AnimateObject(7,0,40,1);


while ((IsKeyPressed(27) == 0) && (IsObjectAnimating(7) == 1)) {
   Wait(1);
}

SetObjectView(7,14);
// Want to display final picture after it stops here,
// but seems as if code will not execute passed
// SetObjectView..ps..how do I display new picture
// with rope tied to boat containing objects in
// room1/first scene that hasn't allready been put in
// inventory.

// NewRoom(1);  I tried this for a reason butI forget now

// ObjectOn(8);  Same reason as room.

Hope this makes sense.   :)
Bhup

strazer

QuoteA short animation then follows of the character throwing the sword at the lifebuoy.

That could also be accomplished animating the character itself.

QuoteI want to show the final picture "after" the animation of the rope tied to the boat and the other end attached to the lifebuoy(that is, the sword in the middle of the lifebuoy),

As I said, draw another version of the background or use an object that's initally off, containing a picture of the rope tied to the boat and lifebuoy.
Set the background frame or turn the object on after the animation.

Quotewith the same objects displayed in the boat that have not yet been put in the inventory.

I'm not sure what you mean.
Objects don't appear or disappear by themselves. They stay on/off if you don't turn them on/off and they're not affected if you set another background frame.
You don't draw stuff you can pick up directly onto your background, do you?

QuoteI also wanted to loop the animation and allow the user to quit/escape the aimation at any time

I don't understand why this animation has to be looped at all. What is he doing?

Quoteand for the next scene not room to be displayed.

Next scene? Another room?
I'm sorry, I don't know what you're getting at.

QuoteThe only way I can think of stopping the animation is by using SetObjectView after the while loop.

Glad that worked.

Quotehowever I can't seem to display the final picture after the animation containing the objects that had not been pu tin inventory.

What does happen? Do you get an error message?

Quote// Want to display final picture after it stops here,

Do you mean the last frame of the animation?
If so, try running the animation once again after the while loop, this time non-repeatedly, or just use SetObjectFrame.

Quote// but seems as if code will not execute passed
// SetObjectView

I doubt that's a bug. To be certain, put a simple Display command there to see if it gets executed.

QuoteHope I got the German correct...

Yes, very good! :)

Quoteyes I know no chatting in the forum

Not in the technical forums, anyway. ;)

Bhup

Strazer,
Ok forget the 'looping' animation.  I have my reasons for the looping but I wont go into that now.  It's sufficient to just run the animation once.  Heres the code:

// script for hotspot1: Use inventory on hotspot


SetObjectView(7,3);
ObjectOn(7);

AnimateObject(7,0,40,0);

//Display("Hi Bhup!!!! How are you today");

// As you can see I did try the 'Display' and when
// I clicked on the lifebuoy(hotspot), it immediately
// displayed the message.  I had to click the screen to
// start the animation.  Funny that..I thought the
// animation would have started before the
// message?!?

SetBackgroundFrame(1); //This does not execute or
                                        // show the new background


// The code below is just stuff I was messing around
// with to see if I could come up with a solution

//AnimateObject(7,0,40,1);
//AnimateObjectEx(7,0,40,0,0,0);

//while ((IsKeyPressed(27) == 0) && (IsObjectAnimating(7) == 1)) {
//  Wait(1);
//}

//SetObjectView(7,14);
//NewRoom(1);

// ObjectOn(8);

It seems that after the AnimateObject is run once it stays on the last frame no matter what the next command is.

Oh yeah by the way  :-X


Bhup

strazer

QuoteFunny that..I thought the
// animation would have started before the
// message?!?

That's correct. It has been started. Since it's a non-blocking command, the following script is executed immediately afterwards.
The reason you see the animation only after clicking away the Display message is that Display IS a blocking command, pausing the game while it runs.

The "while" was used to make the animation blocking with being able to skip it, since it was a looping animation. Making a looping animation blocking with AnimateObjectEx would make no sense since it loops forever, thus blocking the game forever.

But since we don't need a looping animation, we can make the animation run once, but make it blocking by itself so that the following code (changing the background) is executed after the animation has finished.

Change
  AnimateObject(7,0,40,0);
to
  AnimateObjectEx(7,0,40,0,0,1); // play animation once, blocking

Quote
SetBackgroundFrame(1); //This does not execute or
                                        // show the new background

If Display is executed, so is this command. There must be something else afoul.
Are you sure you've imported the correct, changed background image as the new background animation frame?
Is 1 the correct frame number? 0 is the original background, 1 the first animation frame, 2 the second animation frame and so on.


Bhup

Hello there Strazer,
I did the follwing as you recommended:

  // script for hotspot1: Use inventory on hotspot


SetObjectView(7,3);
ObjectOn(7);

// AnimateObject(7,0,40,0);
AnimateObjectEx(7,0,40,0,0,1); // play animation once, blocking
Display("Hi Bhupinder!!!! How are you today");  //I left this bit in to see if
                                                                            //it .executed next
//command. It did.
SetBackgroundFrame(1);


Bhup

Hello there Strazer,
I did the following as you recommended:

Ã, // script for hotspot1: Use inventory on hotspot

SetObjectView(7,3);
ObjectOn(7);

// AnimateObject(7,0,40,0);

AnimateObjectEx(7,0,40,0,0,1); // play animation once, blocking

Display("Hi Bhupinder!!!! How are you today"); Ã, //I left this bit in to see if
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, //it executed next
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, //command....It did.

SetBackgroundFrame(1); Ã,  Ã,  Ã,  //I 'did' import the right frame and it 'is' number
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, //1. Ã, However, it still appears as though
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, //the frame is not being displayed because the
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, //last frame of the animation just remains there.
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, //I 'think' I know what might be happening....

The animation starts from an object which is at the bottom left hand of the screen. Ã, The animation is 640 by 480 and fills the entire screen rather than a portion of the screen. Ã, When I call SetBackgroundFrame(1) it probably 'does' display the background but it it can't be seen because the last frame of the animation is in the foreground. Ã, Could this be the case????

If so I do I get rid of/switch off the last frame ????
Bhup

strazer

QuoteThe animation is 640 by 480 and fills the entire screen rather than a portion of the screen.  When I call SetBackgroundFrame(1) it probably 'does' display the background but it it can't be seen because the last frame of the animation is in the foreground.  Could this be the case?

Absolutely! I should've read the thread more carefully, I didn't realize you were doing this.
It's generally not a good idea to use such large animation frames as the sprites (contrary to room backgrounds) are stored uncompressed in the game exe (for performance reasons) and thus increase the file size dramatically.
But if you really want to do it that way, why not turn off the object after the animation has finished?
I suppose since the object you've used is in the lower left corner, it covered all other objects you had in the room? In that case just set this object's baseline to the very top so that all other objects are always in front of it.

But since you want to animate only the character anyway, I suggest you simply animate the character, not fill the whole screen with an object animation.

Bhup

QuoteAbsolutely! I should've read the thread more carefully
Pourquoi? Qu'est ce que vous mean by thread  ?

QuoteAbsolutely!
I'm getting good at this!


QuoteBut if you really want to do it that way, why not turn off the object after the animation has finished?
Seems like a very good idea...I shall try this.

QuoteBut since you want to animate only the character anyway, I suggest you simply animate the character, not fill the whole screen with an object animation.
Hmmm...I am more inclined to
Quotefill the whole screen with an object animation.
Will small scene I'm animating...will that be considered some kind of 0bject and can it be turned on and off like an object.  I can't quite visualise how animating the character will work because if you want to animate the character throwing a sword attached to the rope whilst in a boat to a lifebuoy...I just can't see it...what am I missing besides my brain??

(p.s. Mirc u sometime  ;) )
Bhup






strazer

QuoteQu'est ce que vous mean by thread?

Look it up it an dictionary. I honestly don't know how to describe it. It's this topic here we're discussing.

QuoteI can't quite visualise how animating the character will work because if you want to animate the character throwing a sword attached to the rope whilst in a boat to a lifebuoy...

Just draw animation frames containing the character, the rope and sword and animate the character with this animation. Just move the character to the place where the animation best fits into the background before starting the animation (so he hits the lifebuoy).

Bhup

Strazer,
1. I am familiar with threads in Java.  They are usually used for multitasking... you know...overlap input and output operations with processing.  Is this the same definition/concept in AGS??

2. I also understand that threads for example allow processes in a program that need to be continuously running, such as a continuously running animation, to be overlapped with other activities in the program.  This again is another Jave concept.  Hence is the definition more closer to the this???
Bhup

SMF spam blocked by CleanTalk