renpy/doc/cookbook/Ambience generator

From Ren'Py

Jump to: navigation, search

How to add ambient noises to your game for greater immersion

Quite simple, really. With a function that generates a playlist of ambient noises mixed with periods of silence. Requires a 5 second silent ogg as well.

# This goes in init block
    python:
        def ambient(songlist, interval):
            playlist = ["sounds/pause_5s.ogg"]
            for song in songlist:
                playlist.append(song)
                j = renpy.random.randint(2, interval)
                for i in range(0, j):
                    playlist.append("sounds/pause_5s.ogg")
            return renpy.music.play(playlist, channel=6)

# This is used a the beginning of label, as the most logical place for ambient noises to begin.. :P
$ ambient(("sounds/ambient02.ogg","sounds/ambient06.ogg","sounds/ambient09.ogg"), 4)

Here's the .ogg file Media:pause_5s.zip

Personal tools