Пример #1
0
    def __init__(self, filename, **kwargs):

        kwargs.update({
            'width': 500,
            'height': 500,
            'vsync': True,
            'resizable': True,
        })
        super(BoxWorldWindow, self).__init__(**kwargs)

        glEnable(GL_BLEND)
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
        graphics.InitWithPyglet(self)
        graphics.text_color(name='BLACK')

        glClearColor(0.9, 0.9, 0.9, 1.0)  # Grey

        self.world = BoxWorld.FromFile(filename, self.get_size())
        self.world.reset_navgraph()

        # prep the fps display and some labels
        self.fps_display = None
        colour_black = (0, 0, 0, 255)
        self.labels = {
            'mouse': Label('', x=5, y=self.height - 20, color=colour_black),
            'search': Label('', x=120, y=self.height - 20, color=colour_black),
            'status': Label('', x=300, y=self.height - 20, color=colour_black),
        }
        self._update_label()

        self.add_handlers()

        self.limit = 0  # Unlimited
Пример #2
0
    def __init__(self, filename, **kwargs):
        kwargs.update({
            'width': 500,
            'height': 500,
            'vsync':True,
            'resizable':True,
        })
        super(BoxWorldWindow, self).__init__(**kwargs)

        # create a pyglet window and set glOptions
        glEnable(GL_BLEND)
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
        # needed so that graphs.egi knows where to draw
        egi.InitWithPyglet(self)
        egi.text_color(name='BLACK')

        glClearColor(0.9, 0.9, 0.9, 1.0) # Grey

        #create a world for graph searching
        #filename = kwargs['filename'] #"boxworld2.txt"
        #filename = 'map2.txt'
        self.world = BoxWorld.FromFile(filename, self.get_size())
        self.world.reset_navgraph()
        if not self.world.items_and_points_done:
            self.world.items_and_points()

        # prep the fps display and some labels
        self.fps_display = None # clock.ClockDisplay()
        clBlack = (0,0,0, 255)
        self.labels = {
            'mouse':  Label('', x=5, y=self.height-20, color=clBlack),
            'search': Label('', x=120, y=self.height-20, color=clBlack),
            'status': Label('', x=300, y=self.height-20, color=clBlack),
        }
        self._update_label()

        # add the extra event handlers we need
        self.add_handers()

        # search limit
        self.limit = 0 # unlimited.

        self.agent = False