mirror of
https://github.com/13hannes11/outyard-hackathon-rush-hour-co2.git
synced 2024-09-03 20:10:59 +02:00
add image for vacuum cleaner
Co-authored-by: Laura Januleviciute <januleviciute.laura@gmail.com>
This commit is contained in:
@@ -6,12 +6,13 @@ class Vacuum:
|
|||||||
def __init__(self, bubble_objects):
|
def __init__(self, bubble_objects):
|
||||||
self.posX = -50
|
self.posX = -50
|
||||||
self.posY = -50
|
self.posY = -50
|
||||||
self.width = 50
|
self.width = 124
|
||||||
self.height = 50
|
self.height = 57
|
||||||
self.bubble_objects = bubble_objects
|
self.bubble_objects = bubble_objects
|
||||||
|
self.image = pygame.image.load("sprites/vacuum.png")
|
||||||
|
|
||||||
def draw(self, screen):
|
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):
|
def update(self, screen):
|
||||||
x, y = pygame.mouse.get_pos()
|
x, y = pygame.mouse.get_pos()
|
||||||
|
|||||||
12
main.py
12
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(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(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:
|
while True:
|
||||||
SCREEN.fill(BACKGROUND)
|
SCREEN.fill(BACKGROUND)
|
||||||
@@ -50,17 +50,19 @@ while True:
|
|||||||
if len(bubble_objects) < BUBBLE_LIMIT:
|
if len(bubble_objects) < BUBBLE_LIMIT:
|
||||||
for game_object in game_objects:
|
for game_object in game_objects:
|
||||||
game_object.update(SCREEN)
|
game_object.update(SCREEN)
|
||||||
for game_object in game_objects:
|
|
||||||
game_object.draw(SCREEN)
|
|
||||||
|
|
||||||
for game_object in bubble_objects:
|
for game_object in bubble_objects:
|
||||||
game_object.update(SCREEN)
|
game_object.update(SCREEN)
|
||||||
|
vacuum.update(SCREEN)
|
||||||
|
|
||||||
|
for game_object in game_objects:
|
||||||
|
game_object.draw(SCREEN)
|
||||||
for game_object in bubble_objects:
|
for game_object in bubble_objects:
|
||||||
game_object.draw(SCREEN)
|
game_object.draw(SCREEN)
|
||||||
|
vacuum.draw(SCREEN)
|
||||||
else:
|
else:
|
||||||
# TODO game over screen with message to reduce driving cars
|
# TODO game over screen with message to reduce driving cars
|
||||||
SCREEN.blit(TEXT_SCREEN, TEXT_RECT)
|
SCREEN.blit(TEXT_SCREEN, TEXT_RECT)
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
pygame.display.flip()
|
pygame.display.flip()
|
||||||
|
|||||||
BIN
sprites/vacuum.png
Normal file
BIN
sprites/vacuum.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.9 KiB |
Reference in New Issue
Block a user