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.
- Per K Grok
- Miko-Class Veteran
- Posts: 630
- Joined: Fri May 18, 2018 1:02 am
- Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1
- Projects: Defenders of Adacan Part 2
- Deviantart: pekj
- itch: per-k-grok
- Location: Sverige
Sounds like you are looking for parallax scrolling.
You can find one thread on that subject here.
viewtopic.php?f=51&t=47482&p=499707&hil ... ax#p499707
Some time ago, PyTom made some code for a displayable that follows the mouse cursor in response to a thread, and then Lena_Borodach modified it so that it moves slower in order for someone to be able to use it as a parallax background. I added a few changes of my own (separating "factor" into xfactor and yfactor, since i didn't want the horizontal and vertical movement to be the same speed.)
Code: Select all
init python: class ParallaxBackground(renpy.Displayable): def __init__(self, child): super(ParallaxBackground, self).__init__() self.child = renpy.displayable(child) self.x = None self.y = None def render(self, width, height, st, at): rv = renpy.Render(width, height) if self.x is not None: cr = renpy.render(self.child, width, height, st, at) cw, ch = cr.get_size() xfactor = -27 # this is how much your image will move horizontally. I added the negative because this way, the area the mouse moves to will be more visible to the player, rather than the opposite. yfactor = -15 # this is how much your image will move vertically csw,csh = (config.screen_width,config.screen_height) cx = (self.x-csw/2)*xfactor/csw-cw/2 cy = (self.y-csh/2)*yfactor/csh-ch/2 rv.blit(cr, (cx,cy)) return rv def event(self, ev, x, y, st): if (x != self.x) or (y != self.y): self.x = x self.y = y renpy.redraw(self, 0)