Created
April 8, 2010 04:14
-
-
Save zachelko/359768 to your computer and use it in GitHub Desktop.
Exclude rain drops below the beaker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Find the shortest beaker so we know which drops to check for collisions | |
# against | |
beakerHeights = [] | |
shortest = 0 | |
for beaker in level.beakers: beakerHeights.append(beaker.rect.y) | |
beakerHeights.sort() | |
if (beakerHeights): shortest = beakerHeights[0] | |
# Get the current drops to test for collisions | |
drops=pygame.sprite.Group() | |
for cloud in level.clouds: | |
for drop in cloud.drops: | |
# Only check for collisions with drops that are above or = to the top | |
# of the shortest beaker | |
if (drop.rect.y <= shortest): | |
drops.add(drop) | |
for beaker in pygame.sprite.groupcollide(level.beakers, drops, False, True).keys(): | |
beaker.takeDrop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment