Пример #1
0
    def apply_config(self, conf):
        """
        Validate and apply configuration to this sprite.

        Generally, each config item becomes a instance attribute.
        """
        conf = self.CONF(conf)
        for key, val in conf.items():
            if not hasattr(self, key):
                # this isn't a configurable attribute. May have special behavior.
                continue
            if getattr(self, key) is None:
                # allow subclasses to force non-None attributes in their constructors
                setattr(self, key, val)
        self.font = helpers.load_font(conf['font_name'])
        if conf['frames']:
            self._build_frames(conf['frames'])

        return conf
Пример #2
0
 def __init__(self, width, height):
     """Construct a scene."""
     Scene.__init__(self, width, height)
     self.font = helpers.load_font('9x15B.bdf')