diff --git a/src/gameUtils/utils.py b/src/gameUtils/utils.py index ae75447..2cb4b65 100644 --- a/src/gameUtils/utils.py +++ b/src/gameUtils/utils.py @@ -1,14 +1,22 @@ import pygame -def centre(surface: pygame.Surface, rect: tuple[int, int, int, int]) -> pygame.Surface: +def centre(surface: pygame.Surface, size: tuple[int, int]) -> pygame.Surface: """ Centres a surface within a given rectangle. Args: surface: The surface to be centred. - rect: The rectangle the surface will be centred in. + size: The size of the rectangle the surface will be centred in. Returns: pygame.Surface """ - pass \ No newline at end of file + + surf = pygame.Surface(size) + offX = surf.size[0]//2 - surface.size[0]//2 + offY = surf.size[1]//2 - surface.size[1]//2 + + surf.blit(surface, (offX, offY)) + + return surf + \ No newline at end of file