I know we're able to scroll a background image hardcoded or using awsd keys(or arrows) if they're pressed. But what about scrolling it with mouse movement? So I have a piece of panoramic image as a background and I wanna embody background transform depending on mouse pos or rel. I came up with mouse.get_rel() pygame function
ultra simplified code snippet:
from pygame import *
screen = display.set_mode((1920, 1080), RESIZABLE)
gx = -12288
gy = -5120
background = image.load(f'Content/Map/Overcast/Overcast_HQ.jpg')
run = True
while run:
for e in event.get():
if e.type == QUIT:
run = False
elif e.type == MOUSEMOTION:
rel = mouse.get_rel()
gx += rel[0]
gy += rel[1]
screen.blit(background, (gx,gy))
display.flip()
but the thing i don't like here is if i move the cursor out of pygame window or if i reach a screen edge no more movement is detected while i'm actually moving a mouse. I need something similar to "mouse locking" when the cursor pos doesn't change (cursor itself dissapears) and player is able to rotate a camera limitlessly as far as his table allows to.