I fiddled around and now have this:
Code: Select all
init python:
mapxsize = 5000
mapysize = 4406
mapfactor = float(config.screen_height)/ mapysize
dummypos = (2100, 1700)
image mapsheet:
"map.jpg"
transform mapzoom:
xalign 0.5
yalign 0.5
zoom mapfactor
pause 3.0
ease 5.0 zoom 1.0
screen mapscreen(x, y):
viewport id "worldmap":
draggable True
edgescroll (50, 500)
xinitial x
yinitial x
add "mapsheet" at mapzoom
# The game starts here.
label start:
$ a = max(0, min(dummypos[0]-(config.screen_width/2), mapxsize-config.screen_width))
$ b = max(0, min(dummypos[1]-(config.screen_height/2), mapysize-config.screen_height))
e "You've created a new Ren'Py game."
call screen mapscreen(a, b)
return
The viewport now zooms in to the right spot, but on the way there it jumps wildly around because it seems it tries to keep the exact initial coordinates in its focus, which are of course off-image at first because the image is zoomed out, and as it's zoomed in and becomes large enough to have those coordinates the viewport moves there, resulting in awkward movement instead of zooming straight onto that spot.
Using floats as initials only makes it zoom to (0, 0).
My next idea was to make the initials dynamic:
Code: Select all
init python:
mapxsize = 5000
mapysize = 4406
mapfactor = float(config.screen_height)/ mapysize
dummypos = (2100, 1700)
def dynamicinitial(a):
bounds = renpy.get_image_bounds("mapsheet", layer='screens')
if a == 0:
return bounds[2]
else:
return bounds[3]
image mapsheet:
"map.jpg"
subpixel True
transform mapzoom:
zoom mapfactor
pause 3.0
ease 5.0 zoom 1.0
screen mapscreen(x, y):
viewport id "worldmap":
draggable True
edgescroll (50, 500)
add "mapsheet" at mapzoom
xinitial dynamicinitial(0)
yinitial dynamicinitial(1)
label start:
$ a = max(0, min(dummypos[0]-(config.screen_width/2), mapxsize-config.screen_width))
$ b = max(0, min(dummypos[1]-(config.screen_height/2), mapysize-config.screen_height))
e "You've created a new Ren'Py game."
call screen mapscreen(a, b)
return
But whatever I do, I always get "None" returned from renpy.get_image_bounds. The image doesn't seem to exist on any layer.
I tried currying the function:
Code: Select all
screen mapscreen(x, y):
$ curryinitial = renpy.curry(dynamicinitial)
viewport id "worldmap":
draggable True
edgescroll (50, 500)
add "mapsheet" at mapzoom
xinitial curryinitial(0)
yinitial curryinitial(1)
But this gives me this error:
While running game code:
File "game/script.rpy", line 50, in script
call screen mapscreen(a, b)
File "renpy/common/000statements.rpy", line 426, in execute_call_screen
store._return = renpy.call_screen(name, *args, **kwargs)
TypeError: unsupported operand type(s) for *: 'int' and 'Curry'
Different question: Can I put condition switches into a transform? Like so:
Code: Select all
transform mapzoom(x=-1, y=-1):
xalign 0.5
yalign 0.5
zoom mapfactor
if x, y >= 0:
pause 3.0
ease 1.0 zoom 1.0 xalign x yalign y
If I do this, I get an indentation error for "pause 3.0" instead.
So please, if anybody can help me here I would be very happy. As you can see, I already tried a lot of things and nothing worked.