How to create VN with time-based concept?

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
Vendor_Honyaku
Regular
Posts: 30
Joined: Thu Apr 09, 2009 8:31 am
Projects: Honyaku-Subs translations
Location: Russia, Novosibirsk
Contact:

How to create VN with time-based concept?

#1 Post by Vendor_Honyaku »

Hello again.

At this time, i encountered with slightly non-standard task: Creating novel which based on actions with defined start and end time (like subtitles). Rather like concept used in School Days VN.

How to correctly realize that? Maybe someone created something like this?
The bear looked on the car, and there was a wild gleam in his eyes. He knew what to do.

User avatar
PyTom
Ren'Py Creator
Posts: 16096
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: How to create VN with time-based concept?

#2 Post by PyTom »

You'll have to use some python to handle the timing, but it's not very hard. here's my example. (You can drop this into the tutorial game.)

Code: Select all


init python:

    # Pull in the time module.
    import time

    # The base time that's used for the timed_say system.
    base_time = None
    
    # This is the character that's used to speak the lines of dialogue.
    timed_speaker = Character(None,
                              what_size=28,
                              what_outlines=[(3, "#0008", 2, 2), (3, "#228", 0, 0)],
                              what_layout="subtitle",
                              what_xalign=0.5,
                              what_text_align=0.5,
                              window_background=None,
                              window_yminimum=0,
                              window_xfill=False,
                              window_xalign=0.5)
    
    # This function waits until start seconds after base time, then
    # displays what until end time is reached.
    def timed_say(start, end, what, *args, **kwargs):
        ui.pausebehavior(start - (time.time() - base_time))
        ui.interact()

        timed_speaker(what, interact=False)
        ui.pausebehavior(end - (time.time() - base_time))
        ui.interact()

    ts = renpy.curry(timed_say)

Code: Select all

    "..."

    show movie
    play movie "shuttle.ogv"
    
    $ base_time = time.time()
    
    ts(0, 1) "T minus Ten"

    ts(1, 2) "Nine"

    ts(2, 3) "Eight"

    ts(3, 4) "Seven"

    ts(4, 5.5) "Main Engine Start"

    ts(5.5, 6.5) "Five"

    ts(6.5, 7.5) "Four"

    ts(7.5, 8.5) "Three"

    ts(8.5, 9.5) "Two"

    ts(9.5, 10.5) "One"

    ts(10.5, 13) "And liftoff of Space Shuttle Atlantis"
    
    stop movie
    
    "..."
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

Vendor_Honyaku
Regular
Posts: 30
Joined: Thu Apr 09, 2009 8:31 am
Projects: Honyaku-Subs translations
Location: Russia, Novosibirsk
Contact:

Re: How to create VN with time-based concept?

#3 Post by Vendor_Honyaku »

Wow, perfect example. Thanks.
The bear looked on the car, and there was a wild gleam in his eyes. He knew what to do.

User avatar
unknown5
Veteran
Posts: 311
Joined: Tue Apr 20, 2010 1:41 pm
Completed: (see sig)
Projects: slit-mouth girl, purifier, etc.
Contact:

Re: How to create VN with time-based concept?

#4 Post by unknown5 »

ack, i shoulda searched first before trying to code this. QQ i wanted to try to synchronize lyrics to music / multiple songs. this is what i came up with. it works, but i'm still learning ren'py, so i was wondering if there was anything i could do to improve the code, or if it's alright? (i'm worried it might blow up on me) (i'm a noob at programming so stuff like renpy.curry scare me, heheheh) (also, i think i remember seeing something like this on the forums before, but i can't remember where it was =()

Code: Select all

    $ lyrics_illurock = ["", "doop dee daa", "bop", "doop dee dee", "da da dun bowow", 
    "beow waa waa", "boppa ba wum", "doop dee weow", "bop", "doop dee dee", 
    "doop dee wum", "bowow ba wum", "bee bee bee", "doop dee wum", "bop",
    "doop dee dee", "17", "18", "19", "20",
    "bom bom bom"]
    $ timing_illurock = [0, 0, 1.5, 2, 3.25, 
        5, 6, 7.5, 9, 10,
        12, 14, 15, 16, 17.5, 
        18, 19.5, 21.5, 24, 26,
        27]

    python:
        def musicwithwords(lyrics, timing):
            song_end = len(lyrics)
            for i in range(1, song_end):
                renpy.pause(timing[i] - timing[i-1])    
                ui.text(lyrics[i], xalign=0.5, yalign=0.8)
            renpy.pause(4.0)              

Code: Select all

    play sound "illurock.ogg"
    $ musicwithwords(lyrics_illurock, timing_illurock)
Image
information wants to be free, yo.

Post Reply

Who is online

Users browsing this forum: No registered users