How to Use Sprite Collide in Pygame

前端 未结 3 1025
你的背包
你的背包 2021-01-21 01:35

I am making a very simple game where the bird (player) has to dodge the rock and if it gets hit by the rock you lose. I am trying to use pygame.sprite.collide_rect() to tell if

3条回答
  •  死守一世寂寞
    2021-01-21 02:20

    You have this:

    col = pygame.sprite.collide_rect(sprite1, sprite2)
    

    But an easier way to do this would be to simply use colliderect which is a function of rect. It might be easier to try this:

    col=sprite1.rect.colliderect(sprite2.rect)
    

提交回复
热议问题