def __init__(self, point): self._joints = WeakSet() self._adjacent_blocks = WeakSet() # load images base_path = "images/blocks/{}.png".format(self.image) damaged_path = "images/blocks/{}_damaged.png".format(self.image) destroyed_path = "images/blocks/{}_destroyed.png".format(self.image) self.img = load_image(base_path, self.image_anchor) self.img_damaged = load_image(damaged_path, self.image_anchor) self.img_destroyed = load_image(destroyed_path, self.image_anchor) w = h = BLOCK_SIZE # using (density * 1 ** 2) for these because our units are BLOCK_SIZE inertia = pymunk.moment_for_box(self.material.density, w, h) self._body = pymunk.Body(self.material.density, inertia) self._body.position = point self._shape = pymunk.Poly.create_box(self._body, (w, h)) self._shape.elasticity = self.material.elasticity self._shape.friction = self.material.friction self._shape.collision_type = self.material.collision_type self._shape._get_block = ref(self) SPACE.add(self._body, self._shape) SPACE.register_block(self)