當前位置: 首頁>>代碼示例>>Python>>正文


Python glfw.RELEASE屬性代碼示例

本文整理匯總了Python中glfw.RELEASE屬性的典型用法代碼示例。如果您正苦於以下問題:Python glfw.RELEASE屬性的具體用法?Python glfw.RELEASE怎麽用?Python glfw.RELEASE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在glfw的用法示例。


在下文中一共展示了glfw.RELEASE屬性的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: key_callback

# 需要導入模塊: import glfw [as 別名]
# 或者: from glfw import RELEASE [as 別名]
def key_callback(self, window, key, scancode, action, mods):
        if action == glfw.PRESS:
            tgt = self.keypress
        elif action == glfw.RELEASE:
            tgt = self.keyup
        elif action == glfw.REPEAT:
            tgt = self.keyrepeat
        else:
            return
        if tgt.get(key):
            for fn in tgt[key]:
                fn(window, key, scancode, action, mods)
        if tgt.get("any"):
            for fn in tgt["any"]:
                fn(window, key, scancode, action, mods)
            # retain functionality for closing the viewer
            if key == glfw.KEY_ESCAPE:
                super().key_callback(window, key, scancode, action, mods)
        else:
            # only use default mujoco callbacks if "any" callbacks are unset
            super().key_callback(window, key, scancode, action, mods) 
開發者ID:StanfordVL,項目名稱:robosuite,代碼行數:23,代碼來源:mujoco_py_renderer.py

示例2: key_callback

# 需要導入模塊: import glfw [as 別名]
# 或者: from glfw import RELEASE [as 別名]
def key_callback(self, window, key, scancode, action, mods):
        super().key_callback(window, key, scancode, action, mods)
        # Trigger on keyup only:
        if action != glfw.RELEASE:
            return
        # Increment experiment seed
        if key == glfw.KEY_N:
            self.reset_increment()
        # Decrement experiment trial
        elif key == glfw.KEY_P:
            print("Pressed P")
            self.seed = max(self.seed - 1, 0)
            self.env.seed(self.seed)
            self.ob = self.env.reset()
            for policy in self.policies:
                policy.reset()
            if hasattr(self.env, "reset_goal"):
                self.goal = self.env.reset_goal()
            self.update_sim(self.env.unwrapped.sim) 
開發者ID:openai,項目名稱:multi-agent-emergence-environments,代碼行數:21,代碼來源:policy_viewer.py

示例3: key_input_clb

# 需要導入模塊: import glfw [as 別名]
# 或者: from glfw import RELEASE [as 別名]
def key_input_clb(window, key, scancode, action, mode):
    global left, right, forward, backward
    if key == glfw.KEY_ESCAPE and action == glfw.PRESS:
        glfw.set_window_should_close(window, True)

    if key == glfw.KEY_W and action == glfw.PRESS:
        forward = True
    elif key == glfw.KEY_W and action == glfw.RELEASE:
        forward = False
    if key == glfw.KEY_S and action == glfw.PRESS:
        backward = True
    elif key == glfw.KEY_S and action == glfw.RELEASE:
        backward = False
    if key == glfw.KEY_A and action == glfw.PRESS:
        left = True
    elif key == glfw.KEY_A and action == glfw.RELEASE:
        left = False
    if key == glfw.KEY_D and action == glfw.PRESS:
        right = True
    elif key == glfw.KEY_D and action == glfw.RELEASE:
        right = False


# do the movement, call this function in the main loop 
開發者ID:totex,項目名稱:Learn-OpenGL-in-python,代碼行數:26,代碼來源:ep21_texturing_from_framebuffers.py

示例4: key_callback

# 需要導入模塊: import glfw [as 別名]
# 或者: from glfw import RELEASE [as 別名]
def key_callback(self, window, key, scancode, action, mods):
        # Trigger on keyup only:
        if action != glfw.RELEASE:
            return
        if key == glfw.KEY_ESCAPE:
            self.env.close()

        # Increment experiment seed
        elif key == glfw.KEY_N:
            self.seed[0] += 1
            self.env.seed(self.seed)
            self.env_reset()
            self.action = self.zero_action(self.env.action_space)
        # Decrement experiment trial
        elif key == glfw.KEY_P:
            self.seed = [max(self.seed[0] - 1, 0)]
            self.env.seed(self.seed)
            self.env_reset()
            self.action = self.zero_action(self.env.action_space)
        if key == glfw.KEY_A:
            if isinstance(self.env.action_space, Box):
                self.action[self.action_mod_index] -= 0.05
        elif key == glfw.KEY_Z:
            if isinstance(self.env.action_space, Box):
                self.action[self.action_mod_index] += 0.05
        elif key == glfw.KEY_K:
            self.action_mod_index = (self.action_mod_index + 1) % self.num_action
        elif key == glfw.KEY_J:
            self.action_mod_index = (self.action_mod_index - 1) % self.num_action

        super().key_callback(window, key, scancode, action, mods) 
開發者ID:openai,項目名稱:mujoco-worldgen,代碼行數:33,代碼來源:env_viewer.py

示例5: keyboard_callback

# 需要導入模塊: import glfw [as 別名]
# 或者: from glfw import RELEASE [as 別名]
def keyboard_callback(self, window, key, scancode, action, mods):
        # perf: local for faster access
        io = self.io

        if action == glfw.PRESS:
            io.keys_down[key] = True
        elif action == glfw.RELEASE:
            io.keys_down[key] = False

        io.key_ctrl = (
            io.keys_down[glfw.KEY_LEFT_CONTROL] or
            io.keys_down[glfw.KEY_RIGHT_CONTROL]
        )

        io.key_alt = (
            io.keys_down[glfw.KEY_LEFT_ALT] or
            io.keys_down[glfw.KEY_RIGHT_ALT]
        )

        io.key_shift = (
            io.keys_down[glfw.KEY_LEFT_SHIFT] or
            io.keys_down[glfw.KEY_RIGHT_SHIFT]
        )

        io.key_super = (
            io.keys_down[glfw.KEY_LEFT_SUPER] or
            io.keys_down[glfw.KEY_RIGHT_SUPER]
        ) 
開發者ID:swistakm,項目名稱:pyimgui,代碼行數:30,代碼來源:glfw.py

示例6: key_input_clb

# 需要導入模塊: import glfw [as 別名]
# 或者: from glfw import RELEASE [as 別名]
def key_input_clb(window, key, scancode, action, mode):
    global left, right, forward, backward
    if key == glfw.KEY_ESCAPE and action == glfw.PRESS:
        glfw.set_window_should_close(window, True)

    if key == glfw.KEY_W and action == glfw.PRESS:
        forward = True
    elif key == glfw.KEY_W and action == glfw.RELEASE:
        forward = False
    if key == glfw.KEY_S and action == glfw.PRESS:
        backward = True
    elif key == glfw.KEY_S and action == glfw.RELEASE:
        backward = False
    if key == glfw.KEY_A and action == glfw.PRESS:
        left = True
    elif key == glfw.KEY_A and action == glfw.RELEASE:
        left = False
    if key == glfw.KEY_D and action == glfw.PRESS:
        right = True
    elif key == glfw.KEY_D and action == glfw.RELEASE:
        right = False
    # if key in [glfw.KEY_W, glfw.KEY_S, glfw.KEY_D, glfw.KEY_A] and action == glfw.RELEASE:
    #     left, right, forward, backward = False, False, False, False


# do the movement, call this function in the main loop 
開發者ID:totex,項目名稱:Learn-OpenGL-in-python,代碼行數:28,代碼來源:ep18_camera_WASD.py

示例7: _handle_key_event

# 需要導入模塊: import glfw [as 別名]
# 或者: from glfw import RELEASE [as 別名]
def _handle_key_event(self, window, key, scancode, activity, mods):
    """Broadcasts the notification to registered listeners.

    Args:
      window: The window that received the event.
      key: ID representing the key, a glfw.KEY_ constant.
      scancode: The system-specific scancode of the key.
      activity: glfw.PRESS, glfw.RELEASE or glfw.REPEAT.
      mods: Bit field describing which modifier keys were held down, such as Alt
        or Shift.
    """
    del window, scancode
    self.add_event(self.on_key, key, activity, mods) 
開發者ID:deepmind,項目名稱:dm_control,代碼行數:15,代碼來源:glfw_gui.py

示例8: key_callback

# 需要導入模塊: import glfw [as 別名]
# 或者: from glfw import RELEASE [as 別名]
def key_callback(self, window, key, scancode, action, mods):
        # Trigger on keyup only:
        if action != glfw.RELEASE:
            return
        if key == glfw.KEY_ESCAPE:
            self.env.close()

        # Increment experiment seed
        elif key == glfw.KEY_N:
            self.seed[0] += 1
            self.env.seed(self.seed)
            self.env_reset()
            self.action = self.zero_action(self.env.action_space)
        # Decrement experiment trial
        elif key == glfw.KEY_P:
            self.seed = [max(self.seed[0] - 1, 0)]
            self.env.seed(self.seed)
            self.env_reset()
            self.action = self.zero_action(self.env.action_space)
        current_action_space = self.env.action_space.spaces[self.action_types[self.action_type_mod_index]].spaces[0]
        if key == glfw.KEY_A:
            if isinstance(current_action_space, Box):
                self.action[self.action_types[self.action_type_mod_index]][self.agent_mod_index][self.action_mod_index] -= 0.05
            elif isinstance(current_action_space, Discrete):
                self.action[self.action_types[self.action_type_mod_index]][self.agent_mod_index] = \
                    (self.action[self.action_types[self.action_type_mod_index]][self.agent_mod_index] - 1) % current_action_space.n
            elif isinstance(current_action_space, MultiDiscrete):
                self.action[self.action_types[self.action_type_mod_index]][self.agent_mod_index][self.action_mod_index] = \
                    (self.action[self.action_types[self.action_type_mod_index]][self.agent_mod_index][self.action_mod_index] - 1) \
                    % current_action_space.nvec[self.action_mod_index]
        elif key == glfw.KEY_Z:
            if isinstance(current_action_space, Box):
                self.action[self.action_types[self.action_type_mod_index]][self.agent_mod_index][self.action_mod_index] += 0.05
            elif isinstance(current_action_space, Discrete):
                self.action[self.action_types[self.action_type_mod_index]][self.agent_mod_index] = \
                    (self.action[self.action_types[self.action_type_mod_index]][self.agent_mod_index] + 1) % current_action_space.n
            elif isinstance(current_action_space, MultiDiscrete):
                self.action[self.action_types[self.action_type_mod_index]][self.agent_mod_index][self.action_mod_index] = \
                    (self.action[self.action_types[self.action_type_mod_index]][self.agent_mod_index][self.action_mod_index] + 1) \
                    % current_action_space.nvec[self.action_mod_index]
        elif key == glfw.KEY_K:
            self.action_mod_index = (self.action_mod_index + 1) % self.num_action[self.action_type_mod_index]
        elif key == glfw.KEY_J:
            self.action_mod_index = (self.action_mod_index - 1) % self.num_action[self.action_type_mod_index]
        elif key == glfw.KEY_Y:
            self.agent_mod_index = (self.agent_mod_index + 1) % self.n_agents
        elif key == glfw.KEY_U:
            self.agent_mod_index = (self.agent_mod_index - 1) % self.n_agents
        elif key == glfw.KEY_G:
            self.action_type_mod_index = (self.action_type_mod_index + 1) % self.num_action_types
            self.action_mod_index = 0
        elif key == glfw.KEY_B:
            self.action_type_mod_index = (self.action_type_mod_index - 1) % self.num_action_types
            self.action_mod_index = 0

        super().key_callback(window, key, scancode, action, mods) 
開發者ID:openai,項目名稱:multi-agent-emergence-environments,代碼行數:58,代碼來源:env_viewer.py


注:本文中的glfw.RELEASE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。