def from_json(self, json): ''' Restore this object from the passed in json object @param json - the json object ''' ShooterSprite.from_json(self, json) self.health = json['health']
def __init__(self, position=(0, 0), size=(0, 0), direction=Direction.down, json=None): ''' Constructor for BossSprite @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 ''' ShooterSprite.__init__(self, position, size, direction) if json: self.from_json(json) else: self.health = 50 self._create_spritesheet(BOSS_IMAGE)
def to_json(self): ''' Serialize the important members of this class as a json object ''' json = ShooterSprite.to_json(self) json['health'] = 50 return json