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


Python pymunk.Space方法代码示例

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


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

示例1: __init__

# 需要导入模块: import pymunk [as 别名]
# 或者: from pymunk import Space [as 别名]
def __init__(self, game):
        super().__init__(game)
        self.player = None
        self.active = True

        self.geometry = list()
        self.space = Space()
        self.space.gravity = (0, 1000)
        self.sprites = LayeredUpdates()
        self.event_handler = event_handling.EventQueueHandler()
        self.background = resources.gfx("background.png", convert=True)
        self.load()
        pygame.mixer.music.load(resources.music_path("zirkus.ogg"))
        pygame.mixer.music.play(-1) 
开发者ID:pygame,项目名称:stuntcat,代码行数:16,代码来源:platformer.py

示例2: __init__

# 需要导入模块: import pymunk [as 别名]
# 或者: from pymunk import Space [as 别名]
def __init__(self):
        self.space = pymunk.Space()
        self.space.gravity = 0, 200
        self.add_wall(self.space, (0, 400), (600, 400))  # ground
        self.add_wall(self.space, (0, 0), (0, 600))  # Left side
        self.add_wall(self.space, (600, 0), (600, 400))  # right side 
开发者ID:PySimpleGUI,项目名称:PySimpleGUI,代码行数:8,代码来源:Demo_Graph_pymunk_2D_Graphics.py

示例3: __init__

# 需要导入模块: import pymunk [as 别名]
# 或者: from pymunk import Space [as 别名]
def __init__(self):
        self.space = pymunk.Space()
        self.space.gravity = 0, 200
        self.add_wall((0, 400), (600, 400))  # ground
        self.add_wall((0, 0), (0, 600))  # Left side
        self.add_wall((600, 0), (600, 400))  # right side 
开发者ID:PySimpleGUI,项目名称:PySimpleGUI,代码行数:8,代码来源:Demo_Graph_pymunk_2D_Graphics.py

示例4: __init__

# 需要导入模块: import pymunk [as 别名]
# 或者: from pymunk import Space [as 别名]
def __init__(self, graph_elem):
        self.space = pymunk.Space()
        self.space.gravity = 0, 200
        self.add_wall((0, 400), (600, 400))  # ground
        self.add_wall((0, 0), (0, 600))  # Left side
        self.add_wall((600, 0), (600, 400))  # right side
        self.arena_balls = []               # type: [] Ball
        self.graph_elem = graph_elem        # type: sg.Graph 
开发者ID:PySimpleGUI,项目名称:PySimpleGUI,代码行数:10,代码来源:Demo_Graph_Ball_Game.py

示例5: __init__

# 需要导入模块: import pymunk [as 别名]
# 或者: from pymunk import Space [as 别名]
def __init__(self, graph_elem):
        self.space = pymunk.Space()
        self.space.gravity = 0, 200
        self.add_wall((0, 400), (600, 400))  # ground
        self.add_wall((0, 0), (0, 600))  # Left side
        self.add_wall((600, 0), (600, 400))  # right side
        self.arena_balls = []               # type: List[Ball]
        self.graph_elem = graph_elem        # type: sg.Graph 
开发者ID:PySimpleGUI,项目名称:PySimpleGUI,代码行数:10,代码来源:Demo_Graph_Ball_Game.py

示例6: __init__

# 需要导入模块: import pymunk [as 别名]
# 或者: from pymunk import Space [as 别名]
def __init__(self):
        # Global-ish.
        self.crashed = False

        # Physics stuff.
        self.space = pymunk.Space()
        self.space.gravity = pymunk.Vec2d(0., 0.)

        # Create the car.
        self.create_car(100, 100, 0.5)

        # Record steps.
        self.num_steps = 0

        # Create walls.
        static = [
            pymunk.Segment(
                self.space.static_body,
                (0, 1), (0, height), 1),
            pymunk.Segment(
                self.space.static_body,
                (1, height), (width, height), 1),
            pymunk.Segment(
                self.space.static_body,
                (width-1, height), (width-1, 1), 1),
            pymunk.Segment(
                self.space.static_body,
                (1, 1), (width, 1), 1)
        ]
        for s in static:
            s.friction = 1.
            s.group = 1
            s.collision_type = 1
            s.color = THECOLORS['red']
        self.space.add(static)

        # Create some obstacles, semi-randomly.
        # We'll create three and they'll move around to prevent over-fitting.
        self.obstacles = []
        self.obstacles.append(self.create_obstacle(200, 350, 100))
        self.obstacles.append(self.create_obstacle(700, 200, 125))
        self.obstacles.append(self.create_obstacle(600, 600, 35))

        # Create a cat.
        self.create_cat() 
开发者ID:llSourcell,项目名称:Self-Driving-Car-Demo,代码行数:47,代码来源:carmunk.py

示例7: __init__

# 需要导入模块: import pymunk [as 别名]
# 或者: from pymunk import Space [as 别名]
def __init__(self, noisey=False, map_style='default'):
        # Noisey sensors?
        self.noisey = noisey

        # Physics stuff.
        self.space = pymunk.Space()
        self.space.gravity = pymunk.Vec2d(0., 0.)

        # Create the car.
        self.create_car(100, 100, -0.75)
        self.driving_direction = 0

        # Record steps.
        self.num_steps = 0

        # Which map?
        self.map_style = map_style

        # Create outer walls.
        static = [
            pymunk.Segment(
                self.space.static_body,
                (0, 1), (0, height), 1),
            pymunk.Segment(
                self.space.static_body,
                (1, height), (width, height), 1),
            pymunk.Segment(
                self.space.static_body,
                (width-1, height), (width-1, 1), 1),
            pymunk.Segment(
                self.space.static_body,
                (1, 1), (width, 1), 1)
        ]
        for s in static:
            s.friction = 1.
            s.group = 1
            s.collision_type = 1
            s.color = THECOLORS['red']
        self.space.add(static)

        if map_style == 'default':
            self.create_default_map()
            # Create a cat.
            self.create_cat()
        elif map_style == 'linear':
            # Used for testing a trained model mostly.
            self.create_linear_map()

        # Initialize our sensors.
        self.sensor_obj = sensors.Sensors(width, height, screen, pygame, False) 
开发者ID:harvitronix,项目名称:rl-rc-car,代码行数:52,代码来源:carmunk.py


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