running = True while running: for event in pygame.event…

Ralf ·

running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False

# Sky
screen.fill((135, 206, 235))

# Ground
pygame.draw.rect(screen, (139, 115, 85), (0, height - 150, width, 150))

# Animate and draw grass
for blade in grass:
blade['sway'] += blade['speed']
sway = math.sin(blade['sway']) * 15
start = (blade['x'], blade['y'])
end = (blade['x'] + sway, blade['y'] - blade['height'])
pygame.draw.line(screen, (34, 139, 34), start, end, 2)

# Animate and draw clouds
for cloud in clouds:
cloud['x'] += cloud['speed']
if cloud['x'] > width + cloud['width']:
cloud['x'] = -cloud['width']

pygame.draw.circle(screen, (255, 255, 255),
(int(cloud['x']), int(cloud['y'])), int(cloud['width'] * 0.3))
pygame.draw.circle(screen, (255, 255, 255),
(int(cloud['x'] + cloud['width'] * 0.3), int(cloud['y'])),
int(cloud['width'] * 0.4))

pygame.display.flip()
clock.tick(60)