Ejemplo n.º 1
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
Ejemplo n.º 2
0
	def createWindow(self):
		
		self.win = None
		if(self.antialiased):
			config = pyglet.gl.Config(sample_buffers=1, samples=4, double_buffer=True)
			self.win = window.Window(width=self.width, height=self.height, vsync=True, resizable=True, config=config)
		else:
			self.win = window.Window(width=self.width, height=self.height, vsync=True, resizable=True)
		
		glEnable(GL_BLEND)
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

		# needed so that egi knows where to draw
		egi.InitWithPyglet(self.win)

		# prep the fps display
		self.fps_display = clock.ClockDisplay()
		self.fps_display.label.color = rgba('fff', 0.05)

		# register key and mouse event handlers
		self.win.push_handlers(self.on_key_press)
		self.win.push_handlers(self.on_mouse_press)
		self.win.push_handlers(self.on_resize)
Ejemplo n.º 3
0
        world.bullets.clear()


def on_resize(cx, cy):
    world.cx = cx
    world.cy = cy


if __name__ == '__main__':

    # create a pyglet window and set glOptions
    win = window.Window(width=1000, height=1000, vsync=True, resizable=True)
    glEnable(GL_BLEND)
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
    # needed so that egi knows where to draw
    egi.InitWithPyglet(win)
    # prep the fps display
    fps_display = clock.ClockDisplay()
    # register key and mouse event handlers
    win.push_handlers(on_key_press)
    win.push_handlers(on_mouse_press)
    win.push_handlers(on_resize)

    # create a world for agents
    world = World(500, 500)
    # add one agent
    world.agents.append(Agent(world))
    world.prey.append(Target(world))
    # unpause the world ready for movement
    world.paused = False
    i = 0