Author Topic: Animating Background+Bool  (Read 596 times)  Share 

Animating Background+Bool
« on: 10 Jun 2012, 21:52 »
Ok, maybe this is a bit complex for me at the moment but I'd like to have some advices on how to create these things:

Background animation

I've seen that is better using many backgrounds instead of single animating objects, but what if you want 3-4 looping characters in your background like for example in Venice for "Last Crusade"?

Interact with a looping character

Let say I want to talk with a character that is doing a loop action in background (maybe using RepExec function, don't know) and when I click he stops, start dialogue and then restart the loop, is easy to do?

Bool or conditions

This instead is when you can't open a door until you get some items or talk with someone for example, I was thiking to the bool function, but maybe is a different thing.

Can you give me some tips to start with these things? Thanks

Frito Master

  • 0% Trans-Fat 100% Toxic
    • I can help with animation
    •  
    • I can help with backgrounds
    •  
    • I can help with characters
    •  
    • I can help with voice acting
    •  
Re: Animating Background+Bool
« Reply #1 on: 10 Jun 2012, 22:13 »
I got a art background and a tiny tiny tiny amount of experience (A tad bit of java/lua.)
Only been using ages for a bit over a week but here we go.

Background animation

If there all doing different actions it might be hard because lets say a guy is smoking a cig and a woman is dancing and a guy is having a convo all of them require a different amount of frames.

Id draw a simple version of frame one of what the action starts as and then draw frame 4 of how it ends and then fill it in and see how it looks. I'd group the simple animations that don't require interaction into backgrounds. (Guy smoking and talking)

It just depends on so much.

Interact with a looping character
Easy just use
  Charatername.SpeechView = AnimationViewNumberHere;
Then after dialog switch it back.

Bool or conditions

I'm guessing it is a preference because it "most likely doesn't matter"
I personally use bools.


If you got anymore I'll try and help but limited experience here.
Your favorite brandname chip friend.

Deu2000

  • The only vaccum cleaner that supports TCP/IP
    • I can help with play testing
    •  
    • I can help with scripting
    •  
    • I can help with translating
    •  
    • I can help with web design
    •  
Re: Animating Background+Bool
« Reply #2 on: 10 Jun 2012, 22:56 »
To animate a character repeteadly, use Character.Animate()


Frito Master

  • 0% Trans-Fat 100% Toxic
    • I can help with animation
    •  
    • I can help with backgrounds
    •  
    • I can help with characters
    •  
    • I can help with voice acting
    •  
Re: Animating Background+Bool
« Reply #3 on: 10 Jun 2012, 23:00 »
Yeah if you want him to just animate or whatever use Character.Animate()
if you set a speech view up it will automatically switch to that when talking.(I switch between mad, angry, sad and laugh expressions though so i use the Speechview)
Your favorite brandname chip friend.

Khris

  • Evil Dark Emperor Death-Kill
    • Lifetime Achievement Award Winner
    •  
    • I can help with play testing
    •  
    • I can help with scripting
    •  
    • I can help with translating
    •  
Re: Animating Background+Bool
« Reply #4 on: 10 Jun 2012, 23:16 »
Background frames are useful for fluttering banners or waves at a beach.
If you want NPCs you can talk to, don't animate them using the background frames; you have to implement them as characters anyway and it is much easier to just assign them an Idle view. Look up Character.SetIdleView.

That should also answer your second question because afaik, an NPC with a set idle animation can talk just like any character. If he happens to idle animate during the dialog, just deactivate the idle anim before the dialog and start it again at the end.

The third question falls into the "asked and answered countless times" category.
Create a bool variable in the Global variables pane, initial value: false, then set it to true in cBartender's TalkTo code:
Code: Adventure Game Studio
  1.     talked_to_bartender = true;

In the door's use/open code, do:
Code: Adventure Game Studio
  1.     if (talked_to_bartender) ...
  2.     else player.Say("I should ask around first.");
http://whathaveyoutried.com/

The other day on yahoo answers:
"Can you print colored images with black ink? If so tell me how please Thanx Kimberly"

Re: Animating Background+Bool
« Reply #5 on: 10 Jun 2012, 23:28 »
Thanks, the first two are definitely more clear now, as for variables (true, false) I need to dedicate much more time and do some tries. I can set a variable for all kind of actions, right? The goal is finding the proper code :)

Frito Master

  • 0% Trans-Fat 100% Toxic
    • I can help with animation
    •  
    • I can help with backgrounds
    •  
    • I can help with characters
    •  
    • I can help with voice acting
    •  
Re: Animating Background+Bool
« Reply #6 on: 10 Jun 2012, 23:31 »
You can set it for whatever.

The tutorial/help built into ags is invaluable.

You'll be fine just give it a few trys and don't look up everything try to figure some of it out I think it helps learning.

Good Luck.
Your favorite brandname chip friend.

Re: Animating Background+Bool
« Reply #7 on: 20 Jun 2012, 18:41 »
I've tried to code this but maybe is completely wrong, can you help me?

Here what I've coded (I want the door opens only if an item is in inventory):

Code: Adventure Game Studio
  1. function hPorta_AnyClick() {
  2.    
  3.    
  4.     if (MovePlayer(46, 105)) {
  5.       player.FaceDirection(eDir_Left);
  6.     // LOOK AT
  7.     if(UsedAction(eGA_LookAt)) {
  8.       player.Say("E' il portone blu di casa.");
  9.       }
  10.     // USE
  11.     else if(UsedAction(eGA_Use)) {
  12.       player.Say("Meglio di no.");
  13.     }
  14.     // OPEN
  15.     else if(UsedAction(eGA_Open)) {
  16.      
  17.       if (Portafogli_inv = true) {
  18.        player.LockView(19);
  19.        player.Animate(1, 0, eOnce, eBlock, eForwards);
  20.        player.UnlockView();
  21.        oPorta1ap.Visible = true;
  22.       }
  23.      
  24.       else {
  25.      
  26.       player.Say("Non posso andarmene senza il mio portafogli.");
  27.       player.Say("E' da qualche parte qua nella casa ma non riesco proprio a ricordarmi dove l'ho lasciato.");
  28.     }
  29.   }

And here the code for the variable

Code: Adventure Game Studio
  1. bool Portafogli_inv {
  2.   player.ActiveInventory(iPortafogli);
  3. }

I've set a Global variable bool Portafogli_inv to false

NickyNyce

  • ready...FIRE...aim
  • NickyNyce worked on a game that was nominated for an AGS Award!
Re: Animating Background+Bool
« Reply #8 on: 20 Jun 2012, 19:09 »
look under HasInventory...no variable needed

if (player.HasInventory(iKey))
{
  Display("The player has the key!!");
}

Re: Animating Background+Bool
« Reply #9 on: 20 Jun 2012, 19:54 »
... Thanks, I'll check again all the functions. But if I want to use for dialogue variables like Chris said, I only need to use the bool name (for example talked_to_bartender) and set it to true in talk_to action?
What about a more complex bool to code under globalscript.asc? I think the way I've coded it is wrong... ;)

Khris

  • Evil Dark Emperor Death-Kill
    • Lifetime Achievement Award Winner
    •  
    • I can help with play testing
    •  
    • I can help with scripting
    •  
    • I can help with translating
    •  
Re: Animating Background+Bool
« Reply #10 on: 20 Jun 2012, 19:54 »
First of all, indent your code properly... I can't stress enough how important this is.

Now, like Nicky said, to simply check if the player possesses a certain inventory item, use player.HasInventory.

If, on the other hand, you want to find out whether the player has used a certain inventory item, you'll need this:
Code: Adventure Game Studio
  1.     else if (UsedAction(eGA_UseInv)) {
  2.       if (player.ActiveInventory == iCup) player.Say("I used the cup.");
  3.       else Unhandled();    // <-- this is needed to handle other inv items
  4.     }

As for your bool code, you can't define a Global variable called Portafogli_inv, then define it again within a script.
Also, to create a bool function, you'll need a) parameter brackets after the name and b) a return value. The following will compile:
Code: Adventure Game Studio
  1. bool player_is_using_key() {
  2.   if (player.ActiveInventory == iKey) return true;
  3.   else return false;
  4. }
Or the short version:
Code: Adventure Game Studio
  1. bool player_is_using_key() {
  2.   return (player.ActiveInventory == iKey);
  3. }
This function is useless though since you can directly check HasInventory() or ActiveInventory.

BUTT, and this is the most important part:
There's already a special function that does all the door handling. It's called any_click_on_door_special and is explained in the goddamn PDF that comes with the fucking template.
Not only does it allow you to specify the inv item that unlocks the door but also the message supposed to be displayed if the player tries opening the door while it's locked or looks at it.
There's also example code right there in the first room of the game.

Edit: May I also remind you of this thread: http://www.adventuregamestudio.co.uk/yabb/index.php?topic=46182.0
Did you forget everything I posted in there...?
« Last Edit: 20 Jun 2012, 19:57 by Khris »
http://whathaveyoutried.com/

The other day on yahoo answers:
"Can you print colored images with black ink? If so tell me how please Thanx Kimberly"

Re: Animating Background+Bool
« Reply #11 on: 20 Jun 2012, 20:24 »
At first glance I didn't understand well the any_click_on door special and had a bit hard time to clear my way until now. In fact I've used a longer way to reach the actions... sorry
I will try to read more careful and pay attention to details. Thanks

Now I've finished the DEMO, thank all for your support. -of course is ridiculous coded DEMO but is what I wanted :)-