added dumb group stuff why pygame
This commit is contained in:
parent
703023c019
commit
9365e50c64
2 changed files with 16 additions and 2 deletions
15
main.py
15
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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue