commit f01ff00e66a869803c8c5a51f9d504c817b8fe7b Author: Brosef Date: Thu Jun 19 18:13:13 2025 +0000 Inital commit Straight up fucked everything up so the history is gone. My bad. diff --git a/README.md b/README.md new file mode 100644 index 0000000..b5d7972 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# GameUtils + +A set of utilities to make the game development process less painful (despite the organisation name) and more unified. \ No newline at end of file diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..832c0e5 --- /dev/null +++ b/__init__.py @@ -0,0 +1,106 @@ +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): + """ + TODO: Write documentation on this, it takes in a + webp file, and handles drawing it to the screen in + a way that doesn't rely on frame counters. + """ + def __init__(self, animationPath): + pass + +class AnimatedObject: + """ + + """ + def __init__(self, baseFrame): + """ + Args: + baseFrame: A still image that gets displayed when no other animation is playing. + """ + + self._currentAnim = None + self._animStart = None + self._animations = {} + #self.baseFrame = pygame.image.load(baseFrame) + + def getFrame(self) -> pygame.Surface: + """ + Gets the current frame based on which animation is playing, and the current time. + + Returns: + pygame.Surface: The current frame + """ + + + + def addAnimation(self, animation: AnimationHandler, animationID: str): + """ + Adds an animation to the object. + + Args: + animation (AnimationHandler): The actual animation. + animationID (str): The ID that's later used to play the animation. + """ + self.animations.update({animationID: animation}) + + def playAnim(self, animationID: str): + """ + Plays an animation. + + Args: + animationID (str): The animation ID to play. + """ + self._animStart = time.perf_counter() + self._currentAnim = self._animations[animationID] + + def get_view(self): + print(f'get_view called') + return super().get_view() + + def get_buffer(self): + print(f'get_buffer called') + return super().get_buffer() + + 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 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..4291b04 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,10 @@ +[build-system] +requires = ["setuptools>=42", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "gameUtils" +version = "0.0.1.dev0" +description = "A set of utilities to make the game development process less painful (despite the organisation name) and more unified." +authors = [{ name = "Brosef" }] +dependencies = ["pygame-ce"] \ No newline at end of file