示例#1
0
文件: debug.py 项目: ChicoState/spyro
 def __init__(self, scene, text, color=(0, 0, 0)):
     spyral.Sprite.__init__(self, scene)
     self._font = spyral.Font(spyral._get_spyral_path() +
                             os.path.join("resources", "fonts",
                                          "DejaVuSans.ttf"),
                             15, color)
     self._render(text)
示例#2
0
 def __init__(self, scene, text, color=(0, 0, 0)):
     spyral.Sprite.__init__(self, scene)
     self._font = spyral.Font(spyral._get_spyral_path() +
                             os.path.join("resources", "fonts",
                                          "DejaVuSans.ttf"),
                             15, color)
     self._render(text)
示例#3
0
 def __init__(self, scene, color):
     spyral.Sprite.__init__(self)
     self._font = spyral.Font(
         spyral._get_spyral_path() +
         os.path.join("resources", "fonts", "DejaVuSans.ttf"), 15, color)
     self._render(0, 0)
     self._update_in = 5
     spyral.event.register("director.update", self._update, scene=scene)
def init():
    global parser
    parser = StyleParser()
    parser.parser = parsley.makeGrammar(open(spyral._get_spyral_path() + 'resources/style.parsley', "r").read(),
                                          {"string": string,
                                           "parser": parser,
                                           "leval": literal_eval,
                                           "Vec2D": spyral.Vec2D})
示例#5
0
文件: debug.py 项目: ChicoState/spyro
 def __init__(self, scene, color):
     spyral.Sprite.__init__(self, scene)
     self._font = spyral.Font(spyral._get_spyral_path() +
                             os.path.join("resources", "fonts",
                                          "DejaVuSans.ttf"),
                             15, color)
     self._render(0, 0)
     self._update_in = 5
     spyral.event.register("director.update", self._update, scene=scene)
示例#6
0
    def __init__(self, size=None, max_ups=None, max_fps=None):
        time_source = time.time
        self.clock = spyral.GameClock(
            time_source=time_source,
            max_fps=max_fps or spyral.director._max_fps,
            max_ups=max_ups or spyral.director._max_ups,
        )
        self.clock.use_wait = True

        self._handlers = collections.defaultdict(lambda: [])
        self._namespaces = set()
        self._event_source = spyral.event.LiveEventHandler()  # Gotta go rename this now
        self._handling_events = False
        self._events = []
        self._pending = []
        self._greenlets = {}  # Maybe need to weakref dict

        self._style_symbols = {}
        self._style_classes = []
        self._style_properties = defaultdict(lambda: {})
        self._style_functions = {}

        def TestingBox(size, color):
            i = spyral.Image(size=size)
            i.fill(color)
            return i

        self._style_functions["TestingBox"] = TestingBox

        self._size = None
        self._scale = (1.0, 1.0)  # None
        self._surface = pygame.display.get_surface()
        if size is not None:
            self._set_size(size)
        self._background = pygame.surface.Surface(self._surface.get_size())
        self._background.fill((255, 255, 255))
        self._surface.blit(self._background, (0, 0))
        self._blits = []
        self._dirty_rects = []
        self._clear_this_frame = []
        self._clear_next_frame = []
        self._soft_clear = []
        self._static_blits = {}
        self._rect = self._surface.get_rect()

        self._layers = ["all"]
        self._sprites = set()

        self.register("director.update", self.handle_events)
        self.register("director.update", self.run_actors, ("dt",))

        # View interface
        self.scene = self

        # Loading default styles
        self.load_style(spyral._get_spyral_path() + "resources/form_defaults.spys")
示例#7
0
def init():
    """
    Initializes the Styler.
    """
    global parser
    parser = StyleParser()
    style_file = open(spyral._get_spyral_path() + "resources/style.parsley").read()
    parser.parser = parsley.makeGrammar(
        style_file, {"string": string, "parser": parser, "leval": literal_eval, "Vec2D": spyral.Vec2D}
    )
示例#8
0
def init():
    """
    Initializes the Styler.
    """
    global parser
    parser = StyleParser()
    style_file = open(spyral._get_spyral_path() +
                      'resources/style.parsley').read()
    parser.parser = parsley.makeGrammar(style_file,
                                        {"string": string,
                                         "parser": parser,
                                         "leval": literal_eval,
                                         "Vec2D": spyral.Vec2D})
示例#9
0
    def __init__(self, size = None, max_ups=None, max_fps=None):
        time_source = time.time
        self.clock = spyral.GameClock(
            time_source=time_source,
            max_fps=max_fps or spyral.director._max_fps,
            max_ups=max_ups or spyral.director._max_ups)
        self.clock.use_wait = True

        self._handlers = defaultdict(lambda: [])
        self._namespaces = set()
        self._event_source = spyral.event.LiveEventHandler()
        self._handling_events = False
        self._events = []
        self._pending = []
        self._greenlets = {} # Maybe need to weakref dict

        self._style_symbols = {}
        self._style_classes = []
        self._style_properties = defaultdict(lambda: {})
        self._style_functions = {}

        self._style_functions['_get_spyral_path'] = spyral._get_spyral_path

        self._size = None
        self._scale = spyral.Vec2D(1.0, 1.0) #None
        self._surface = pygame.display.get_surface()
        if size is not None:
            self._set_size(size)
        display_size = self._surface.get_size()
        self._background = spyral.image._new_spyral_surface(display_size)
        self._background.fill((255, 255, 255))
        self._surface.blit(self._background, (0, 0))
        self._blits = []
        self._dirty_rects = []
        self._clear_this_frame = []
        self._clear_next_frame = []
        self._soft_clear = []
        self._static_blits = {}
        self._invalidating_views = {}
        self._collision_boxes = {}
        self._rect = self._surface.get_rect()

        self._layers = []
        self._child_views = []
        self._layer_tree = _LayerTree(self)
        self._sprites = set()

        spyral.event.register('director.scene.enter', self.redraw,
                              scene=self)
        spyral.event.register('director.update', self._handle_events,
                              scene=self)
        spyral.event.register('director.update', self._run_actors, ('delta',),
                              scene=self)
        spyral.event.register('spyral.internal.view.changed',
                              self._invalidate_views, scene=self)

        # View interface
        self._scene = _wref(self)
        self._views = []

        # Loading default styles
        self.load_style(spyral._get_spyral_path() +
                        'resources/form_defaults.spys')
示例#10
0
 def __init__(self):
     self.reverse_map = {}
     self.load_keys_from_file(spyral._get_spyral_path() +
                              'resources/default_key_mappings.txt')
     self._fix_bad_names([("return", "enter"),
                          ("break", "brk")])
示例#11
0
 def __init__(self):  
   self.load_keys_from_file(spyral._get_spyral_path() + 'resources/default_key_mappings.txt')   
示例#12
0
    def __init__(self, size = None, max_ups=None, max_fps=None):
        time_source = time.time
        self.clock = spyral.GameClock(
            time_source=time_source,
            max_fps=max_fps or spyral.director._max_fps,
            max_ups=max_ups or spyral.director._max_ups)
        self.clock.use_wait = True

        self._handlers = defaultdict(lambda: [])
        self._namespaces = set()
        self._event_source = spyral.event.LiveEventHandler()
        self._handling_events = False
        self._events = []
        self._pending = []
        self._greenlets = {} # Maybe need to weakref dict

        self._style_symbols = {}
        self._style_classes = []
        self._style_properties = defaultdict(lambda: {})
        self._style_functions = {}

        self._style_functions['_get_spyral_path'] = spyral._get_spyral_path

        self._size = None
        self._scale = spyral.Vec2D(1.0, 1.0) #None
        self._surface = pygame.display.get_surface()
        if size is not None:
            self._set_size(size)
        display_size = self._surface.get_size()
        self._background = spyral.image._new_spyral_surface(display_size)
        self._background.fill((255, 255, 255))
        self._background_version = 0
        self._surface.blit(self._background, (0, 0))
        self._blits = []
        self._dirty_rects = []
        self._clear_this_frame = []
        self._clear_next_frame = []
        self._soft_clear = []
        self._static_blits = {}
        self._invalidating_views = {}
        self._collision_boxes = {}
        self._rect = self._surface.get_rect()

        self._layers = []
        self._child_views = []
        self._layer_tree = _LayerTree(self)
        self._sprites = set()

        spyral.event.register('director.scene.enter', self.redraw,
                              scene=self)
        spyral.event.register('director.update', self._handle_events,
                              scene=self)
        if _GREENLETS_AVAILABLE:
            spyral.event.register('director.update', self._run_actors, 
                                  ('delta',), scene=self)
        spyral.event.register('system.focus_change', self.redraw)
        spyral.event.register('system.video_resize', self.redraw)
        spyral.event.register('system.video_expose', self.redraw)
        spyral.event.register('spyral.internal.view.changed',
                              self._invalidate_views, scene=self)

        # View interface
        self._scene = _wref(self)
        self._views = []

        # Loading default styles
        self.load_style(spyral._get_spyral_path() +
                        'resources/form_defaults.spys')
示例#13
0
 def __init__(self):
     self.reverse_map = {}
     self.load_keys_from_file(spyral._get_spyral_path() +
                              'resources/default_key_mappings.txt')
     self._fix_bad_names([("return", "enter"), ("break", "brk")])