我正在尝试与4位玩家进行比赛。我需要在玩家与墙壁之间以及玩家自身之间进行碰撞检测。
如果player1´ is testing for collision using
spritecollide , I don't understand how to create a sprite group, within the Player class, that contains
player2 ,
player3 , and
player4`,但不是player1``(因此它不会注册冲突)。其他所有玩家也一样。还是这是错误的思考方式?
答案 0 :(得分:0)
这就是它最终在Sprite方法中工作的方式-
class Player(pg.sprite.Sprite):
def __init__(self, game, x, y):
self.groups = game.all_sprites
def collide_with_walls_and_players(self):
hits = pygame.sprite.spritecollide(self, self.groups, False)
if self in hits:
hits.remove(self)