From 9365e50c64157c9520e08e9218834169591bf5db Mon Sep 17 00:00:00 2001 From: specCon18 Date: Wed, 15 Jan 2025 00:29:22 -0500 Subject: [PATCH] added dumb group stuff why pygame --- main.py | 15 +++++++++++++-- player.py | 3 +++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 8be5844..1cbede8 100644 --- a/main.py +++ b/main.py @@ -10,14 +10,25 @@ def main(): screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT)) clock = pygame.time.Clock() dt = 0 + + drawables = pygame.sprite.Group() + updatables = pygame.sprite.Group() + + Player.containers = (drawables, updatables) p1 = Player(SCREEN_WIDTH/2,SCREEN_HEIGHT/2) + while True: for event in pygame.event.get(): if event.type == pygame.QUIT: return screen.fill((0, 0, 0)) - p1.draw(screen) - p1.update(dt) + + for drawable in drawables: + drawable.draw(screen) + + for updatable in updatables: + updatable.update(dt) + pygame.display.flip() tick = clock.tick(60) dt = tick/1000 diff --git a/player.py b/player.py index 06cfa6f..512b0ee 100644 --- a/player.py +++ b/player.py @@ -3,6 +3,9 @@ import constants import pygame class Player(circleshape.CircleShape): + + containers = [] + def __init__(self,x,y): super().__init__(x,y,constants.PLAYER_RADIUS) self.rotation = 0