pygame提供了两个非常方便的方法可以实现碰撞检测
pygam.sprite.grupcollide():实现子弹撞毁敌机,两个都销毁
两个精灵组中所有的精灵的碰撞检测
def groupcollide(groupa: Any,
groupb: Any,
dokilla: Any,
dokillb: Any,
collided: Any = None) -> Dict[Any, list]
detect collision between a group and another group
pygame.sprite.groupcollide(groupa, groupb, dokilla, dokillb):
return dict
Given two groups, this will find the intersections between all sprites in each group. It returns a dictionary of all sprites in the first group that collide. The value for each item in the dictionary is a list of the sprites in the second group it collides with. The two dokill arguments control if the sprites from either group will be automatically removed from all groups. Collided is a callback function used to calculate if two sprites are colliding. it should take two sprites as values, and return a bool value indicating if they are colliding. If collided is not passed, all sprites must