Shorter way to make colliderect in if statement work?

I have two objects:

#Object1
enemigo=pygame.image.load("enemigo.png").convert_alpha()
enemigo=pygame.transform.scale(enemigo, (100, 100))
enemigo_rectangulo=enemigo.get_rect(center=(1000, 100))

#Object2
enemigo2=pygame.image.load("enemigo2.png").convert_alpha()
enemigo2=pygame.transform.scale(enemigo2, (140, 140))
enemigo_rectangulo2=enemigo2.get_rect(center=(1400, 50))

And I want to make an if statement if they collide with a third object. This code actually works but is too long:

if personaje_rectangulo.colliderect(enemigo_rectangulo) or personaje_rectangulo.colliderect(enemigo_rectangulo2):

And there's an error when I try to write:

if personaje_rectangulo.colliderect(enemigo_rectangulo, enemigo_rectangulo2):

So, what is wrong? Is there a shorter way to write it?



Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation