Utils.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:Carrom_rl 作者: samiranrl 项目源码 文件源码
def init_striker(space, 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)
    # print " Final Position: ", body.position
    # body.position=(100,)
    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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号