当前位置: 首页>>代码示例>>Python>>正文


Python locals.K_q方法代码示例

本文整理汇总了Python中pygame.locals.K_q方法的典型用法代码示例。如果您正苦于以下问题:Python locals.K_q方法的具体用法?Python locals.K_q怎么用?Python locals.K_q使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pygame.locals的用法示例。


在下文中一共展示了locals.K_q方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _get_keyboard_control

# 需要导入模块: from pygame import locals [as 别名]
# 或者: from pygame.locals import K_q [as 别名]
def _get_keyboard_control(self, keys):
        """
        Return a VehicleControl message based on the pressed keys.

        Return None
        if a new episode was requested.
        """

        control = VehicleControl()
        if keys[K_LEFT] or keys[K_a]:
            control.steer = -1.0
        if keys[K_RIGHT] or keys[K_d]:
            control.steer = 1.0
        if keys[K_UP] or keys[K_w]:
            control.throttle = 1.0
        if keys[K_DOWN] or keys[K_s]:
            control.brake = 1.0
        if keys[K_SPACE]:
            control.hand_brake = True
        if keys[K_q]:
            self._is_on_reverse = not self._is_on_reverse
        control.reverse = self._is_on_reverse
        return control 
开发者ID:felipecode,项目名称:coiltraine,代码行数:25,代码来源:human_agent.py

示例2: _is_quit_shortcut

# 需要导入模块: from pygame import locals [as 别名]
# 或者: from pygame.locals import K_q [as 别名]
def _is_quit_shortcut(key):
        return (key == K_ESCAPE) or (key == K_q and pygame.key.get_mods() & KMOD_CTRL)


# ==============================================================================
# -- Global Objects ------------------------------------------------------------
# ============================================================================== 
开发者ID:carla-simulator,项目名称:scenario_runner,代码行数:9,代码来源:no_rendering_mode.py

示例3: _is_quit_shortcut

# 需要导入模块: from pygame import locals [as 别名]
# 或者: from pygame.locals import K_q [as 别名]
def _is_quit_shortcut(key):
        return (key == K_ESCAPE) or (key == K_q and pygame.key.get_mods() & KMOD_CTRL)


# ==============================================================================
# -- HUD -----------------------------------------------------------------
# ============================================================================== 
开发者ID:felipecode,项目名称:coiltraine,代码行数:9,代码来源:carla08interface.py

示例4: _is_quit_shortcut

# 需要导入模块: from pygame import locals [as 别名]
# 或者: from pygame.locals import K_q [as 别名]
def _is_quit_shortcut(key):
        return (key == K_ESCAPE) or (key == K_q and pygame.key.get_mods() & KMOD_CTRL) 
开发者ID:felipecode,项目名称:coiltraine,代码行数:4,代码来源:carla09interface.py

示例5: parse_events

# 需要导入模块: from pygame import locals [as 别名]
# 或者: from pygame.locals import K_q [as 别名]
def parse_events(self, world, clock):
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                return True
            elif event.type == pygame.KEYUP:
                if self._is_quit_shortcut(event.key):
                    return True
                elif event.key == K_BACKSPACE:
                    world.restart()
                elif event.key == K_h or (event.key == K_SLASH and pygame.key.get_mods() & KMOD_SHIFT):
                    world.hud.help.toggle()
                elif event.key == K_TAB:
                    world.camera_manager.toggle_camera()
                elif event.key == K_c and pygame.key.get_mods() & KMOD_SHIFT:
                    world.next_weather(reverse=True)
                elif event.key == K_c:
                    world.next_weather()
                elif event.key == K_BACKQUOTE:
                    world.camera_manager.next_sensor()
                elif event.key > K_0 and event.key <= K_9:
                    world.camera_manager.set_sensor(event.key - 1)
                elif event.key == K_r:
                    world.camera_manager.toggle_recording()
                elif event.key == K_q:
                    self._control.reverse = not self._control.reverse
                elif event.key == K_p:
                    self._autopilot_enabled = not self._autopilot_enabled
                    world.vehicle.set_autopilot(self._autopilot_enabled)
                    world.hud.notification('Autopilot %s' % ('On' if self._autopilot_enabled else 'Off'))
        if not self._autopilot_enabled:
            self._parse_keys(pygame.key.get_pressed(), clock.get_time())
            world.vehicle.apply_control(self._control) 
开发者ID:praveen-palanisamy,项目名称:macad-gym,代码行数:34,代码来源:manual_control.py

示例6: _is_quit_shortcut

# 需要导入模块: from pygame import locals [as 别名]
# 或者: from pygame.locals import K_q [as 别名]
def _is_quit_shortcut(key):
        return (key == K_ESCAPE) or (key == K_q and pygame.key.get_mods() & KMOD_CTRL)


# ==============================================================================
# -- HUD -----------------------------------------------------------------------
# ============================================================================== 
开发者ID:praveen-palanisamy,项目名称:macad-gym,代码行数:9,代码来源:manual_control.py

示例7: _is_quit_shortcut

# 需要导入模块: from pygame import locals [as 别名]
# 或者: from pygame.locals import K_q [as 别名]
def _is_quit_shortcut(key):
        return (key == K_ESCAPE) or (key == K_q
                                     and pygame.key.get_mods() & KMOD_CTRL)


# ==============================================================================
# -- HUD -----------------------------------------------------------------------
# ============================================================================== 
开发者ID:praveen-palanisamy,项目名称:macad-gym,代码行数:10,代码来源:spawn_control.py

示例8: _is_quit_shortcut

# 需要导入模块: from pygame import locals [as 别名]
# 或者: from pygame.locals import K_q [as 别名]
def _is_quit_shortcut(key):
        return (key == K_ESCAPE) or (key == K_q
                                     and pygame.key.get_mods() & KMOD_CTRL) 
开发者ID:praveen-palanisamy,项目名称:macad-gym,代码行数:5,代码来源:keyboard_control.py

示例9: parse_events

# 需要导入模块: from pygame import locals [as 别名]
# 或者: from pygame.locals import K_q [as 别名]
def parse_events(self, clock):
        """
        parse an input event
        """
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                return True
            elif event.type == pygame.KEYUP:
                if self._is_quit_shortcut(event.key):
                    return True
                elif event.key == K_F1:
                    self.hud.toggle_info()
                elif event.key == K_h or (event.key == K_SLASH and
                                          pygame.key.get_mods() & KMOD_SHIFT):
                    self.hud.help.toggle()
                elif event.key == K_b:
                    self.vehicle_control_manual_override = not self.vehicle_control_manual_override
                    self.set_vehicle_control_manual_override(self.vehicle_control_manual_override)
                if event.key == K_q:
                    self._control.gear = 1 if self._control.reverse else -1
                elif event.key == K_m:
                    self._control.manual_gear_shift = not self._control.manual_gear_shift
                    self.hud.notification('%s Transmission' % (
                        'Manual' if self._control.manual_gear_shift else 'Automatic'))
                elif self._control.manual_gear_shift and event.key == K_COMMA:
                    self._control.gear = max(-1, self._control.gear - 1)
                elif self._control.manual_gear_shift and event.key == K_PERIOD:
                    self._control.gear = self._control.gear + 1
                elif event.key == K_p:
                    self._autopilot_enabled = not self._autopilot_enabled
                    self.set_autopilot(self._autopilot_enabled)
                    self.hud.notification('Autopilot %s' % (
                        'On' if self._autopilot_enabled else 'Off'))
        if not self._autopilot_enabled and self.vehicle_control_manual_override:
            self._parse_vehicle_keys(pygame.key.get_pressed(), clock.get_time())
            self._control.reverse = self._control.gear < 0 
开发者ID:carla-simulator,项目名称:ros-bridge,代码行数:38,代码来源:carla_manual_control.py

示例10: process_pygame_events

# 需要导入模块: from pygame import locals [as 别名]
# 或者: from pygame.locals import K_q [as 别名]
def process_pygame_events(self):
        """
        pygame events are how we learn about a window being closed or
        resized or a key being pressed. This function looks for the events
        we care about and reacts when needed.
        """

        for event in pygame.event.get():
            if event.type == QUIT:
                self.running = False
            elif event.type == VIDEORESIZE:
                self.my_weather_rock.sizing(event.size)
            elif event.type == KEYDOWN:

                # On 'q' or keypad enter key, quit the program.
                if ((event.key == K_KP_ENTER) or (event.key == K_q)):
                    self.running = False

                # On 'd' key, set mode to 'daily weather'.
                elif event.key == K_d:
                    self.current_screen = 'd'
                    self.d_count = 1
                    self.h_count = 0
                    self.non_weather_timeout = 0
                    self.periodic_info_activation = 0

                # on 'h' key, set mode to 'hourly weather'
                elif event.key == K_h:
                    self.current_screen = 'h'
                    self.d_count = 0
                    self.h_count = 1
                    self.non_weather_timeout = 0
                    self.periodic_info_activation = 0

                # On 'i' key, set mode to 'info'.
                elif event.key == K_i:
                    self.current_screen = 'i'
                    self.d_count = 0
                    self.h_count = 0
                    self.non_weather_timeout = 0
                    self.periodic_info_activation = 0

                # On 's' key, save a screen shot.
                elif event.key == K_s:
                    self.my_weather_rock.screen_cap() 
开发者ID:genebean,项目名称:PiWeatherRock,代码行数:47,代码来源:runner.py

示例11: parse_events

# 需要导入模块: from pygame import locals [as 别名]
# 或者: from pygame.locals import K_q [as 别名]
def parse_events(self, world, clock):
        self.vehicle = world.actor_list[self.actor_id]
        self.vehicle.set_autopilot(self._autopilot_enabled)
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                return True
            elif event.type == pygame.KEYUP:
                if self._is_quit_shortcut(event.key):
                    return True
                elif event.key == K_BACKSPACE:
                    world.restart()
                elif event.key == K_F1:
                    world.hud.toggle_info()
                elif event.key == K_h or (event.key == K_SLASH and
                                          pygame.key.get_mods() & KMOD_SHIFT):
                    world.hud.help.toggle()
                elif event.key == K_TAB:
                    world.camera_manager.toggle_camera()
                elif event.key == K_c and pygame.key.get_mods() & KMOD_SHIFT:
                    world.next_weather(reverse=True)
                elif event.key == K_c:
                    world.next_weather()
                elif event.key == K_BACKQUOTE:
                    world.camera_manager.next_sensor()
                elif event.key > K_0 and event.key <= K_9:
                    world.camera_manager.set_sensor(event.key - 1 - K_0)
                elif event.key == K_r:
                    world.camera_manager.toggle_recording()
                elif event.key == K_q:
                    self._control.reverse = not self._control.reverse
                elif event.key == K_p:
                    self._autopilot_enabled = not self._autopilot_enabled
                    self.vehicle.set_autopilot(self._autopilot_enabled)
                    world.hud.notification(
                        'Autopilot %s' %
                        ('On' if self._autopilot_enabled else 'Off'))
        if not self._autopilot_enabled:
            if self.actor_id == 0:
                self._parse_keys1(pygame.key.get_pressed(), clock.get_time())
            elif self.actor_id == 1:
                self._parse_keys2(pygame.key.get_pressed(), clock.get_time())
            elif self.actor_id == -1:  # use default ones
                self._parse_keys(pygame.key.get_pressed(), clock.get_time())
            self.vehicle.apply_control(self._control) 
开发者ID:praveen-palanisamy,项目名称:macad-gym,代码行数:46,代码来源:keyboard_control.py


注:本文中的pygame.locals.K_q方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。