Scrolling image - tearing my hair out!

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
RewindTheGame
Regular
Posts: 62
Joined: Thu Dec 31, 2020 3:37 pm
Contact:

Scrolling image - tearing my hair out!

#1 Post by RewindTheGame »

Hello all,

I'm tearing my hair out on this one, because it just seems to be one of those things where it's not even obvious what I would search for to find the answer and everything I do search for just gives me incomprehensible code or isn't what I'm looking for. So...

In a lot of games, an image is displayed which is larger vertically than the screen. The screen starts off displaying the very top of the image, scrolls down smoothly to the bottom and then the game continues. I'm assuming this is something to do with viewports, but beyond forum posts saying "you need a viewport", pointing at the online manual for viewports, or somesuch, I find nothing helpful :(. Considering this is a feature in so many games, I'm surprised I can't find a simple cut-and-paste example where I just plug in my own image and it does it out of the box. Then I could learn from reading the code. So how do I do this?

I'm currently writing a science fiction game based on my book, and I would like to introduce new characters as large vertical portrait images twice the height of the screen which scroll from top to bottom. Where do I start?

Thanks in advance, while I still have some hair left :)

User avatar
RicharDann
Veteran
Posts: 286
Joined: Thu Aug 31, 2017 11:47 am
Contact:

Re: Scrolling image - tearing my hair out!

#2 Post by RicharDann »

No need to use a viewport unless you need to manually scroll screen elements, if you just need to show an image that scrolls up slowly on its own you can achieve a similar effect with ATL (Animation and Transformation Language):

Code: Select all

transform character_intro():
    
    zoom 2.
    xalign .5
    yalign 0.
    
    linear 5 yalign 1.
    
image silvie = "silvie.png"

label start:
    
    show silvie at character_intro
The most important step is always the next one.

User avatar
_ticlock_
Miko-Class Veteran
Posts: 910
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

Re: Scrolling image - tearing my hair out!

#3 Post by _ticlock_ »

Hi, RewindTheGame,

EDIT:
RicharDann posted the answer before I finished typing. Anyway, here is another way for a large image(bigger than screen size to avoid scaling)

Code: Select all

image large_img:
    contains:
        Solid("#f00",xysize=(1280,500))
    contains:
        ypos 500
        Solid("#0f0",xysize=(1280,500))
    contains:
        ypos 1000
        Solid("#00f",xysize=(1280,500))

transform move_down:
    ypos 0
    linear 5.0 ypos -780


label start:
    show large_img at move_down
    pause 5.0
    "Test"
If you want to ensure that your image is shown at the bottom, when the player clicks or uses skip you can add this:

Code: Select all

label start:
    show large_img at move_down
    pause 5.0
    show large_img:
        ypos -780
    "Test"

User avatar
RicharDann
Veteran
Posts: 286
Joined: Thu Aug 31, 2017 11:47 am
Contact:

Re: Scrolling image - tearing my hair out!

#4 Post by RicharDann »

As pointed out by _ticlock_ (Good catch!) you don't need to use zoom if your image is already larger than the screen, I only used it for testing since I didn't have a bigger image handy. The effect is achieved through the linear (or ease) statement, so that's the one you'll want to specially look into.
The most important step is always the next one.

RewindTheGame
Regular
Posts: 62
Joined: Thu Dec 31, 2020 3:37 pm
Contact:

Re: Scrolling image - tearing my hair out!

#5 Post by RewindTheGame »

Thank you both so much. Back to coding :)

I think the problem with modern languages isn't so much that they lack any way of doing something - it's more that they no longer come with a 2000 page set of books that actually tell you how to do it. I'd quite happily pay for a printed manual I could place on my desk and flick through at will. Bloody online documents :)

I'll be announcing my game shortly and posting updates and screenshots. It'll probably be a bit on the large side (eventually) considering it's based on a series of 3 scriptbooks each of which contains the scripts for 3x2 hour episodes set in a parody dystopian future. Expect British humour.

RewindTheGame
Regular
Posts: 62
Joined: Thu Dec 31, 2020 3:37 pm
Contact:

Re: Scrolling image - tearing my hair out!

#6 Post by RewindTheGame »

Just a quick note to say that I've now tried this and it works perfectly. I'm assuming, of course, that Daz Studio knows how to output a 1920x2160 image - because if not, it's going to be fun stitching images together in Photoshop. Thanks again.

Post Reply

Who is online

Users browsing this forum: Andredron