renpy/doc/cookbook/Double Vision

From Ren'Py

Jump to: navigation, search

Double Vision Effect

The following code produces a blurred "double vision" effect. This was used in the games Gakuen Redux and Secretary of Death.

The basic idea is that you create a half-opaque version of the background, and then show it at a random location after showing the background. That means that unlike many effects, invoking this effect during your story requires two statements, not just one.

init:

    image cs2 = Image("b_city_scape_02.gif")
    image cs2alpha = im.Alpha("b_city_scape_02.gif", 0.5)

    python hide:

        def gen_randmotion(count, dist, delay):

            import random

            args = [ ]

            for i in range(0, count):
                args.append(anim.State(i, None,
                                       Position(xpos=random.randrange(-dist, dist),
                                                ypos=random.randrange(-dist, dist),
                                                xanchor='left',
                                                yanchor='top',
                                                )))

            for i in range(0, count):
                for j in range(0, count):

                    if i == j:
                        continue

                    args.append(anim.Edge(i, delay, j, MoveTransition(delay)))

            return anim.SMAnimation(0, *args)

        store.randmotion = gen_randmotion(5, 5, 1.0)

label start:

    scene cs2
    show cs2alpha at randmotion

    "Presented in DOUBLE-VISION (where drunk)."

In this code, the statements which actually produce the effect during the story are:

    scene cs2
    show cs2alpha at randmotion

As you may have noticed, for every image that you want to show in double vision, you'll have to create two images for it as well. In the code above, these are the lines which create the images (note that like all image statements, they must be placed in an init block):

    image cs2 = Image("b_city_scape_02.gif")
    image cs2alpha = im.Alpha("b_city_scape_02.gif", 0.5)
Personal tools