Scroll any, not even seamless background

A place for Ren'Py tutorials and reusable Ren'Py code.
Forum rules
Do not post questions here!

This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
Post Reply
User avatar
Posts: 340
Joined: Thu Dec 28, 2017 2:37 pm
Location: Russia

Scroll any, not even seamless background

#1 Post by Andredron » Fri Mar 15, 2019 8:58 am


Download - ... t.html?m=1

How to scroll with arbitrary speed any background and still make it seamless? Very simple:
mirror and dock the same sides
example for moving left

Code: Select all

    image sky = "images / sky.jpg"
    #transformations for moving and mirroring
    transform scroll_in (delay = 10.0):
        xpos config.screen_width xzoom -1.0
        linear delay xpos 0
        pause delay
    transform scroll_in2 (delay = 10.0):
        xpos config.screen_width
        pause delay
        linear delay xpos 0
    transform scroll_out (delay = 10.0):
        xpos 0
        linear delay xpos -config.screen_width
        pause delay
    transform scroll_out2 (delay = 10.0):
        xpos config.screen_width
        pause delay
        xpos 0 xzoom -1.0
        linear delay xpos -config.screen_width

init python:
    # function combines transformations
    # displays
    def _scroll (img, effect = None, delay = 10.0): (img + "1", what = ImageReference (img), at_list = [scroll_in (delay)]) (img + "2", what = ImageReference (img), at_list = [scroll_out (delay)]) (img + "3", what = ImageReference (img), at_list = [scroll_in2 (delay)]) (img + "4", what = ImageReference (img), at_list = [scroll_out2 (delay)])
        renpy.with_statement (effect)
    def _hide (img, effect = None):
        renpy.hide (img + "1")
        renpy.hide (img + "2")
        renpy.hide (img + "3")
        renpy.hide (img + "4")
        renpy.with_statement (effect)
# all, now you can anywhere in the script
# one line display moving seamless pattern
label start:
    scene black
    # display (parameters can be omitted)
    $ _scroll ("sky", Dissolve (2.0), 15)
    pause # enjoy the clouds
    # now hide our running pictures
    $ _hide ("sky", Dissolve (2.0))
    pause .5
I know, I'm writing terribly in English.

I'm writing a Renpy textbook (in Russian). Update 22.06.18

Honest Critique

Post Reply

Who is online

Users browsing this forum: No registered users