I've been working on creating a small, space invaders style game in pygame. I've almost reached the end however, I want to make it so if the enemy ships collide with my ship, a collision is detected and the game ends.
So far I have the code for detecting when a bullet and an enemy ship collides, however when I tried to rewrite this for a enemy/player collision it doesnt work as expected, so I think im doing something incorrect.
Code in question:
for block in block_list:
player_hit_list = pygame.sprite.spritecollide(block, player_list, True)
for player in player_hit_list:
explosion.play()
block_list.remove(block)
player_list.remove(player)
all_sprites_list.remove(block)
all_sprites_list.remove(player)
if block.rect.y < +10:
block_list.remove(block)
all_sprites_list.remove(block)
Full code: http://pastebin.com/FShPuR6A
Is anyone able to tell my why the code I have isnt functioning?
Thanks a lot