diff --git a/Vacuum.py b/Vacuum.py index a34b6cd..94f3a4c 100644 --- a/Vacuum.py +++ b/Vacuum.py @@ -6,13 +6,14 @@ class Vacuum: def __init__(self, bubble_objects): self.posX = -50 self.posY = -50 - self.width = 50 - self.height = 50 + self.width = 124 + self.height = 57 self.bubble_objects = bubble_objects + self.image = pygame.image.load("sprites/vacuum.png") def draw(self, screen): - pygame.draw.rect(screen, (255, 0, 0), pygame.Rect(self.posX, self.posY, self.width, self.height)) - + screen.blit(self.image, (self.posX, self.posY)) + def update(self, screen): x, y = pygame.mouse.get_pos() self.posX = x -(self.width / 2) diff --git a/main.py b/main.py index ab79eb6..1f0b22e 100644 --- a/main.py +++ b/main.py @@ -41,7 +41,7 @@ for i in range(3, 6): game_objects.append(Lane(i * 80 + 60, SCREEN_WIDTH, 80, add_markings=markings)) game_objects.append(Car(random.uniform(0, SCREEN_WIDTH), i * 80 + 60, bubble_objects, directionX= - random.uniform(1, 5))) -game_objects.append(Vacuum(bubble_objects)) +vacuum = Vacuum(bubble_objects) while True: SCREEN.fill(BACKGROUND) @@ -50,17 +50,19 @@ while True: if len(bubble_objects) < BUBBLE_LIMIT: for game_object in game_objects: game_object.update(SCREEN) - for game_object in game_objects: - game_object.draw(SCREEN) - for game_object in bubble_objects: game_object.update(SCREEN) + vacuum.update(SCREEN) + + for game_object in game_objects: + game_object.draw(SCREEN) for game_object in bubble_objects: game_object.draw(SCREEN) + vacuum.draw(SCREEN) else: # TODO game over screen with message to reduce driving cars SCREEN.blit(TEXT_SCREEN, TEXT_RECT) - pass + pygame.display.flip() diff --git a/sprites/vacuum.png b/sprites/vacuum.png new file mode 100644 index 0000000..eb88dd7 Binary files /dev/null and b/sprites/vacuum.png differ