I am having some trouble with my code. I was wondering how to call a specific class. Here is my code:
choices = [Enemy, Enemy2]
def create_enemies(rows, columns):
enemy_x = x
enemy_y = y
for rows in range(0, rows):
for columns in range(0, columns):
rand_num = random.randint(1, 3)
if rand_num == 1:
enemy = random.choice(choices)(enemy_x, enemy_y)
enemy_sprites.add(enemy)
enemy_x += spacing_x
enemy_y += spacing_y
enemy_x = x
and then:
for enemy in enemy_sprites:
enemy.update()
if enemy.rect.colliderect(player):
health -= 10
enemy_sprites.remove(enemy)
I have an Enemy and an Enemy2 class, but they are both defined as enemy in my create_enemies function. I was wondering how to get the specific enemy class to collide with the player instead of just checking both at the same time. I want to use this for taking different amounts of health. Any help is greatly appreciated!