How to Use Sprite Collide in Pygame

前端 未结 3 991
你的背包
你的背包 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:10

    Change

    def checkCollision(sprite1, sprite2):
    

    To

    def checkCollision(self, sprite1, sprite2):
    

    And you don't have to check the collision on every event, reduce the indent of rock.checkCollision(bird.image_b, rock.image_b) by 1.

提交回复
热议问题