Started separating everything away from __init__

This commit is contained in:
2025-06-19 21:23:22 +01:00
parent 86c0230b26
commit e97d55fbc3
4 changed files with 31 additions and 40 deletions

4
src/__init__.py Normal file
View File

@ -0,0 +1,4 @@
from .base import Game
from .utils import centre
from .anim import AnimatedHandler
from .anim import AnimatedObject

View File

@ -1,11 +1,4 @@
import pygame 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): class AnimationHandler(pygame.Surface):
""" """
@ -71,36 +64,4 @@ class AnimatedObject:
def copy(self): def copy(self):
print(f'copy called') print(f'copy called')
return super().copy() 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()

12
src/base.py Normal file
View File

@ -0,0 +1,12 @@
class Game:
def __init__(self):
pass
def update(self):
pass
def onEvent(self, event):
pass
def close(self):
pass

14
src/utils.py Normal file
View File

@ -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