Lip flap and random blinking with ATL? [SOLVED]

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
User avatar
SundownKid
Lemma-Class Veteran
Posts: 2299
Joined: Mon Feb 06, 2012 9:50 pm
Completed: Icebound, Selenon Rising Ep. 1-2
Projects: Selenon Rising Ep. 3-4
Organization: Fastermind Games
Deviantart: sundownkid
Location: NYC
Contact:

Lip flap and random blinking with ATL? [SOLVED]

#1 Post by SundownKid » Thu Apr 26, 2012 9:00 pm

I'm trying to use this code to make the characters have the blinking animation, but it seems to be non-random in the amount of time characters have their eyes open. How do I add a random number picker or something?

Also, isn't the Animation function deprecated?

Unrelated question: Is it possible to enclose the entire thing in another animation that makes it bob slightly up and down?
Last edited by SundownKid on Tue Dec 17, 2013 6:41 am, edited 3 times in total.

User avatar
Mild Curry
Regular
Posts: 107
Joined: Fri Jul 02, 2010 3:03 pm
Projects: That's The Way The Cookie Crumbles
Organization: TwinTurtle Games
Contact:

Re: LiveComposite with random blinking?

#2 Post by Mild Curry » Sat Apr 28, 2012 6:34 pm

Randomizing the amount of time between blinks would be hard, because you’d have to keep updating the animation with the new time. Might be possible to write a function that randomizes a number and then shows the animation…I dunno. If you have some python experience you could play around with renpy.random.randint() and renpy.show().

What I would do, though, is just extend the animation so it's a cycle of differently timed blinks, which would appear more natural.

Code: Select all

Animation("eyes.png", 4.0, "blink.png", 0.1, "eyes.png", 6.0, "blink.png", 0.1, "eyes.png", 1.5, "blink.png", 0.1)
Also, for your second question, bobbing is easily achieved with a transform:

Just declare a transform somewhere (an init block is best):
(this one just goes up and down a little bit at the middle of the screen)

Code: Select all

transform bobbing: 
     xalign 0.5
     yalign 0.5
     linear 1.0 yalign 0.49 
     linear 1.0 yalign 0.5
     repeat
Then, when you’re ready to show the LiveComposite, do this:

Code: Select all

show myComposite at bobbing
http://www.renpy.org/doc/html/atl.html

User avatar
SundownKid
Lemma-Class Veteran
Posts: 2299
Joined: Mon Feb 06, 2012 9:50 pm
Completed: Icebound, Selenon Rising Ep. 1-2
Projects: Selenon Rising Ep. 3-4
Organization: Fastermind Games
Deviantart: sundownkid
Location: NYC
Contact:

Re: LiveComposite with random blinking? [unsolved]

#3 Post by SundownKid » Sat Apr 28, 2012 11:55 pm

EDIT:

Got the bobbing to work using yanchor instead.

I still could use a random number maker to save space.

User avatar
DaFool
Lemma-Class Veteran
Posts: 4171
Joined: Tue Aug 01, 2006 12:39 pm
Contact:

Re: LiveComposite with random blinking? [unsolved]

#4 Post by DaFool » Sun Apr 29, 2012 3:40 am

SundownKid wrote: I still could use a random number maker to save space.
From one of my really really old porn games, but I think the code still applies today

Code: Select all

# -------------------Character Sprites----------------------

#Katja sprites           

#base pngs

    $ base = Image("katjabase.png")
    $ curiousbase = Image("katjabasecurious.png")
    $ smilebase = Image("katjabasesmiling.png")
    
#eye pngs

    $ eyenormal = Image( "katjalayeyecurious.png")
    $ eyeshift = Image("katjalayeyeshift.png")
    $ eyeblink = Image("katjalayeyeblinking.png")
    $ eyescared = Image("katjalayeyescared.png")
    $ eyesmile = Image("katjalayeyesmiling.png")
    
#composite curious face 3 states of animation

    $ curious = im.Composite((225, 600), (0, 0), "blank.png", (0, 300), base, (0, 300), curiousbase, (0, 300), eyenormal)
    $ curiousblink = im.Composite((225, 600), (0, 0), "blank.png", (0, 300), base, (0, 300), curiousbase, (0, 300), eyeblink)
    $ curiousshift = im.Composite((225, 600), (0, 0), "blank.png", (0, 300), base, (0, 300), curiousbase, (0, 300), eyeshift)
    
#composite smiling face 3 states of animation

    $ smiling = im.Composite((225, 600), (0, 0), "blank.png", (0, 300), base, (0, 300), smilebase, (0, 300), eyenormal)
    $ smilingblink = im.Composite((225, 600), (0, 0), "blank.png", (0, 300), base, (0, 300), smilebase, (0, 300), eyeblink)
    $ smilingshift = im.Composite((225, 600), (0, 0), "blank.png", (0, 300), base, (0, 300), smilebase, (0, 300), eyeshift)
    
#composite non-animated expressions

    $ scared = im.Composite((225, 600), (0, 0), "blank.png", (0, 300), base, (0, 300), curiousbase, (0, 300), eyescared) 
    
#animated curious

    $ kneutral = Character('Katja', color="#000000", ctc=anim.Blink("arrow.png"), window_left_padding=230,
                        show_side_image=anim.SMAnimation( 
    "open", 
    anim.State("open", Image(curious, xalign=0.0, yalign=1.0)), 
    anim.State("close", Image(curiousblink, xalign=0.0, yalign=1.0)), 
    anim.State("shift", Image(curiousshift, xalign=0.0, yalign=1.0)), 
    
    anim.Edge("open", 1.0, "open", prob=4), 
    anim.Edge("shift", 0.3, "shift", prob=2),
    anim.Edge("shift", 0.1, "close"), 
    anim.Edge("open", 0.1, "close"), 
    anim.Edge("close", 0.1, "open") ,
    anim.Edge("close", 0.1, "shift"), 
    )) 
    
#animated smiling    

    $ ksmile = Character('Katja', color="#000000", ctc=anim.Blink("arrow.png"), window_left_padding=230,
                        show_side_image=anim.SMAnimation( 
    "open", 
    anim.State("open", Image(smiling, xalign=0.0, yalign=1.0)), 
    anim.State("close", Image(smilingblink, xalign=0.0, yalign=1.0)), 
    anim.State("shift", Image(smilingshift, xalign=0.0, yalign=1.0)), 
    
    anim.Edge("open", 1.0, "open", prob=4), 
    anim.Edge("shift", 0.3, "shift", prob=2),
    anim.Edge("shift", 0.1, "close"), 
    anim.Edge("open", 0.1, "close"), 
    anim.Edge("close", 0.1, "open") ,
    anim.Edge("close", 0.1, "shift"), 
    )) 
    
#non-animated expressions   

    $ kscared = Character('Katja', color="#000000", ctc=anim.Blink("arrow.png"), window_left_padding=230,
                        show_side_image=Image(scared, xalign=0.0, yalign=1.0))
                        
    $ kthink = Character(None, color="#000000", ctc=anim.Blink("arrow.png"), window_left_padding=20)
    $ kterrified = Character(None, color="#000000", ctc=anim.Blink("arrow.png"), window_left_padding=20, what_slow_cps=20)
    $ kmono = Character('Katja', color="#000000", ctc=anim.Blink("arrow.png"), window_left_padding=20)

User avatar
SundownKid
Lemma-Class Veteran
Posts: 2299
Joined: Mon Feb 06, 2012 9:50 pm
Completed: Icebound, Selenon Rising Ep. 1-2
Projects: Selenon Rising Ep. 3-4
Organization: Fastermind Games
Deviantart: sundownkid
Location: NYC
Contact:

Re: LiveComposite with random blinking? [unsolved]

#5 Post by SundownKid » Sun Apr 29, 2012 11:18 pm

That is pretty old, it seems to have been replaced by ATL. Is there a way to do that anim.State stuff (and like, the blink and lip flap in general) with ATL?

curiosity
Newbie
Posts: 6
Joined: Tue Dec 17, 2013 4:48 am
Contact:

Re: Lip flap and random blinking with ATL? [unsolved]

#6 Post by curiosity » Tue Dec 17, 2013 4:52 am

Maybe try adding "repeat" under image girl eyes normal. That worked for me.

User avatar
SundownKid
Lemma-Class Veteran
Posts: 2299
Joined: Mon Feb 06, 2012 9:50 pm
Completed: Icebound, Selenon Rising Ep. 1-2
Projects: Selenon Rising Ep. 3-4
Organization: Fastermind Games
Deviantart: sundownkid
Location: NYC
Contact:

Re: Lip flap and random blinking with ATL? [unsolved]

#7 Post by SundownKid » Tue Dec 17, 2013 6:40 am

I recently figured it out actually, so you can feel free to let this thread die. The relevant code is now in the Cookbook.

(But you're right, I forgot repeat - added to the code).

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot]