added dumb group stuff why pygame

This commit is contained in:
specCon18 2025-01-15 00:29:22 -05:00
parent 703023c019
commit 9365e50c64
2 changed files with 16 additions and 2 deletions

15
main.py
View file

@ -10,14 +10,25 @@ def main():
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT)) screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
clock = pygame.time.Clock() clock = pygame.time.Clock()
dt = 0 dt = 0
drawables = pygame.sprite.Group()
updatables = pygame.sprite.Group()
Player.containers = (drawables, updatables)
p1 = Player(SCREEN_WIDTH/2,SCREEN_HEIGHT/2) p1 = Player(SCREEN_WIDTH/2,SCREEN_HEIGHT/2)
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == pygame.QUIT: if event.type == pygame.QUIT:
return return
screen.fill((0, 0, 0)) 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() pygame.display.flip()
tick = clock.tick(60) tick = clock.tick(60)
dt = tick/1000 dt = tick/1000

View file

@ -3,6 +3,9 @@ import constants
import pygame import pygame
class Player(circleshape.CircleShape): class Player(circleshape.CircleShape):
containers = []
def __init__(self,x,y): def __init__(self,x,y):
super().__init__(x,y,constants.PLAYER_RADIUS) super().__init__(x,y,constants.PLAYER_RADIUS)
self.rotation = 0 self.rotation = 0