def __init__(self, game, _group, image_file, animation=None, image_data=None, anchorx=0, anchory=0, **kwargs): #init standard variables if animation is not None: framewidth,frameheight = animation image = helper.make_animation(helper.load_image(image_file),framewidth,frameheight,anchorx,anchory)[2] elif (image_data is None): image = helper.load_from_cache(game.rawcache, image_file, anchorx, anchory) else: image = image_data pyglet.sprite.Sprite.__init__(self, image, batch=game.batch, group=_group) self.x = kwargs["x"] self.y = kwargs["y"] #Update the dict if they sent in any keywords self.__dict__.update(kwargs)
def __init__(self, game, gamepos, **kwargs): self._pos = gamepos self._screenpos = ((game.width//2)//game.dummytile.image.width,(game.height//2)//game.dummytile.image.height) self.animationlength = 0.40#seconds self.lastmove = datetime.datetime.now() self.maxhp = 100 self.hp = 100 self.animationset = helper.make_animation(helper.load_image('character.png'),64,64,anchorx=16,anchory=0) self.stationaryimg = helper.load_image('character.png') self.stationaryset = [] self.animationframes = len(self.animationset) self.direction = 'down' for x in xrange(0,4): self.stationaryset.append(self.stationaryimg.get_region(0,64*x,64,64)) self.stationaryset[x].anchor_x=16 self.stationaryset[x].anchor_y=0 self.sprite = sprite.Sprite(game, game.middleground, None, image_data=self.stationaryset[1], x=gamepos[0], y=gamepos[1], anchorx=16, anchory=0, **kwargs)