Answers for "pygame collision"

7

how to do collision detection in pygame

#making stuff to collide
player=pygame.Rect(whatever you want)
villian=pygame.Rect(whatever you want)

#making the detection
if villian.colliderect(player):
	print ("villian got you oh no!")#this can be something different
Posted by: Guest on January-25-2021
0

pygame check collision

def is_collided_with(self, sprite):
    return self.rect.colliderect(sprite.rect)
Posted by: Guest on June-24-2020

Python Answers by Framework

Browse Popular Code Answers by Language