def _handle_player_collide_item(self, player: Player, dropped_item: DroppedItem, data, arbiter: pymunk.Arbiter) -> bool: """Callback to handle collision between the player and a (dropped) item. If the player has sufficient space in their to pick up the item, the item will be removed from the game world. Parameters: player (Player): The player that was involved in the collision dropped_item (DroppedItem): The (dropped) item that the player collided with data (dict): data that was added with this collision handler (see data parameter in World.add_collision_handler) arbiter (pymunk.Arbiter): Data about a collision (see http://www.pymunk.org/en/latest/pymunk.html#pymunk.Arbiter) NOTE: you probably won't need this Return: bool: False (always ignore this type of collision) (more generally, collision callbacks return True iff the collision should be considered valid; i.e. returning False makes the world ignore the collision) """ if dropped_item.get_id() == 'coin': dropped_item.collect(self._player) self._world.remove_item(dropped_item) elif dropped_item.get_id() == 'star': dropped_item.collect(self._player) self._world.remove_item(dropped_item) elif dropped_item.get_id() == 'flower': dropped_item.collect(self._player) self._world.remove_item(dropped_item) return False
def _draw_physical_item(self, instance: DroppedItem, shape: pymunk.Shape, view: tk.Canvas, offset: Tuple[int, int]) -> List[int]: image = self.load_image(self._item_images[instance.get_id()]) return [ view.create_image(shape.bb.center().x + offset[0], shape.bb.center().y, image=image, tags="item") ]