From 153d21ace9801ac665e2d7f99c967147d1214f29 Mon Sep 17 00:00:00 2001 From: RaindropsSys Date: Sun, 3 Sep 2023 14:39:50 +0200 Subject: Updated 16 files and added 5 files (automated) --- src/helper.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/helper.py') diff --git a/src/helper.py b/src/helper.py index 46f831a..2f4e53e 100644 --- a/src/helper.py +++ b/src/helper.py @@ -70,4 +70,20 @@ def get_chunk_regions(chunks): "range": (16 * x, 16 * y, 15 + 16 * x, 15 + 16 * y) }) - return data \ No newline at end of file + return data + +def get_real_mouse(screen): + width = screen.get_size()[0] + height = width / (16/9) + + if width > screen.get_size()[0] or height > screen.get_size()[1]: + height = screen.get_size()[1] + width = height * (16/9) + + offset_x = screen.get_size()[0] / 2 - width / 2 + offset_y = screen.get_size()[1] / 2 - height / 2 + scaling = ((width / 1280) + (height / 720)) / 2 + + pos = pygame.mouse.get_pos() + + return (int((pos[0] - offset_x) / scaling), int((pos[1] - offset_y) / scaling)) -- cgit