A newer version of the layered parallax in this thread. This code is based on the "Ren'Py How To: parallax camera and 'drunken' blur" devlog by Midge on Itch, with some QOL adjustments and the addition of an easing factor by me.
Code: Select all
default persistent.parallax = True #Add a toggle in your settings! Your players will appreciate it.
transform parallax:
perspective True
subpixel True
function moving_camera
# Distances (define more transforms as needed).
transform near:
truecenter()
ypos int(config.screen_height*0.528) #shifting the image downwards a bit so the parallax effect doesnt show its cutoff
transform far:
truecenter()
zzoom True
zpos -750
# Setting our images to be near by default, and bgs as far.
define config.default_transform = near
define config.tag_transform = {"bg" : far}
# Moving camera logic
init python:
def moving_camera(trans, st, at):
if persistent.parallax:
x, y = renpy.display.draw.get_mouse_pos()
parallax_factor = 0.055
target_xoffset = (x - config.screen_width / 2) * parallax_factor
target_yoffset = (y - config.screen_height / 2) * parallax_factor
easing_factor = 0.055 #closer to 0 = slower, closer to 1 = faster, with 1 being no ease
trans.xoffset += (target_xoffset - trans.xoffset) * easing_factor
trans.yoffset += (target_yoffset - trans.yoffset) * easing_factor
else:
trans.xoffset = 0
trans.yoffset = 0
return 0
Code: Select all
camera at parallax