def __init__(self, pos): super(Enemie, self).__init__() self.x, self.y = pos self.cooldowntime = 0.7 self.cooldown = self.cooldowntime self.cooled = True self.image = pg.Surface((TILE_SIZE, TILE_SIZE)) self.image.fill((255, 0, 255)) self.image.convert() self.rect = self.image.get_rect(topleft=pos) self.hit_rect = self.rect.copy() self.hit_rect.center = self.rect.center self.pattern = BulletML.FromDocument(open("threefire.xml", "rU")) self.bullets = [] self.lifetime = 10
def __init__(self, pos): super(SimpleWeapon, self).__init__() self.frames = { "LEFT": pg.transform.flip(TILES[0][0], True, False), "RIGHT": TILES[0][0] } self.relative_x = 16 self.x, self.y = pos self.image = self.frames["RIGHT"] self.rect = self.image.get_rect(topleft=pos) DECORATOR_GROUP.add(self) self.dirty = 2 self.pattern = BulletML.FromDocument(open("threefire.xml", "rU")) self.bullets = [] self.cooldowntime = 0.3 self.cooldown = self.cooldowntime self.cooled = False
def test_run(self, filename=filename): doc = BulletML.FromDocument(open(filename, "rU")) bullets = [Bullet.FromDocument(doc)] for i in range(100): for bullet in bullets: bullets.extend(bullet.step())
def test_repr(self, filename=filename): doc = BulletML.FromDocument(open(filename, "rU")) repr(doc)
def test_yaml(self, filename=filename): doc = BulletML.FromDocument(open(filename, "rU")) doc = yaml.load(yaml.dump(doc)) doc = yaml.load(yaml.dump(doc))
def test_xml(self, filename=filename): BulletML.FromDocument(open(filename, "rU"))
def load(self, filename, source, target, rank=0.5): bullet = MyBullet.FromDocument(BulletML.FromDocument(open("bml/" + filename, "rU")), source.x, source.y, target=target, rank=rank) bullet.root = True self.add(bullet)