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
Message
Author
User avatar
Andredron
Veteran
Posts: 340
Joined: Thu Dec 28, 2017 2:37 pm
Location: Russia
Contact:

Scroll any, not even seamless background

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

Image

Download - http://renpyfordummies.blogspot.com/201 ... 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

init:
    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
        repeat
    transform scroll_in2 (delay = 10.0):
        xpos config.screen_width
        pause delay
        linear delay xpos 0
        repeat
    transform scroll_out (delay = 10.0):
        xpos 0
        linear delay xpos -config.screen_width
        pause delay
        repeat
    transform scroll_out2 (delay = 10.0):
        xpos config.screen_width
        pause delay
        xpos 0 xzoom -1.0
        linear delay xpos -config.screen_width
        repeat

init python:
    # function combines transformations
    # displays
    def _scroll (img, effect = None, delay = 10.0):
        renpy.show (img + "1", what = ImageReference (img), at_list = [scroll_in (delay)])
        renpy.show (img + "2", what = ImageReference (img), at_list = [scroll_out (delay)])
        renpy.show (img + "3", what = ImageReference (img), at_list = [scroll_in2 (delay)])
        renpy.show (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
    return
    
I know, I'm writing terribly in English.

I'm writing a Renpy textbook (in Russian). https://yadi.sk/d/ZX_DonP63USRru Update 22.06.18

Honest Critique

Post Reply

Who is online

Users browsing this forum: No registered users