groups
This commit is contained in:
10
main.py
10
main.py
@@ -20,6 +20,11 @@ def main():
|
|||||||
time = pygame.time.Clock()
|
time = pygame.time.Clock()
|
||||||
dt = 0
|
dt = 0
|
||||||
|
|
||||||
|
updatable = pygame.sprite.Group()
|
||||||
|
drawable = pygame.sprite.Group()
|
||||||
|
|
||||||
|
Player.containers = (updatable, drawable)
|
||||||
|
|
||||||
player = Player(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2)
|
player = Player(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
@@ -29,9 +34,10 @@ def main():
|
|||||||
|
|
||||||
pygame.Surface.fill(screen, (0,0,0))
|
pygame.Surface.fill(screen, (0,0,0))
|
||||||
|
|
||||||
player.update(dt)
|
updatable.update(dt)
|
||||||
|
|
||||||
player.draw(screen)
|
for drawing in drawable:
|
||||||
|
drawing.draw(screen)
|
||||||
|
|
||||||
pygame.display.flip() #refresh screen
|
pygame.display.flip() #refresh screen
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ from constants import PLAYER_RADIUS, PLAYER_SPEED, PLAYER_TURN_SPEED
|
|||||||
|
|
||||||
|
|
||||||
class Player(CircleShape):
|
class Player(CircleShape):
|
||||||
|
#containers = []
|
||||||
|
|
||||||
def __init__(self, x, y):
|
def __init__(self, x, y):
|
||||||
super().__init__(x, y, PLAYER_RADIUS)
|
super().__init__(x, y, PLAYER_RADIUS)
|
||||||
self.rotation = 0
|
self.rotation = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user