Objects/Characters animating in the background

Started by Jade, Wed 15/09/2004 13:36:44

Previous topic - Next topic

Jade

I need help animating objects or characters in the background.
For example...i've a stormy background and i want to add some lighting effects. I think that its not the case to do the animation with frames of the landscape so i don't know if its better to create an object or a character to make it animating randomly(in my case the lightings).

I tried creating a character but if i set him animating when the room is loaded it loop only one time and if i set it repeately execute the game is stuck in cutscene mode... ???

Any help and suggest is appreciate, thanks!

Darth Mandarb

It makes more sense to use an animated object.

This question has been asked countless times.

Darth's helpful tip: Search first!

Here's just 1 of the many threads I found which may be of use to you.

I searched for 'background animation object' and got several results.

Best of luck!

Jade

#2
Ok thanks!Ã,  ;)

EDIT: wait...but if i want a character randomly animating how can i do it?
I tried but i always get stucked in cutscene mode... :(

dreammaster

What script are you using to animate your character. The AnimateCharacter method is non-blocking, and AnimateCharacterEx has a blocking parameter that specifies whether you want the animation to go in the background (ie. the script to continue running), or wait until the animation is finished.

Jade

#4
I used this:
int ran=random(10);
if (ran == 0) {
SetCharacterView(Character, 6);
AnimatedCharacter(Character, 0, 0, 1);
ReleaseCharacterView(Character);
}

I put this scrip under "repeately execute" in the room i want the character move randomly.

Gilbert

#5
As dreammaster stated, AnimateCharacter() is non-blocking, you need to make the game wait for it to stop (or just use AnimateCharacterEx() ) before using ReleaseCharacterView() (I take that SeleaseCharacterView() as a typo...): {Fixed by scummy, thanks}
int ran=random(10);
if (ran == 0) {
Ã,  SetCharacterView(Character, 6);
Ã,  AnimatedCharacter(Character, 0, 0, 1);
Ã,  while(character[Character].animating) Wait(1);
Ã,  ReleaseCharacterView(Character);
}

Jade

Actually i wasnt sure if using the "wait" thing...thank you for correcting the script...i'll try... :)

Jade

Ok...all is working...but the annoying remaining thing is that every time the character start animating randomly it stop the other actions.
I mean...it work like a little cutscene...is there a way to make him animating and being indipendend from other actions in the game?
For example...when i'm talking to another character in the room...the script for animating the other objects doesnt work... :-[

Albert Cuandero

Quotebut the annoying remaining thing is that every time the character start animating randomly it stop the other actions

but that's waht you told it to do...

it's this line:

while(character[Character].animating) Wait(1);

=AGS waits until the animation is over...
int do_you_like_me;
if (do_you_like_me == 1) Display ("You can call me Al");
else {}

Scorpiorus

#9
Yeah, so putting "if (character[Character].animating == 0)" within the repeatedly execute should do the trick:

repeatedly execute:


// if Character is not animating...
if (character[Character].animating == 0) {

Ã,  Ã,  ReleaseCharacterView(Character);

Ã,  Ã,  int ran=random(10);

Ã,  Ã,  if (ran == 0) {
Ã,  Ã,  SetCharacterView(Character, 6);
Ã,  Ã,  AnimatedCharacter(Character, 0, 0, 0);
Ã,  Ã,  }
}

dreammaster

Slight correction to Scorpiorus's code fragment - one trouble is that the animation is only restarted with a 10% probably. But your test condition was if .animating == 0, which means that it'd keep calling ReleaseCharacterView.

Perhaps  not a critical problem, but it's a good practice to set up flags so that such "ending" conditions only get called once. Otherwise, as your code becomes more complicated, there could be weird side-effects.

Gilbert

#11
I'll suggest this fix:

move
int ran;
to the top of the script, so it's not redeclared everytime the repeatedly_execute() script is run.

Then, in repeatedly_execute():
if (ran==0) {
Ã,  Ã,  if (character[Character].animating==0) {
        // if Character just stopped animating
Ã,  Ã,  Ã,  Ã,  ReleaseCharacterView(Character);
Ã,  Ã,  Ã,  Ã,  ran=1; //So to trigger random() again next game loop
Ã,  Ã,  }
} else {
    // if Character is not animating...
Ã,  Ã,  ran=random(10);
Ã,  Ã,  if (ran == 0) {
Ã,  Ã,  Ã,  SetCharacterView(Character, 6);
Ã,  Ã,  Ã,  AnimatedCharacter(Character, 0, 0, 0);
Ã,  Ã,  }
}


Edit: oops found that the former codes may not work as expected.

Scorpiorus

Quote from: dreammaster on Fri 17/09/2004 00:58:29PerhapsÃ,  not a critical problem, but it's a good practice to set up flags so that such "ending" conditions only get called once. Otherwise, as your code becomes more complicated, there could be weird side-effects.
Yep, good point. Here, as you say, it's not that critical since the character's view is only released when he isn't animating. And since he isn't to move ReleaseCharacter shouldn't have a side effect. But yeah practically it's a way to go. Gilbert's code will care about it. The only thing left to do is to increase a value within random(...), because otherwise the animation will be run almost instantly. :)

Jade


SMF spam blocked by CleanTalk