我在创建多个每0.5秒产生一次的僵尸时遇到麻烦。这是我最小的可重现示例。可能吗我想制作多个群体,每隔几秒钟就会产生挑战,随着时间的推移不断挑战玩家。
class Zombie(object):
def __init__(self):
images=[pygame.image.load('zombie4.png') ,
pygame.image.load('zombie5.png') ,
pygame.image.load('zombie2.png'),
pygame.image.load('zombie3.png')]
self.image=images[random.randint(0,3)]
self.rect=self.image.get_rect()
self.Xco=random.randint(0,disWidth)
self.Yco=random.randint(0,disLength)
self.speed=5
self.angle=0
zombie=Zombie()
zombie2=Zombie()
Player1=Player()
##
loop=True
while loop :
clock.tick(30)
pygame.display.update()
for event in pygame.event.get():
if event.type==pygame.QUIT:
loop=False
if zombie.is_collided_with(Player1):
print ("collision!")
Player1.PLAYERrefresh(display)
Player1.Move()
zombie.ZOMBIErefresh(display,Player1)
pygame.quit()