def create_car(self, x, y, r):
# moment has mass, inner_radius, outer_radius, offset=(0, 0))
inertia = pymunk.moment_for_circle(1, 0, 14*self.game.scale, (0, 0))
# mass, moment
self.car_body = pymunk.Body(1, inertia)
self.car_body.position = x*self.game.scale, y*self.game.scale
# body, radius
self.car_shape = pymunk.Circle(self.car_body, 25*self.game.scale)
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_at_local_point(driving_direction)
self.space.add(self.car_body, self.car_shape)
评论列表
文章目录