Ejemplo n.º 1
0
def printEvents(window):
    """
    Debug tool that will print the events to the console.

    window is an instance of a Window object receiving the events.
    """
    window.push_handlers(pyglet.window.event.WindowEventLogger())
Ejemplo n.º 2
0
def printEvents(window):
    """
    Debug tool that will print the events to the console.

    window is an instance of a Window object receiving the events.
    """
    window.push_handlers(pyglet.window.event.WindowEventLogger())
Ejemplo n.º 3
0
    def __init__(self, window, camera, objects, callbacks=None, mouse_sensitivity=0.0025):
        self.window = window
        self.camera = camera
        self.objects = objects
        self.callbacks = callbacks
        if not self.callbacks:
            self.callbacks = {}
        self.mouse_sensitivity = mouse_sensitivity

        self.keys = key.KeyStateHandler()
        self.dx = 0
        self.dy = 0

        self.mouse_locked = False
        self.time_multiplier = 1.0
        self.time_multiplier_before_pause = 1.0
        self.paused = False
        self.draw_help_label = True
        self.toggled_help_label = False
        self.selected_body = None
        self.camera_offset = Vector3()

        window.push_handlers(self.on_mouse_press, self.on_mouse_motion, self.on_key_press, self.on_key_release)
Ejemplo n.º 4
0
    def __init__(self, window):
        self.map = gamemap.Map(width=20, height=15)
        self.start = None
        self.end = None

        self.graph = scenegraph.Scenegraph()

        # Map stem
        self.stem = self.graph.stem('map')
        self.stem.append(self.graph.node(self.map.sgdata))

        player1 = player.Player('Player 1', self.map)
        player2 = player.Player('Player 2', self.map)

        self.players = []
        self.players.append(player1)
        self.players.append(player2)

        self.handlers = GameEventHandlers(self)
        window.push_handlers(self.handlers)

        self.gui = gui.GuiManager(self, self.graph)
        self.gui.push_textbox(20, 20, 30, 40)
        window.push_handlers(self.gui.handlers)
Ejemplo n.º 5
0
SIZE = 30
COLOR = (0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1)
x = W // 2
y = H // 2

window = pyglet.window.Window(width=W, height=H, caption='Game')
window.set_location(5, 30)
window.set_mouse_visible(visible=False)
counter = pyglet.window.FPSDisplay(window=window)

batch = pyglet.graphics.Batch()
background = pyglet.graphics.OrderedGroup(0)
foreground = pyglet.graphics.OrderedGroup(1)

keys = key.KeyStateHandler()
window.push_handlers(keys)

# start QUADS
x = y = 0
for raw  in level:
    for col in raw: 
        if col == '-':
            polygon = batch.add(
                4, pyglet.gl.GL_QUADS,  background,
                ('v2f', [x, y, x, y + SIZE, x + SIZE, y + SIZE, x + SIZE, y]),
                ('c3f', COLOR)
            )
        x += SIZE
    y += SIZE
    x = 0    
# stop QUAdsAsAAT