def update(self): ''' Updates the position of sprite ''' self.move() EntitySprite.update(self)
def from_json(self, json): ''' Restore this object from the passed in json object @param json - the json object ''' EntitySprite.from_json(self, json) self.health = json['health'] self.item = get_items()[json['item']]
def from_json(self, json): ''' Restore this object from the passed in json object @param json - the json object ''' EntitySprite.from_json(self, json) self.action_wait_val = json['action_wait_val'] self.iters_until_action = json['iters_until_action'] self.direction = json['direction']
def update (self): ''' The update function changes the sprite to look like its moving and calls the entity update function ''' if self.currentStrip is self.strips[self.direction]: self.image = self._get_next_image() else: self.currentStrip = self.strips[self.direction] self.image = self._get_next_image() self.currentStrip = self.strips[self.direction] EntitySprite.update(self)
def __init__(self, image_filename, position, size, direction): ''' Intitializes a BulletSprite @param image_filename - The file name of the sprite's image @param position - The position of the sprite @param size - The size of teh sprite @param direction - The direction of the sprite ''' EntitySprite.__init__(self, position, size) self.direction = direction self.image = pygame.image.load(image_filename) self._reset_rect()
def __init__(self, image_filename, position, size, direction): ''' Initializes the CreatureSprite to be called from subclasses @param image_filename - The file name of spritesheet @param position - The position of the sprite on the map @param size - The size fo the sprite @param direction - The direction its facing in the game ''' EntitySprite.__init__(self, position, size) self.action_wait_val = 12 self.iters_until_action = 0 self.direction = direction self._create_spritesheet(image_filename)
def __init__ (self, position=(0, 0), size=(0, 0), json=None): ''' Initializes the gate @param position - optional argument to specify position @param size - optional argument to specify size of sprite @param direction - optional argument to specify direction facing when initialized @param json - optional argument to be used when loading from a json file ''' EntitySprite.__init__(self, position, size) if json: self.from_json(json) self.image = self._scale(self.normal) self._reset_rect()
def to_json(self): ''' Serialize the import members of this class as a json object ''' json = EntitySprite.to_json(self) json['action_wait_val'] = self.action_wait_val json['iters_until_action'] = self.iters_until_action json['direction'] = self.direction return json
def to_json(self): ''' Serialize the important members of this class as a json object. ''' json = EntitySprite.to_json(self) json['health'] = self.health if self.item: json['item'] = self.item.name else: json['item'] = 'None' return json