python - How to save a pygame sprite-group using the shelve module -
i'm making game in want have save game feature. have sprite group want save using shelf module, 'can't pickle surface objects' error when trying save sprite group. wondering if there way use shelf module save sprite group, , if there isnt, other saving method should use? i'd store relevant values of sprites in json file when user wants save game. load game, empty sprite group, reconstruct sprites loaded data , add them group. e.g. (click on sprites drag them around , press "s" save , "w" load): import sys import json import pygame pg class actor(pg.sprite.sprite): def __init__(self, pos, color): super().__init__() self.color = color self.image = pg.surface((32, 52)) self.image.fill(self.color) self.rect = self.image.get_rect(topleft=pos) class game: def __init__(self): self.fps = 30 self.done = false self.bg_color = pg.color('gray13') sel...