From e97d55fbc3cdf8f52b7fe57dc2c70cac45cf2499 Mon Sep 17 00:00:00 2001 From: Brosef Date: Thu, 19 Jun 2025 21:23:22 +0100 Subject: [PATCH] Started separating everything away from __init__ --- src/__init__.py | 4 ++++ __init__.py => src/anim.py | 41 +------------------------------------- src/base.py | 12 +++++++++++ src/utils.py | 14 +++++++++++++ 4 files changed, 31 insertions(+), 40 deletions(-) create mode 100644 src/__init__.py rename __init__.py => src/anim.py (65%) create mode 100644 src/base.py create mode 100644 src/utils.py diff --git a/src/__init__.py b/src/__init__.py new file mode 100644 index 0000000..1932efd --- /dev/null +++ b/src/__init__.py @@ -0,0 +1,4 @@ +from .base import Game +from .utils import centre +from .anim import AnimatedHandler +from .anim import AnimatedObject diff --git a/__init__.py b/src/anim.py similarity index 65% rename from __init__.py rename to src/anim.py index 832c0e5..500a36f 100644 --- a/__init__.py +++ b/src/anim.py @@ -1,11 +1,4 @@ import pygame -import time - -# Oclaim, I know we talked about putting everything -# in __init__.py and how it's a bad thing, and I -# will move things at some point, but as of right now, -# I'm still unsure exactly how I'm supposed to -# separate all of this. class AnimationHandler(pygame.Surface): """ @@ -71,36 +64,4 @@ class AnimatedObject: def copy(self): print(f'copy called') - return super().copy() - -def centre(surface: pygame.Surface, rect: tuple[int, int, 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. - - Returns: - pygame.Surface - """ - pass - -class Game: - def __init__(self): - pass - - def update(self): - pass - - def onEvent(self, event): - pass - - def close(self): - pass - -if __name__ == '__main__': - screen = pygame.display.set_mode((500, 500)) - anim = AnimatedObject('') - screen.blit(anim.getFrame(), (0, 0)) - pygame.quit() \ No newline at end of file + return super().copy() \ No newline at end of file diff --git a/src/base.py b/src/base.py new file mode 100644 index 0000000..fa09410 --- /dev/null +++ b/src/base.py @@ -0,0 +1,12 @@ +class Game: + def __init__(self): + pass + + def update(self): + pass + + def onEvent(self, event): + pass + + def close(self): + pass \ No newline at end of file diff --git a/src/utils.py b/src/utils.py new file mode 100644 index 0000000..ae75447 --- /dev/null +++ b/src/utils.py @@ -0,0 +1,14 @@ +import pygame + +def centre(surface: pygame.Surface, rect: tuple[int, int, 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. + + Returns: + pygame.Surface + """ + pass \ No newline at end of file