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

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
User avatar
Kinmoku
Miko-Class Veteran
Posts: 560
Joined: Mon Aug 11, 2014 9:39 am
Completed: One Night Stand
Projects: Love IRL, Memories
Tumblr: gamesbykinmoku
itch: kinmoku
Location: Germany
Contact:

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

#1 Post by Kinmoku » Wed Feb 26, 2020 11:39 am

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
Last edited by Kinmoku on Fri Feb 28, 2020 7:15 am, edited 1 time in total.

rames44
Veteran
Posts: 232
Joined: Sun May 29, 2016 4:38 pm
Contact:

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

#2 Post by rames44 » 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.

User avatar
Kinmoku
Miko-Class Veteran
Posts: 560
Joined: Mon Aug 11, 2014 9:39 am
Completed: One Night Stand
Projects: Love IRL, Memories
Tumblr: gamesbykinmoku
itch: kinmoku
Location: Germany
Contact:

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

#3 Post by Kinmoku » Fri Feb 28, 2020 6:26 am

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!

User avatar
Kinmoku
Miko-Class Veteran
Posts: 560
Joined: Mon Aug 11, 2014 9:39 am
Completed: One Night Stand
Projects: Love IRL, Memories
Tumblr: gamesbykinmoku
itch: kinmoku
Location: Germany
Contact:

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

#4 Post by Kinmoku » Fri Feb 28, 2020 7:15 am

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

rames44
Veteran
Posts: 232
Joined: Sun May 29, 2016 4:38 pm
Contact:

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

#5 Post by rames44 » Fri Feb 28, 2020 12:54 pm

Ah. “edgescroll”. Didn’t know about that, but PyTom always seems to have anticipated our needs...

User avatar
Katy133
Miko-Class Veteran
Posts: 704
Joined: Sat Nov 16, 2013 1:21 pm
Completed: Eight Sweets, The Heart of Tales, [redacted] Life, Must Love Jaws, A Tune at the End of the World, Three Guys That Paint, The Journey of Ignorance, Portal 2.5.
Projects: The Butler Detective
Tumblr: katy-133
Deviantart: Katy133
Soundcloud: Katy133
itch: katy133
Location: Canada
Contact:

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

#6 Post by Katy133 » Fri Feb 28, 2020 10:54 pm

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?
ImageImage

My Website, which lists my visual novels.
Become a patron on my Patreon!

Post Reply

Who is online

Users browsing this forum: Bing [Bot], span4ev