Ren'Py Is "panorama" game type possible with Renpy?

Deleted member 1121028

Well-Known Member
Dec 28, 2018
1,716
3,308
No sure how to translate that, I mean trying to simulate old point&click adventure like .
May it be by full spherical panorama or just cylindric ones (with no Y axis)?
I tried to dig the question but some posts are very old (nearly 5/6 year)...
It's possible or I should give up on the idea?

C_MuM2UXoAEsw1d.jpg
 

Rich

Old Fart
Modder
Donor
Respected User
Game Developer
Jun 25, 2017
2,566
7,382
It's possible or I should give up on the idea?
Yes, you could certainly do it in Ren'py (it's very powerful if you're willing to dive down). A Creator-Defined Displayable has access to mouse events (so you could detect whether the mouse is sufficiently far enough left or right that you needed to "rotate") and has pretty powerful rendering capabilities. So you could do the "rotating image" by creating a cylindrical projection, and blitting it onto the screen with the correct left-right offset within the CDD, blitting a second copy, if necessary, if the "seam" is showing in the viewport. You'd obviously need to do some math, based on the current rotation, to then figure out what part of the image the mouse is over to determine whether you're hovering over something "clickable."

Essentially, you'd need some Python programming skills to do this.
 

recreation

pure evil!
Respected User
Game Developer
Jun 10, 2018
6,327
22,777
It's (kind of) possible, I made a little test project a while ago that worked simliar, renpy even has a pan function. The problem is that neither spherical, nor cylindrical render work really well with renpy, you'll always have little distortions.
 

recreation

pure evil!
Respected User
Game Developer
Jun 10, 2018
6,327
22,777
It's (kind of) possible, I made a little test project a while ago that worked simliar, renpy even has a pan function. The problem is that neither spherical, nor cylindrical render work really well with renpy, you'll always have little distortions.
Have a look at this thread and the66 might have some tips too, he actually provided a way better version of my own -hacked together- script, with some neat additions.
 

Deleted member 1121028

Well-Known Member
Dec 28, 2018
1,716
3,308
Thank you both for your answers! Some old threads had a categoric "nope impossible" so I didn't really know on which foot to dance. Seems a bit complex tho, but at least I know it's kinda possible. Guess I gonna need to raise my renpy level a little bit.
 

mickydoo

Fudged it again.
Game Developer
Jan 5, 2018
2,446
3,557
Thank you both for your answers! Some old threads had a categoric "nope impossible" so I didn't really know on which foot to dance. Seems a bit complex tho, but at least I know it's kinda possible. Guess I gonna need to raise my renpy level a little bit.
I think I googled the same thing as you a while back and came to the same conclusion, beyond my ability. But I did just to see what would happen, render out a 360 image in Daz and used an online converter to convert it to a movie, the idea being to interact with that movie in renpy to make some type of map. I have not had the time to fuck about with it, but you know food for thought.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,971
16,228
Just for fun, because it's either too slow or not smooth enough, here's how to have a panoramic background :

Code:
init python:
    class panBackground(renpy.Displayable):

        def __init__(self, background, xSpeed=10, ySpeed=10, **kwargs):
            super(panBackground, self).__init__(**kwargs)
            (x, y) = renpy.image_size( background )
            self.xLimit = x - config.screen_width
            self.yLimit = y - config.screen_height
            self.bg = renpy.displayable( background )
            self.xSpeed = xSpeed
            self.ySpeed = ySpeed

        def event(self, ev, x, y, st):
            if x < 0 or y < 0: return None

            if x < 100:                         store.panScreenX = 0 if panScreenX < self.xSpeed else panScreenX - self.xSpeed
            elif x > config.screen_width - 100: store.panScreenX = self.xLimit if panScreenX > self.xLimit - self.xSpeed else panScreenX + self.xSpeed

            if y < 100:                          store.panScreenY = 0 if panScreenY < self.ySpeed else panScreenY - self.ySpeed
            elif y > config.screen_height - 100: store.panScreenY = self.yLimit if panScreenY > self.yLimit - self.ySpeed else panScreenY + self.ySpeed

            renpy.restart_interaction()
            renpy.redraw(self, 0)

        def render(self, width, height, st, at):
            rv = renpy.Render(width, height)
            rv.blit( renpy.render(Crop( (panScreenX, panScreenY, config.screen_width, config.screen_height), self.bg ), width, height, st, at), (0, 0))
            return rv

default panScreenX = 0
default panScreenY = 0

screen panBackground( background ):
    add panBackground( background, xSpeed=5, ySpeed=5 )

label start:
    show screen panBackground( "images/wide.jpg" )
    "And here you put the dialogs, or whatever you want"
Place the mouse near to a border of the screen to scroll the background in this direction.

It's probably possible to have a smooth result by cropping a little larger and adding a transform to make the image move from its actual position to the next one, but I don't have the time to test it right now.

You can even have some clickable on the screen, but you need to make their position depend of panScreenX and panScreenY. Something that should looks like this :
Code:
screen myWildLocation():
    add panBackground( "myWildLocationBackground.jpg" )

    imagebutton:
        auto "myCliackable_%s.png"
        xpos 100 - panScreenX
        ypos 10 - panScreenY
        action NullAction()
 

Gee Nez

New Member
Nov 25, 2020
2
0
Ren'Py Noob Foetus here. Love this forum so far. So, the panorama works for me but can't figure out where to put the clickable code in the second example. I placed it at the end of init as well as tried after start label, show screen. Can't seem to make the clickable png appear. You can probably tell I'm an artist first, confused coder second (third, fourth?...)

Thanks in advance.
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,608
2,256
[...] but can't figure out where to put the clickable code in the second example.

Pretty much anywhere.
At the top of the script.rpy is pretty common. So is adding it to the screens.rpy file. You could create a custom .rpy file for just your personal screens or scripts... or anything in between.

It is not part of the init: or init python: code... so I suppose "not in there" is about as much as you need. Normally it wouldn't be placed after the label start:, but it will work there - it'll just look a little odd to a seasoned developer.

[...] Can't seem to make the clickable png appear.

If I had to guess, you've added the screen definition in full correctly. What I'm guessing you haven't done is asked your game to show it to the player. Each screen: code usually needs to be invoked using either call screen or show screen. The example includes a show screen for the actual panorama, but not one for the second screen which contains the clickable area(s).

Python:
label start:
    show screen panBackground( "images/wide.jpg" )
    show screen myWildLocation()

    "And here you put the dialogs, or whatever you want"
... could be one solution.

But I think where this should probably be heading is to actually merge both example screens together into a single screen, like...

Python:
# blah, blah -- removed all the other code for brevity, but it would still be needed.

screen panBackground( background ):
    add panBackground( background, xSpeed=5, ySpeed=5 )

    imagebutton:
        auto "myCliackable_%s.png"
        xpos 100 - panScreenX
        ypos 10 - panScreenY
        action NullAction()

Your guess is as good as mine as to whether it really is that simple, since I'm not sure if that imagebutton: will dynamically move as the image panning occurs.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,971
16,228
If I had to guess, you've added the screen definition in full correctly. What I'm guessing you haven't done is asked your game to show it to the player.
I have another guess to suggest.

"myClickable_%s.png" have to be replaced by the name of the clickable image you'll use ; or, for the test, you've to make a file named according to this.
And in both case, it have to follow the syntax, so there should be at least a file named "myClickable_idle.png".
 
  • Like
Reactions: Richday

Gee Nez

New Member
Nov 25, 2020
2
0
Sorry for such a late reply. Work, fam, Covid testing, etc. I didn't even realize the helpful peeps at f95zone came to my rescue.
Welp, it worked like a charm. Thank you and I wish you happy holidays, AON and 79flavors! Couldn't done it without you.