best way to do expressions using miniature avatars

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
Free Time Machine
Regular
Posts: 42
Joined: Fri Jun 15, 2007 9:45 am
Location: Philly, USA
Contact:

best way to do expressions using miniature avatars

#1 Post by Free Time Machine »

I've decided that in my game, the main character will have a small avatar on the left of the text box. That's easy enough to copy from the demo, but what about showing different facial expressions? Should I create a different character for each expression? What's the elegant way to code this? I'm thinking of Nettestadt and Jitteh Dawn as examples of the desired effect.

EDIT: FYI, I'm also using DynamicCharacter so that the user can input a name, so the solution needs to work with this.
"HOLD ON TIGHT" ~ Outfits and expressions, where art thou? And why does Elsa's face look so awful??? *bangs head in*

Everytime you delete a traceback, someone else gets it. -PyTom

User avatar
PyTom
Ren'Py Creator
Posts: 16093
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: best way to do expressions using miniature avatars

#2 Post by PyTom »

Nowadays, you can use ShowingSwitch to choose the expression. See the example at the website, it should work similarly for a DynamicCharacter.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

rocket
Veteran
Posts: 373
Joined: Tue Jul 10, 2007 2:54 am
Projects: Starlight Ep0, Ep1
Location: San Fransisco
Contact:

Re: best way to do expressions using miniature avatars

#3 Post by rocket »

I can see how ConditionSwitch could be used for the desired effect, but I am not quite clear on the usage of ShowingSwitch.

This is the code I found:

Code: Select all

init:  
    $ e = Character(
        'Eileen',
        color="#c8ffc8",
        window_left_padding=160,
        show_side_image=ShowingSwitch(
            "eileen happy", "eileen_side_happy.png",
            "eileen vhappy", "eileen_side_vhappy.png",
            "eileen concerned", "eileen_side_concerned.png",            
            None, Null(),
            xalign=0.0, yalign=1.0))
Now what? If I do:

Code: Select all

    e "How am I feeling today?"
    show eileen happy
I get an error if I don't define that image or I get two images if I do.

Am I just supposed to do this?

Code: Select all

init:
    image eileen happy = Null()
That works but seems kinda... dunno... odd.
*scratches head*

Criptych
Regular
Posts: 87
Joined: Sat Jun 23, 2007 9:19 am
Projects: ALICE.NET
Location: The other end of the internet.
Contact:

Re: best way to do expressions using miniature avatars

#4 Post by Criptych »

rocket wrote:I can see how ConditionSwitch could be used for the desired effect, but I am not quite clear on the usage of ShowingSwitch.
~snip~
I get an error if I don't define that image or I get two images if I do.
I believe (correct me if I'm wrong, PyTom) that where ConditionSwitch selects an image based on an arbitrary condition, ShowingSwitch selects an image according to which other images are displayed. So you're supposed to have two images: one full-size character image, and one smaller image by the message window. From your description it sounds like you want just the smaller image; declaring the full-size image as Null() might work, but it "seems odd" because it's extra effort. Perhaps you want something more like:

Code: Select all

        show_side_image=ConditionSwitch(
            "eileen_expr == 'happy'", "eileen_side_happy.png",
            "eileen_expr == 'vhappy'", "eileen_side_vhappy.png",
            "eileen_expr == 'concerned'", "eileen_side_concerned.png",
(I'm not sure if there's a way to just derive the image filename directly from a variable?)
Computers are useless. They can only give you answers. —Pablo Picasso

Image

rocket
Veteran
Posts: 373
Joined: Tue Jul 10, 2007 2:54 am
Projects: Starlight Ep0, Ep1
Location: San Fransisco
Contact:

Re: best way to do expressions using miniature avatars

#5 Post by rocket »

Yes exactly.

It's odd because working around the system that way allows me to use normal "show charaName.mood" statements, whereas ConditionSwitch would force me to rewrite my script and put in "show charaName" "charaNameMood = mood" pairs.

*shrug*

Criptych
Regular
Posts: 87
Joined: Sat Jun 23, 2007 9:19 am
Projects: ALICE.NET
Location: The other end of the internet.
Contact:

Re: best way to do expressions using miniature avatars

#6 Post by Criptych »

rocket wrote:It's odd because working around the system that way allows me to use normal "show charaName.mood" statements, whereas ConditionSwitch would force me to rewrite my script and put in "show charaName" "charaNameMood = mood" pairs.
Hmm, good point-- I guess my method is the one that takes extra effort. n.n"
Computers are useless. They can only give you answers. —Pablo Picasso

Image

rocket
Veteran
Posts: 373
Joined: Tue Jul 10, 2007 2:54 am
Projects: Starlight Ep0, Ep1
Location: San Fransisco
Contact:

Re: best way to do expressions using miniature avatars

#7 Post by rocket »

PyTom! Please enlighten us! What is the intended usage of ShowingSwitch? What are we missing?!

:edit:

Wait, no, I'm an idiot.

If you were using the mini picture you wouldn't necessarily use "show charaName" because they'd just show up when you had them speak. So you could:

Code: Select all

show jenny
$ jennyMood = happy
jen "I'm so happy!"

$ lucyMood=angry
lucy "Baka! What's there to be happy about?!"

jen "Huh who's that?"

show lucy
lucy "Tada, it's me! It's me!"
lucy "Stop hogging the stage!"
play sound push
hide jenny

$ lucyMood=happy
lucy "Much better."

$ jennyMood = sad
jenny "Boo hoo!"
Is that the intended usage? *blinks*

User avatar
PyTom
Ren'Py Creator
Posts: 16093
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: best way to do expressions using miniature avatars

#8 Post by PyTom »

ShowingSwitch is intended for use with show_side_image, so that the side image's expression can easily match the emotion displayed on the screen. Unlike ConditionSwitch, ShowingSwitch properly deals with image prediction, so it's the better of the two to use if you can get away with it. (Even if you have to define some images to be Null().
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Post Reply

Who is online

Users browsing this forum: Google [Bot]