SOLVED- Beard or not ? LiveComposite character and variables

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
ultramooz
Newbie
Posts: 8
Joined: Mon Jul 12, 2010 7:32 pm
Location: Paris, France
Contact:

SOLVED- Beard or not ? LiveComposite character and variables

#1 Post by ultramooz »

Hi, I'm beginning to work on a game and I'm slowly progressing in the basics of Ren'PY using the various tutorials and great cookbooks posts. My boyfriend is doing the character art, and I'll do the backgrounds, animation... and coding :? .

The game is geared toward a male gay audience and features male characters to romance (with probably naughty stuff to follow) and we'd like to let the user customize a little the character.

The main choice would be between a bearded/hairy guy , or a smooth one.

So far I successfully used this tutorial http://www.renpy.org/wiki/renpy/doc/coo ... d_Lip_Flap
To make a LiveComposite character with different emotions and animations

Code: Select all

 image roger = LiveComposite(
        (400, 650),
        (0, 0), "images/roger_neutral_corps_base.png",
        (170, 71), anim.Filmstrip("images/roger_neutral_eyes.png", (65, 30), (3, 7), 0.2 ),
        (180, 116), WhileSpeaking("roger", anim.Filmstrip("images/roger_neutral_mouth.png", (65, 30), (4, 3), 0.1)),
        (0, 0), "images/roger_beard.png",
        )
and I made a menu at the start of the game where you can choose [bearded] or [not bearded] with a "hairy" variable :

Code: Select all

# The game starts here.

label start:
    $ hairy = "beard"
    
    menu:
        "I love bearded guys !":
            jump room01
        
        "Yuck! Shave that face !":
            $ hairy = "nobeard"
            jump room01
... but I don't know how to make the live-composited character react to the choice of the user.
I saw some people use the Condition switch to do that, but I could not make it work with the LiveComposite animated character.

One other possibility I imagined would be to make the name of the transparent image with the beard change depending on the choice :

Code: Select all

(0, 0), "images/roger_beard.png",
could become

Code: Select all

(0, 0), "images/roger_RETURNOFVARIABLE.png",
and then the LiveComposite would either display roger_beard.png or roger_nobeard.png depending on the choice.

:cry: But I couldn't find the right way to code it either, I know it must be easy, but I'm probably searching the wrong keywords in the wiki and forum. (english is not my 1st language, sorry)

I know there are more tedious way to do it (the worst being two different path of the story depending on the choice, and double coding everything) but I'd be really grateful to learn a clever way if possible and be guided to the existing ressources.

(Many thanks already for the tutorials and cookbooks, those are great.)
Last edited by ultramooz on Fri Feb 22, 2013 5:35 am, edited 1 time in total.

v3-kei
Regular
Posts: 103
Joined: Wed Mar 07, 2012 5:50 am
Contact:

Re: Beard or not ? LiveComposite character and variables...

#2 Post by v3-kei »

I don't know much about progtamming, just drop by to say the game assets sound like Obscura's Coming Out On Top: http://www.kickstarter.com/projects/obs ... video-game
Moved account to fuicchi.

ultramooz
Newbie
Posts: 8
Joined: Mon Jul 12, 2010 7:32 pm
Location: Paris, France
Contact:

Re: Beard or not ? LiveComposite character and variables...

#3 Post by ultramooz »

You're totally right, our game will probably have the same audience than Obscura's : (gay) men, or girls that like male/male romance & sex.

Her project is really great, and I can't wait to play it (My Bf kickstarted it, and I'll buy it to play on my Mac too when it's released.) I was really impressed by the demo.

Our own game will probably be less ambitious in the story department. For our first steps with Ren Py, I think finishing a little game with pretty graphics, some sounds and nice backgrounds will be enough work... Besides it's a side project to our main activity which is comics.

I think our game will be different enough in the graphics department : Obscura's style is very clean and realistic, very American. Ours will be more cartoony, & inspired by what is usually called "bara-manga".

I'll have to thank her personally, cause playing her demo is the final kick in the b#tt that I needed to start working on our game... Hopefully some good souls will help me learn a little Ren Py coding.

I completely suck at coding, but I've some skills in photoshop, 3d modeling, manga studio, illustrator... So I'll try to help back in those domains.

User avatar
Arowana
Miko-Class Veteran
Posts: 531
Joined: Thu May 31, 2012 11:17 pm
Completed: a2 ~a due~
Projects: AXIOM.01, The Pirate Mermaid
Organization: Variable X, Navigame
Tumblr: navigame-media
itch: navigame
Contact:

Re: Beard or not ? LiveComposite character and variables...

#4 Post by Arowana »

Hmm, I use ConditionSwitch with animated characters as well, so I'm surprised to hear that it doesn't work here. Did you try something like this?

Code: Select all

 image roger = LiveComposite(
        (400, 650),
        (0, 0), "images/roger_neutral_corps_base.png",
        (170, 71), anim.Filmstrip("images/roger_neutral_eyes.png", (65, 30), (3, 7), 0.2 ),
        (180, 116), WhileSpeaking("roger", anim.Filmstrip("images/roger_neutral_mouth.png", (65, 30), (4, 3), 0.1)),
        (0, 0), ConditionSwitch(
            "hairy == 'beard' ", "images/roger_beard.png", #shows beard
            "hairy == 'nobeard' ", Null(), #shows nothing
            ),
        )
Good luck with your game, by the way! I'd be interested in seeing more bara. ;)
Complete: a2 ~a due~ (music, language, love)
In progress: The Pirate Mermaid (fairytale otome)
On hold: AXIOM.01 (girl detective game)

Image

v3-kei
Regular
Posts: 103
Joined: Wed Mar 07, 2012 5:50 am
Contact:

Re: Beard or not ? LiveComposite character and variables...

#5 Post by v3-kei »

Arowana wrote: Good luck with your game, by the way! I'd be interested in seeing more bara. ;)
^^^THIS. Good luck with yout game~
Moved account to fuicchi.

ultramooz
Newbie
Posts: 8
Joined: Mon Jul 12, 2010 7:32 pm
Location: Paris, France
Contact:

Re: Beard or not ? LiveComposite character and variables...

#6 Post by ultramooz »

Big thanks to both of you for the support and encouragements (is it an english word ?) and also for the code !

I just woke up to your answers, and I'm eager to try it!

Just by looking at your code, I understand I didn't format it correctly when I tried it yesterday... I'm pretty sure I didn't indent correctly the ConditionSwitch, and I didn't use a Null either, which is brilliant ( I tried to use a transparent .png with nothing on it )

I'll just finish my coffee to open my eyes enough to see the screen, and open RenPY to try it. When successful, I'll post the full working code below.

Thanks again ! (● °(エ)° ●) ♪☆

User avatar
Obscura
Eileen-Class Veteran
Posts: 1431
Joined: Fri Mar 09, 2012 6:58 pm
Projects: Coming Out On Top
Location: United States
Contact:

Re: Beard or not ? LiveComposite character and variables...

#7 Post by Obscura »

Ultramooz, Arowana's code looks good, but if you're still having problems I'll see if I can send you our code later this year when we work the hair mod into the game. (Saguaro is the magician coder, not me...she's waiting on me to finish some stuff right now.) Hair mods should be a feature of all games, LOL.*

Also, I dunno if your bf is in the CoT forum, but if he is, make sure he posts about your game. Or start a WIP thread here at some point so I can link to it. I'm not aware of a single Bara game made on Ren'Py and I'm sure everybody will be super excited. :mrgreen:

*edit: ahaaa--at the rate you're going though, I think you'll be done before I will.
Coming Out On Top - An Adult Gay Dating Sim
website

ultramooz
Newbie
Posts: 8
Joined: Mon Jul 12, 2010 7:32 pm
Location: Paris, France
Contact:

Re: Beard or not ? LiveComposite character and variables...

#8 Post by ultramooz »

@ Obscura :

So glad to hear from you ! Like I said, your project is a great inspiration, and really motivated us to finally begin our own game. Thanks for your offer to talk about our game on your forum, so far there's not much to pitch... but I hope this will soon evolve into a game. We'll be sure to talk about your game too, I've hopefully sold a few copies the other day when I showed the demo to some friends.

My big fear on our project is wanting to do too much for a first try, and not finishing it... so we'll begin small. Once the base coding is done and working, we will try to put together a not-too-stupid story and then work hard to add some eye candy on top.

Speaking of coding... Arowana was right : It works ! Here's the final commented code :

Code: Select all

init python:

    # This is set to the name of the character that is speaking, or
    # None if no character is currently speaking.
    speaking = None

    # This returns d if the character is speaking, and Null() if the
    # character is not. 
    def while_speaking(name, d, st, at):
        if speaking == name:
            return d, .1
        else:
            return Null(), None

    # Curried form of the above.
    curried_while_speaking = renpy.curry(while_speaking)

    # Displays d when the named character is speaking, and Null otherwise.
    def WhileSpeaking(name, d):
        return DynamicDisplayable(curried_while_speaking(name, d))

    # This callback maintains the speaking variable.
    def speaker_callback(name, event, **kwargs):
        global speaking
        
        if event == "show":
            speaking = name
        elif event == "slow_done":
            speaking = None
        elif event == "end":
            speaking = None

    # Curried form of the same.
    speaker = renpy.curry(speaker_callback)
    # END OF SPEAKING CODE
    
init:
    
    # Create a speaking character.
    $ roger = Character("Roger",
        color = "#FF24D7", #color of the name
        what_color="#FF24D7", #color of the speaking text
        window_left_padding = 160, # margin of the text left
        show_two_window=True, #put the name in a separate box
        callback=speaker("roger"))

    # Composite things together to make a character with blinking eyes and
    # lip-flap.
    
    image roger neutral = LiveComposite(
        (400, 650),
        (0, 0), "images/roger_neutral_corps_base.png", #base body
        (170, 71), anim.Filmstrip("images/roger_neutral_eyes.png", (65, 30), (3, 7), 0.2 ),
        (180, 116), WhileSpeaking("roger", anim.Filmstrip("images/roger_neutral_mouth.png", (65, 30), (4, 3), 0.1)), 
        (0, 0), ConditionSwitch(
            "hairy == 'a beard' ", "images/roger_beard.png", #shows beard
            "hairy == 'no beard' ", Null(), #shows nothing
            ),
        )

# The game starts here.

label start:
    $ hairy = "a beard" #default variable shows a bearded character

scene black with dissolve

    menu:
        "I love bearded guys !":
            jump room01 # no change default value is a beard
        
        "Yuck! Shave that face !":
            $ hairy = "no beard" # change default value to no beard
            jump room01

scene black with dissolve
    
    show roger neutral at right with dissolve
    
    roger "I'm neutral, and my mouth moves when I speak. I also blink. Blah blah blah blah blah blah blah."
    
    "Not speaking anymore. -Narrator's voice"
    
    roger "I have [hairy], depending on your previous choice. Blah blah blah blah blah blah blah."

    "Good ending..."
    return
Instead of the beard, I suppose you can imagine anything : clothes, hair, accessories... and make them appear by setting the corresponding variable to on or off... This is really convenient.

Note on the lip flap : at first, the mouth was too fast to even see the animation, so I added some images in the filmstrip to make it longer, and slowed the text in the options of the game (it was set on ultra-fast by default. (The lip animation plays while the text is appearing in the dialogue box, so if the text appears instantly, you don't see the mouth moving.)

I made a little jpg to better understand how this works and try to explain to my boyfriend how to create the artwork, I'll post it underneath :

Image

@ Arowana : Thanks again for your help, I owe you one ! <3

Hope this helps some others noobs like me !

Fabrissou
Newbie
Posts: 2
Joined: Sun Jul 11, 2010 9:23 am
Contact:

Re: SOLVED- Beard or not ? LiveComposite character and varia

#9 Post by Fabrissou »

Ohohoho ! This looks great !
(I'm Ultramooz's bf, so thank you for all the help ^___^)

art926
Newbie
Posts: 10
Joined: Fri Jan 23, 2015 8:08 pm
Contact:

Re: SOLVED- Beard or not ? LiveComposite character and varia

#10 Post by art926 »

What game is that? Did you finish it? Where can I find more about the game?

ultramooz
Newbie
Posts: 8
Joined: Mon Jul 12, 2010 7:32 pm
Location: Paris, France
Contact:

Re: SOLVED- Beard or not ? LiveComposite character and varia

#11 Post by ultramooz »

Hi Art926 !

So far the game is not finished, sorry ! We have some bits of graphics and code in place and working, but the main work on story, backgrounds is still in progress. We've been busy doing comics, so I hope we can take some time to work on the game finally this year. "Coming out on top" which is a real labor of love, has set the bar quite high in the quality department, so we'll have to work really hard on ours !

User avatar
Pierrou
Regular
Posts: 53
Joined: Fri Dec 05, 2014 8:25 pm
Projects: Togainu no Chi, DMMD, Omerta, ...
Skype: pierrouney
Location: France
Contact:

Re: SOLVED- Beard or not ? LiveComposite character and varia

#12 Post by Pierrou »

Dokkun !
Sorry for my english, it's not my native language. :s

art926
Newbie
Posts: 10
Joined: Fri Jan 23, 2015 8:08 pm
Contact:

Re: SOLVED- Beard or not ? LiveComposite character and varia

#13 Post by art926 »

"so we'll have to work really hard on ours" - please do! It's so much more fun to play interactive story than just read a comics ^.^
Do you have a developer blog?

ultramooz
Newbie
Posts: 8
Joined: Mon Jul 12, 2010 7:32 pm
Location: Paris, France
Contact:

Re: SOLVED- Beard or not ? LiveComposite character and varia

#14 Post by ultramooz »

Sorry, no developper blog yet... But as soon as we get in full production, as in : drawing backgrounds, animating characters, etc... We will ! I'll probably make a new thread here, and link a tumblr where we'll post some art and screens over time.

I'm working on two 20 pages color comics for the fanzine right now, so my hands are a little full... I hope to have them finished by june and then start on the game seriously. Dokkun is a hobby so sometimes it's hard to find time to do everything you have in mind.

Thanks for your interest !

Post Reply

Who is online

Users browsing this forum: henne, Majestic-12 [Bot]