First-person blinking effect?

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
Rosstin2
Veteran
Posts: 253
Joined: Thu Jan 09, 2014 12:42 pm
Completed: King's Ascent, Kitty Love
Projects: Queen At Arms, Rex Rocket
Organization: Aqualuft Games
Contact:

First-person blinking effect?

#1 Post by Rosstin2 »

Sorry I keep asking these, I wish we had better search functions or TOCs. When I search for this, I keep finding things about character expression code.

I'm dead certain I saw someone post a very nice "blinking" effect a month or so ago, in the Cookbook, Creator Discussion, or Ren'Py Questions, I forget. The kind where it simulates a first-person human eye? I'm looking for a nice effect like that for Queen.

To be clear, I mean something like this: http://www.youtube.com/watch?v=bhVDvl7GxZI

More detailed search with better terms, I'm finding some stuff:
http://lemmasoft.renai.us/forums/viewto ... =8&t=23300
http://lemmasoft.renai.us/forums/viewto ... =8&t=24541
Image

Asceai
Eileen-Class Veteran
Posts: 1258
Joined: Fri Sep 21, 2007 7:13 am
Projects: a battle engine
Contact:

Re: First-person blinking effect?

#2 Post by Asceai »

Use an ImageDissolve transition. Multiply a vertical 0->1->0 gradient with a circular 0->1 gradient for your control image, then transition to / from black. The eye open animation should have reverse=False, the eye close animation should have reverse=True.

Asceai
Eileen-Class Veteran
Posts: 1258
Joined: Fri Sep 21, 2007 7:13 am
Projects: a battle engine
Contact:

Re: First-person blinking effect?

#3 Post by Asceai »

It's a pretty hard effect to get quite right, but here is my attempt, just to give you a general idea. Someone not as inept at image manipulation would probably do a 10x better job.

Code: Select all

init python:
  def eyewarp(x):
    return x**1.33
  eye_open = ImageDissolve("eye.png", .5, ramplen=128, reverse=False, time_warp=eyewarp)
  eye_shut = ImageDissolve("eye.png", .5, ramplen=128, reverse=True, time_warp=eyewarp)
image black:
  Solid("#000")
image white:
  Solid("#FFF")

label start:
    scene black
    "Asleep"
    scene white
    with eye_open
    "Awake"
    scene black
    with eye_shut
    "Asleep"
    return
Attachments
eye.png

Asceai
Eileen-Class Veteran
Posts: 1258
Joined: Fri Sep 21, 2007 7:13 am
Projects: a battle engine
Contact:

Re: First-person blinking effect?

#4 Post by Asceai »

Played around some more- this one is a little better:
Attachments
eye.png

User avatar
Rosstin2
Veteran
Posts: 253
Joined: Thu Jan 09, 2014 12:42 pm
Completed: King's Ascent, Kitty Love
Projects: Queen At Arms, Rex Rocket
Organization: Aqualuft Games
Contact:

Re: First-person blinking effect?

#5 Post by Rosstin2 »

Wow, this is really good, Asc!

I meant to delete this topic after I necroed the other one... sorry forum gods ^_^;
Image

crimsonnight
Veteran
Posts: 298
Joined: Fri Apr 20, 2012 4:44 am
Contact:

Re: First-person blinking effect?

#6 Post by crimsonnight »

Asceai wrote:It's a pretty hard effect to get quite right, but here is my attempt, just to give you a general idea. Someone not as inept at image manipulation would probably do a 10x better job.

Code: Select all

init python:
  def eyewarp(x):
    return x**1.33
  eye_open = ImageDissolve("eye.png", .5, ramplen=128, reverse=False, time_warp=eyewarp)
  eye_shut = ImageDissolve("eye.png", .5, ramplen=128, reverse=True, time_warp=eyewarp)
image black:
  Solid("#000")
image white:
  Solid("#FFF")

label start:
    scene black
    "Asleep"
    scene white
    with eye_open
    "Awake"
    scene black
    with eye_shut
    "Asleep"
    return
Sorry, I know this topic is old - I'd love to use this effect in my game but I'm getting the following error when trying to use this code:

Code: Select all

I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.


File "game/script.rpy", line 153: expected an indented block
    return x**1.33
          ^
    

Ren'Py Version: Ren'Py 6.99.12.1912
How do I correct it?
alwaysthesamebluesky.com

User avatar
Donmai
Eileen-Class Veteran
Posts: 1958
Joined: Sun Jun 10, 2012 1:45 am
Completed: Toire No Hanako, Li'l Red [NaNoRenO 2013], The One in LOVE [NaNoRenO 2014], Running Blade [NaNoRenO 2016], The Other Question, To The Girl With Sunflowers
Projects: Slumberland
Location: Brazil
Contact:

Re: First-person blinking effect?

#7 Post by Donmai »

As the error is telling you. Check the indentation. Asceai's example code uses two spaces for indentation. It works, but if you mix it with another piece of code that uses a different indentation, you may have problems. Try 4-spaces indentation, for example:

Code: Select all

init python:
    def eyewarp(x):
        return x**1.33
    eye_open = ImageDissolve("eye.png", .5, ramplen=128, reverse=False, time_warp=eyewarp)
    eye_shut = ImageDissolve("eye.png", .5, ramplen=128, reverse=True, time_warp=eyewarp)
image black:
    Solid("#000")
image white:
    Solid("#FFF")

label start:
    scene black
    "Asleep"
    scene white
    with eye_open
    "Awake"
    scene black
    with eye_shut
    "Asleep"
    return
Does it work for you?
BTW, if you want to use this effect to simulate someone falling asleep and awakening, it would be better to change the .5 value to something like 1.0 or 2.0.
Image
No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)

crimsonnight
Veteran
Posts: 298
Joined: Fri Apr 20, 2012 4:44 am
Contact:

Re: First-person blinking effect?

#8 Post by crimsonnight »

Donmai wrote:As the error is telling you. Check the indentation. Asceai's example code uses two spaces for indentation. It works, but if you mix it with another piece of code that uses a different indentation, you may have problems. Try 4-spaces indentation, for example:

Code: Select all

init python:
    def eyewarp(x):
        return x**1.33
    eye_open = ImageDissolve("eye.png", .5, ramplen=128, reverse=False, time_warp=eyewarp)
    eye_shut = ImageDissolve("eye.png", .5, ramplen=128, reverse=True, time_warp=eyewarp)
image black:
    Solid("#000")
image white:
    Solid("#FFF")

label start:
    scene black
    "Asleep"
    scene white
    with eye_open
    "Awake"
    scene black
    with eye_shut
    "Asleep"
    return
Does it work for you?
BTW, if you want to use this effect to simulate someone falling asleep and awakening, it would be better to change the .5 value to something like 1.0 or 2.0.
Thanks, I think I was being an idiot, I've got it working now... only it isn't what I hoped for. There doesn't seem to be any actual blinking :(
My aim is to create an effect of someone blinking rapidly a few times, for example after being exposed to a bright light - maybe I should start a new thread?
alwaysthesamebluesky.com

redeyedangel01
Newbie
Posts: 1
Joined: Mon May 28, 2018 7:04 pm
Contact:

Re: First-person blinking effect?

#9 Post by redeyedangel01 »

Asceai wrote: Mon Mar 17, 2014 7:28 pm It's a pretty hard effect to get quite right, but here is my attempt, just to give you a general idea. Someone not as inept at image manipulation would probably do a 10x better job.

Code: Select all

init python:
  def eyewarp(x):
    return x**1.33
  eye_open = ImageDissolve("eye.png", .5, ramplen=128, reverse=False, time_warp=eyewarp)
  eye_shut = ImageDissolve("eye.png", .5, ramplen=128, reverse=True, time_warp=eyewarp)
image black:
  Solid("#000")
image white:
  Solid("#FFF")

label start:
    scene black
    "Asleep"
    scene white
    with eye_open
    "Awake"
    scene black
    with eye_shut
    "Asleep"
    return
I'm aware that this thread is super old but i was wondering if i might have your permission in using this code for my game?
I just starting learning renpy recently.
and if on the off-chance that i make profit off of my game in the future i really need your permission to use the code before i can use it in good faith.

User avatar
richycapy
Regular
Posts: 56
Joined: Mon May 27, 2019 8:53 pm
Organization: EN Productions
Location: Mexico
Contact:

Re: First-person blinking effect?

#10 Post by richycapy »

Amazing animation!! Congrats!!

User avatar
Treladon
Regular
Posts: 40
Joined: Sat Dec 31, 2016 3:20 pm
Projects: ToMaG, Feinted Game
Organization: Kuehler-Corrada Productions
Deviantart: Journie
Contact:

Re: First-person blinking effect?

#11 Post by Treladon »

I know it's been a while since this was posted, but for anyone who ends up here (like I did) I wanted to post what I ended up doing as well. Another option if you like.

I wanted to player to see main character blinking a few times over the background (like they're waking up, trying to clear their vision, etc.), so what I did was add a blank png to my images folder as well as this half-closed eye background attached (a plain black background will do basically the same thing).
eye.png
*Not sure if this attached png will actually have any transparency on LemmaSoft, so you may have to make your own.

Then I created this transform:

Code: Select all

transform blink:
        "eye.png" 
        alpha 1.0
        .1
        alpha 0.0
        .2
        alpha 1.0
        .1
        alpha 0.0
        .7
        alpha 1.0
        .1
        alpha 0.0  
I added the blank png as a background image at the beginning of the script:

Code: Select all

image blank = "blank.png"
Then every time I want the player to blink a few times, I write:

Code: Select all

show blank at blink
WIP: The Tasks of Messengers and Guardians - Progress Page Here!

User avatar
nyeowmi
Newbie
Posts: 5
Joined: Thu Oct 27, 2022 11:10 pm
Projects: Never Ending Love
Discord: nyeowmi#6969
Contact:

Re: First-person blinking effect?

#12 Post by nyeowmi »

Sorry to like reawaken this topic since it's pretty much dead but I figured out a smoother way of making the blink transition work?

Image

Basically took treladon's idea and made it complicated loool but what I did was have three images instead of one: eye closed, eye half open and eye open. (Figured posting it on imgur would keep the transparency)

That's the only difference loool but it ended up looking exactly how I wanted it and it felt smoother too. I included two codes: one for the long blink that I use in my game and the second one is a short blink you can have repeat as many times as you want.

Code: Select all

transform blink:
    "eye-half.png"
    .1
    "eye-close.png" 
    .1
    "eye-opehn.png"
    .2
    "eye-half.png"
    .1
    "eye-close.png"
    .1
    "eye-opehn.png"
    .2
    "eye-half.png"
    .1
    "eye-close.png"
    .1
    "eye-opehn.png"
    alpha 0.0

Code: Select all

    "eye-half.png"
    .1
    "eye-close.png"
    .1
    "eye-opehn.png"
    alpha 0.0
You would basically call it the same exact way treladon put in their reply!

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]