Page 1 of 1

[SOLVED] Possible to explore around a scene moving mouse to screen edge?

Posted: Wed Feb 26, 2020 11:39 am
by Kinmoku
Hi all. Is it possible to explore around a scene moving the mouse to the screen edge? I have a couple of long images (one tall, one wide) and I want the player to be able to explore up close - when the mouse goes near the edge of the screen, the "camera" moves with it/ the image pans. I hope I'm making myself clear ^^;

Here's an example. It's a 3D game but shows the cursor behaving how I want:

https://youtu.be/OR7aYCnv4IE?t=4241

Re: Possible to explore around a scene moving mouse to screen edge?

Posted: Wed Feb 26, 2020 12:41 pm
by rames44
I know you could do this with a custom Displayable, but that may be more work than necessary.

What you could try is creating screen with a transparent image button at each edge of the screen and then attach an action to the button’s hovered that will adjust the offset of the background, so that when the mouse gets close enough to the edge, the background starts to scroll. The trick would be writing the action so that it scrolls at a proper rate.

Re: Possible to explore around a scene moving mouse to screen edge?

Posted: Fri Feb 28, 2020 6:26 am
by Kinmoku
rames44 wrote:
Wed Feb 26, 2020 12:41 pm
I know you could do this with a custom Displayable, but that may be more work than necessary.

What you could try is creating screen with a transparent image button at each edge of the screen and then attach an action to the button’s hovered that will adjust the offset of the background, so that when the mouse gets close enough to the edge, the background starts to scroll. The trick would be writing the action so that it scrolls at a proper rate.
Ah, nice work around :wink: I'll give this a go and see how I get on :) Thanks!

Re: Possible to explore around a scene moving mouse to screen edge?

Posted: Fri Feb 28, 2020 7:15 am
by Kinmoku
Having a look around the forums, I found a post that helped me: viewtopic.php?t=34086

Here's my code. It works moving the mouse up or down, or if the mouse wheel is used :) Awesome!

Code: Select all

screen photograph_scroll:
    viewport id "photographs":
        align (0.5, 0.5)
        mousewheel True
        edgescroll (150, 800)
        child_size (1920, 3240)

        add "images/present/photographs.jpg"
I've just set it up for imagebuttons instead of an image. In case anyone is interested:

Code: Select all

screen photograph_scroll:
    viewport id "photographs":
        align (0.5, 0.5)
        mousewheel True
        edgescroll (150, 800)
        child_size (1920, 3240)

        #add "images/present/photographs.jpg"
        
        use photograph_map
    
screen photograph_map:
    add "images/present/photographs.jpg"
    
    imagebutton idle Solid("#0000", xysize=(295, 342)) clicked Play("sound", "sounds/balloon1.ogg") xpos 820 ypos 34 focus_mask None
    imagebutton idle Solid("#0000", xysize=(343, 324)) clicked Play("sound", "sounds/balloon1.ogg") xpos 930 ypos 1372 focus_mask None

Re: [SOLVED] Possible to explore around a scene moving mouse to screen edge?

Posted: Fri Feb 28, 2020 12:54 pm
by rames44
Ah. “edgescroll”. Didn’t know about that, but PyTom always seems to have anticipated our needs...

Re: [SOLVED] Possible to explore around a scene moving mouse to screen edge?

Posted: Fri Feb 28, 2020 10:54 pm
by Katy133
This thread is solved, but this may be additional help to others trying to do this:

Ren'Py comes with a VN you can open called Tutorial. In it, if you select "Screen Displayables," followed by "Viewports" from the menu/index Eileen gives you, you can find an example of "edgescroll" being used. If you open that part of the script in Editra (or whichever script editor you're using), it will help provide you with a method to do the same thing:

Code: Select all

screen edgescroll_viewport_screen():

    viewport:
        xalign 0.5 ypos 50 xysize (700, 300)

        edgescroll (150, 500)
        mousewheel True
        arrowkeys True

        add "bg band"
 
Also, I made a thread asking about how to draw a panoramic (you will need that if you want to turn the "camera" over 180 degrees), which has tips you may find useful. Thread: How to Draw Panoramic Rooms?