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
评论列表
文章目录