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


Python locals.K_w方法代码示例

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


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

示例1: _parse_vehicle_keys

# 需要导入模块: from pygame import locals [as 别名]
# 或者: from pygame.locals import K_w [as 别名]
def _parse_vehicle_keys(self, keys, milliseconds):
        """
        Calculate new vehicle controls based on input keys
        """
        self._control.throttle = 0.6 if keys[K_UP] or keys[K_w] else 0.0
        steer_increment = 15.0 * 5e-4 * milliseconds
        if keys[K_LEFT] or keys[K_a]:
            self._steer_cache -= steer_increment
        elif keys[K_RIGHT] or keys[K_d]:
            self._steer_cache += steer_increment
        else:
            self._steer_cache = 0.0

        self._steer_cache = min(0.95, max(-0.95, self._steer_cache))
        self._control.steer = round(self._steer_cache, 1)
        self._control.brake = 1.0 if keys[K_DOWN] or keys[K_s] else 0.0
        self._control.hand_brake = keys[K_SPACE] 
开发者ID:carla-simulator,项目名称:scenario_runner,代码行数:19,代码来源:human_agent.py

示例2: _get_keyboard_control

# 需要导入模块: from pygame import locals [as 别名]
# 或者: from pygame.locals import K_w [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

示例3: _parse_vehicle_keys

# 需要导入模块: from pygame import locals [as 别名]
# 或者: from pygame.locals import K_w [as 别名]
def _parse_vehicle_keys(self, keys, milliseconds):
        """
        parse key events
        """
        self._control.throttle = 1.0 if keys[K_UP] or keys[K_w] else 0.0
        steer_increment = 5e-4 * milliseconds
        if keys[K_LEFT] or keys[K_a]:
            self._steer_cache -= steer_increment
        elif keys[K_RIGHT] or keys[K_d]:
            self._steer_cache += steer_increment
        else:
            self._steer_cache = 0.0
        self._steer_cache = min(0.7, max(-0.7, self._steer_cache))
        self._control.steer = round(self._steer_cache, 1)
        self._control.brake = 1.0 if keys[K_DOWN] or keys[K_s] else 0.0
        self._control.hand_brake = keys[K_SPACE] 
开发者ID:carla-simulator,项目名称:ros-bridge,代码行数:18,代码来源:carla_manual_control.py

示例4: _parse_keys

# 需要导入模块: from pygame import locals [as 别名]
# 或者: from pygame.locals import K_w [as 别名]
def _parse_keys(self, milliseconds):
        keys = pygame.key.get_pressed()
        self.control.throttle = 1.0 if keys[K_UP] or keys[K_w] else 0.0
        steer_increment = 5e-4 * milliseconds
        if keys[K_LEFT] or keys[K_a]:
            self._steer_cache -= steer_increment
        elif keys[K_RIGHT] or keys[K_d]:
            self._steer_cache += steer_increment
        else:
            self._steer_cache = 0.0
        self._steer_cache = min(0.7, max(-0.7, self._steer_cache))
        self.control.steer = round(self._steer_cache, 1)
        self.control.brake = 1.0 if keys[K_DOWN] or keys[K_s] else 0.0
        self.control.hand_brake = keys[K_SPACE] 
开发者ID:carla-simulator,项目名称:scenario_runner,代码行数:16,代码来源:no_rendering_mode.py

示例5: _parse_keys

# 需要导入模块: from pygame import locals [as 别名]
# 或者: from pygame.locals import K_w [as 别名]
def _parse_keys(self, keys, milliseconds):
        self._control.throttle = 1.0 if keys[K_UP] or keys[K_w] else 0.0
        steer_increment = 5e-4 * milliseconds
        if keys[K_LEFT] or keys[K_a]:
            self._steer_cache -= steer_increment
        elif keys[K_RIGHT] or keys[K_d]:
            self._steer_cache += steer_increment
        else:
            self._steer_cache = 0.0
        self._steer_cache = min(0.7, max(-0.7, self._steer_cache))
        self._control.steer = round(self._steer_cache, 1)
        self._control.brake = 1.0 if keys[K_DOWN] or keys[K_s] else 0.0
        self._control.hand_brake = keys[K_SPACE] 
开发者ID:praveen-palanisamy,项目名称:macad-gym,代码行数:15,代码来源:manual_control.py

示例6: _parse_keys

# 需要导入模块: from pygame import locals [as 别名]
# 或者: from pygame.locals import K_w [as 别名]
def _parse_keys(self, keys, milliseconds):
        self._control.throttle = 1.0 if keys[K_UP] or keys[K_w] else 0.0
        steer_increment = 5e-3 * milliseconds
        if keys[K_LEFT] or keys[K_a]:
            self._steer_cache -= steer_increment
        elif keys[K_RIGHT] or keys[K_d]:
            self._steer_cache += steer_increment
        else:
            self._steer_cache = 0.0
        self._steer_cache = min(0.7, max(-0.7, self._steer_cache))
        self._control.steer = round(self._steer_cache, 1)
        self._control.brake = 1.0 if keys[K_DOWN] or keys[K_s] else 0.0
        self._control.hand_brake = keys[K_SPACE] 
开发者ID:praveen-palanisamy,项目名称:macad-gym,代码行数:15,代码来源:spawn_control.py

示例7: _parse_keys1

# 需要导入模块: from pygame import locals [as 别名]
# 或者: from pygame.locals import K_w [as 别名]
def _parse_keys1(self, keys, milliseconds):
        self._control.throttle = 1.0 if keys[K_w] else 0.0
        steer_increment = 5e-4 * milliseconds
        if keys[K_a]:
            self._steer_cache -= steer_increment
        elif keys[K_d]:
            self._steer_cache += steer_increment
        else:
            self._steer_cache = 0.0
        self._steer_cache = min(0.7, max(-0.7, self._steer_cache))
        self._control.steer = round(self._steer_cache, 1)
        self._control.brake = 1.0 if keys[K_s] else 0.0
        self._control.hand_brake = keys[K_SPACE] 
开发者ID:praveen-palanisamy,项目名称:macad-gym,代码行数:15,代码来源:keyboard_control.py


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