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


Python pymunk.moment_for_circle方法代码示例

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


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

示例1: __init__

# 需要导入模块: import pymunk [as 别名]
# 或者: from pymunk import moment_for_circle [as 别名]
def __init__(self, distance, angle, x, y, space):
        self.life = 20
        mass = 5
        radius = 12
        inertia = pm.moment_for_circle(mass, 0, radius, (0, 0))
        body = pm.Body(mass, inertia)
        body.position = x, y
        power = distance * 53
        impulse = power * Vec2d(1, 0)
        angle = -angle
        body.apply_impulse_at_local_point(impulse.rotated(angle))
        shape = pm.Circle(body, radius, (0, 0))
        shape.elasticity = 0.95
        shape.friction = 1
        shape.collision_type = 0
        space.add(body, shape)
        self.body = body
        self.shape = shape 
开发者ID:estevaofon,项目名称:angry-birds-python,代码行数:20,代码来源:characters.py

示例2: add_ball

# 需要导入模块: import pymunk [as 别名]
# 或者: from pymunk import moment_for_circle [as 别名]
def add_ball(space):
    mass    = 0.01
    radius  = 3
    inertia = pymunk.moment_for_circle(mass, 0, radius, (0,0))
    x = random.randint(181,182)

    body = pymunk.Body(mass, inertia)
    body._bodycontents.v_limit = 120
    body._bodycontents.h_limit = 1
    body.position = x, 410

    shape = pymunk.Circle(body, radius, (0,0))
    shape.collision_type = 0x6 #liquid
    space.add(body, shape)

    return shape 
开发者ID:jseidl,项目名称:virtuaplant,代码行数:18,代码来源:world.py

示例3: __init__

# 需要导入模块: import pymunk [as 别名]
# 或者: from pymunk import moment_for_circle [as 别名]
def __init__(self, distance, angle, x_pos, y_pos, space):
        weight = 5
        r = 12 #radius
        value_of_inertia = p.moment_for_circle(weight, 0, r, (0, 0))
        obj_body = p.Body(weight, value_of_inertia)
        obj_body.position = x_pos, y_pos
        power_value = distance * 53
        impulse = power_value * Vec2d(1, 0)
        angle = -angle
        obj_body.apply_impulse_at_local_point(impulse.rotated(angle))
        obj_shape = p.Circle(obj_body, r, (0, 0))
        obj_shape.elasticity = 0.95 #bouncing angry bird
        obj_shape.friction = 1 #for roughness
        obj_shape.collision_type = 0 #for checking collisions later
        space.add(obj_body, obj_shape)
        #class RoundBird attribute ----
        self.body = obj_body
        self.shape = obj_shape 
开发者ID:PacktPublishing,项目名称:Learning-Python-by-building-games,代码行数:20,代码来源:characters.py

示例4: __init__

# 需要导入模块: import pymunk [as 别名]
# 或者: from pymunk import moment_for_circle [as 别名]
def __init__(self, space, x, y, radius, mass, static, cosmetic=False):
        if not cosmetic:
            moment = pymunk.moment_for_circle(mass, 0, radius)

            if static:
                self.body = pymunk.Body(mass, moment, pymunk.Body.STATIC)
            else:
                self.body = pymunk.Body(mass, moment)

            self.body.position = x, y
            self.shape = pymunk.Circle(self.body, radius)
            space.add(self.body, self.shape)

        self.static = static
        self._draw_radius_line = False
        self._x = x
        self._y = y
        self._radius = radius

        super().__init__(cosmetic) 
开发者ID:jshaffstall,项目名称:PyPhysicsSandbox,代码行数:22,代码来源:ball_shape.py

示例5: init_pockets

# 需要导入模块: import pymunk [as 别名]
# 或者: from pymunk import moment_for_circle [as 别名]
def init_pockets(space):
    pockets = []
    for i in [(44.1, 44.1), (755.9, 44.1), (755.9, 755.9), (44.1, 755.9)]:
        inertia = pymunk.moment_for_circle(0.1, 0, POCKET_RADIUS, (0, 0))
        body = pymunk.Body(0.1, inertia)
        body.position = i
        shape = pymunk.Circle(body, POCKET_RADIUS, (0, 0))
        shape.color = POCKET_COLOR
        shape.collision_type = 2
        shape.filter = pymunk.ShapeFilter(categories=0b1000)
        space.add(body, shape)
        pockets.append(shape)
        del body
        del shape
    return pockets

# Initialize striker with force 
开发者ID:samiranrl,项目名称:Carrom_rl,代码行数:19,代码来源:Utils.py

示例6: init_striker

# 需要导入模块: import pymunk [as 别名]
# 或者: from pymunk import moment_for_circle [as 别名]
def init_striker(space, x, passthrough, action, player):

    inertia = pymunk.moment_for_circle(STRIKER_MASS, 0, STRIKER_RADIUS, (0, 0))
    body = pymunk.Body(STRIKER_MASS, inertia)
    if player == 1:
        body.position = (action[0], 140)
    if player == 2:
        body.position = (action[0], BOARD_SIZE - 140)
    body.apply_force_at_world_point((cos(action[1]) * action[2], sin(
        action[1]) * action[2]), body.position + (STRIKER_RADIUS * 0, STRIKER_RADIUS * 0))

    shape = pymunk.Circle(body, STRIKER_RADIUS, (0, 0))
    shape.elasticity = STRIKER_ELASTICITY
    shape.color = STRIKER_COLOR

    mask = pymunk.ShapeFilter.ALL_MASKS ^ passthrough.filter.categories

    sf = pymunk.ShapeFilter(mask=mask)
    shape.filter = sf
    shape.collision_type = 2

    space.add(body, shape)
    return [body, shape]

# Adds coins to the board at the given coordinates 
开发者ID:samiranrl,项目名称:Carrom_rl,代码行数:27,代码来源:Utils.py

示例7: init_striker

# 需要导入模块: import pymunk [as 别名]
# 或者: from pymunk import moment_for_circle [as 别名]
def init_striker(space, x, passthrough, action, player):

    inertia = pymunk.moment_for_circle(STRIKER_MASS, 0, STRIKER_RADIUS, (0, 0))
    body = pymunk.Body(STRIKER_MASS, inertia)
    if player == 1:
        body.position = (action[0], 145)
    if player == 2:
        body.position = (action[0], BOARD_SIZE - 136)
    body.apply_force_at_world_point((cos(action[1]) * action[2], sin(
        action[1]) * action[2]), body.position + (STRIKER_RADIUS * 0, STRIKER_RADIUS * 0))

    shape = pymunk.Circle(body, STRIKER_RADIUS, (0, 0))
    shape.elasticity = STRIKER_ELASTICITY
    shape.color = STRIKER_COLOR

    mask = pymunk.ShapeFilter.ALL_MASKS ^ passthrough.filter.categories

    sf = pymunk.ShapeFilter(mask=mask)
    shape.filter = sf
    shape.collision_type = 2

    space.add(body, shape)
    return [body, shape]

# Adds coins to the board at the given coordinates 
开发者ID:samiranrl,项目名称:Carrom_rl,代码行数:27,代码来源:Utils.py

示例8: init_pockets

# 需要导入模块: import pymunk [as 别名]
# 或者: from pymunk import moment_for_circle [as 别名]
def init_pockets(space):
    pockets = []
    for i in [(44.1, 43.1), (756.5, 43), (756.5, 756.5), (44, 756.5)]:
        inertia = pymunk.moment_for_circle(0.1, 0, POCKET_RADIUS, (0, 0))
        body = pymunk.Body(0.1, inertia)
        body.position = i
        shape = pymunk.Circle(body, POCKET_RADIUS, (0, 0))
        shape.color = POCKET_COLOR
        shape.collision_type = 2
        shape.filter = pymunk.ShapeFilter(categories=0b1000)
        space.add(body, shape)
        pockets.append(shape)
        del body
        del shape
    return pockets

# Initialize striker with force 
开发者ID:samiranrl,项目名称:Carrom_rl,代码行数:19,代码来源:Utils.py

示例9: create_cat

# 需要导入模块: import pymunk [as 别名]
# 或者: from pymunk import moment_for_circle [as 别名]
def create_cat(self):
        inertia = pymunk.moment_for_circle(1, 0, 14, (0, 0))
        self.cat_body = pymunk.Body(1, inertia)
        self.cat_body.position = 50, height - 100
        self.cat_shape = pymunk.Circle(self.cat_body, 30)
        self.cat_shape.color = THECOLORS["orange"]
        self.cat_shape.elasticity = 1.0
        self.cat_shape.angle = 0.5
        direction = Vec2d(1, 0).rotated(self.cat_body.angle)
        self.space.add(self.cat_body, self.cat_shape) 
开发者ID:llSourcell,项目名称:Self-Driving-Car-Demo,代码行数:12,代码来源:carmunk.py

示例10: create_car

# 需要导入模块: import pymunk [as 别名]
# 或者: from pymunk import moment_for_circle [as 别名]
def create_car(self, x, y, r):
        inertia = pymunk.moment_for_circle(1, 0, 14, (0, 0))
        self.car_body = pymunk.Body(1, inertia)
        self.car_body.position = x, y
        self.car_shape = pymunk.Circle(self.car_body, 25)
        self.car_shape.color = THECOLORS["green"]
        self.car_shape.elasticity = 1.0
        self.car_body.angle = r
        driving_direction = Vec2d(1, 0).rotated(self.car_body.angle)
        self.car_body.apply_impulse(driving_direction)
        self.space.add(self.car_body, self.car_shape) 
开发者ID:llSourcell,项目名称:Self-Driving-Car-Demo,代码行数:13,代码来源:carmunk.py

示例11: create_cat

# 需要导入模块: import pymunk [as 别名]
# 或者: from pymunk import moment_for_circle [as 别名]
def create_cat(self):
        inertia = pymunk.moment_for_circle(1, 0, 14, (0, 0))
        self.cat_body = pymunk.Body(1, inertia)
        self.cat_body.position = 800, 200
        self.cat_shape = pymunk.Circle(self.cat_body, 30)
        self.cat_shape.color = THECOLORS["orange"]
        self.car_shape.elasticity = 1.0
        self.cat_shape.angle = 0.5
        self.space.add(self.cat_body, self.cat_shape) 
开发者ID:harvitronix,项目名称:rl-rc-car,代码行数:11,代码来源:carmunk.py

示例12: create_car

# 需要导入模块: import pymunk [as 别名]
# 或者: from pymunk import moment_for_circle [as 别名]
def create_car(self, x, y, r):
        inertia = pymunk.moment_for_circle(1, 0, 14, (0, 0))
        self.car_body = pymunk.Body(1, inertia)
        self.car_body.position = x, y
        self.car_shape = pymunk.Circle(self.car_body, 15)
        self.car_shape.color = THECOLORS["green"]
        self.car_shape.elasticity = 1.0
        self.car_body.angle = r
        self.driving_direction = Vec2d(1, 0).rotated(self.car_body.angle)
        self.car_body.apply_impulse(self.driving_direction)
        self.space.add(self.car_body, self.car_shape) 
开发者ID:harvitronix,项目名称:rl-rc-car,代码行数:13,代码来源:carmunk.py

示例13: create_car

# 需要导入模块: import pymunk [as 别名]
# 或者: from pymunk import moment_for_circle [as 别名]
def create_car(self, x, y, r):
        inertia = pymunk.moment_for_circle(1, 0, 14, (0, 0))
        self.car_body = pymunk.Body(1, inertia)
        self.car_body.position = x, y
        self.car_shape = pymunk.Circle(self.car_body, r)
        self.car_shape.color = THECOLORS["green"]
        self.car_shape.elasticity = 1.0
        self.car_body.angle = 1.4
        driving_direction = Vec2d(1, 0).rotated(self.car_body.angle)
        self.car_body.apply_impulse(driving_direction)
        self.space.add(self.car_body, self.car_shape) 
开发者ID:jangirrishabh,项目名称:toyCarIRL,代码行数:13,代码来源:carmunk.py

示例14: __init__

# 需要导入模块: import pymunk [as 别名]
# 或者: from pymunk import moment_for_circle [as 别名]
def __init__(self, x, y, r, *args, **kwargs):
        mass = 10
        self.body = pymunk.Body(mass,
                                pymunk.moment_for_circle(mass, 0, r, (0, 0)))  # Create a Body with mass and moment
        self.body.position = x, y
        # Create a box shape and attach to body
        self.shape = pymunk.Circle(self.body, r, offset=(0, 0))
        self.shape.elasticity = 0.99999
        self.shape.friction = 0.8
        self.gui_circle_figure = None 
开发者ID:PySimpleGUI,项目名称:PySimpleGUI,代码行数:12,代码来源:Demo_Graph_pymunk_2D_Graphics.py

示例15: __init__

# 需要导入模块: import pymunk [as 别名]
# 或者: from pymunk import moment_for_circle [as 别名]
def __init__(self, x, y, r, *args, **kwargs):
        mass = 10
        self.body = pymunk.Body(mass,
                                pymunk.moment_for_circle(mass, 0, r, (0, 0)))  # Create a Body with mass and moment
        self.body.position = x, y
        self.shape = pymunk.Circle(self.body, r, offset=(0, 0))  # Create a box shape and attach to body
        self.shape.elasticity = 0.99999
        self.shape.friction = 0.8
        self.gui_circle_figure = None 
开发者ID:PySimpleGUI,项目名称:PySimpleGUI,代码行数:11,代码来源:Demo_Graph_pymunk_2D_Graphics.py


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