I am making a small game using pygame in python 3.3 and I have a class for the enemies (see below). If I want to spawn in a new enemy every 10 or so seconds, so that theoretically, the game could go on forever. This however required the instances of the classes to be generated automatically every 10 seconds. Is there a way to create a new instance of the enemy class automatically?
Enemy class:
class Enemy(object):
def __init__(self, image, posx, posy, speed, damage):
self.image = image
self.posx = posx
self.posy = posy
self.speed = speed
self.damage = damage
def move(self):
self.posy = self.posy + self.speed
def draw(self):
screen.blit(self.image, (self.posx, self.posy))
Edit: Sorry! I posted this, not realising I didn't finish writing my explanation. My apologies!