I have started to make a platforming game in pygame. In the game, I want to use a 'timewarp' option, which allows the player to go back to a previous point int he game with all the variables being the same as at that point, e.g. if they had not defeated an enemy at that point but defeated it later on, then the enemy should reappear after timewarp.
To do this, I have used a list to store key details about the game every second. All of it seems to work apart from one thing: the enemies do not return to their state at this point.
I have found that this is because when adding a sprite group to a list (in this case enemyList), it replaces all of the enemyLists stored in the previous list with the most current one, so this code:
self.timewarpList.append([self.currentTime, self.presentLevel.enemyList])
print(self.timewarpList)
returns this at each second:
[[14, <Group(1 sprites)>]]
[[14, <Group(1 sprites)>], [13, <Group(1 sprites)>]]
[[14, <Group(1 sprites)>], [13, <Group(1 sprites)>], [12, <Group(1 sprites)>]]
[[14, <Group(1 sprites)>], [13, <Group(1 sprites)>], [12, <Group(1 sprites)>],
[11, <Group(1 sprites)>]]
[[14, <Group(0 sprites)>], [13, <Group(0 sprites)>], [12, <Group(0
sprites)>],[11, <Group(0 sprites)>], [10, <Group(0 sprites)>]]
[[14, <Group(0 sprites)>], [13, <Group(0 sprites)>], [12, <Group(0 sprites)>],
[11, <Group(0 sprites)>], [10, <Group(0 sprites)>], [9, <Group(0 sprites)>]]
Does anyone know why this happens? And also how I can fix this so my values don't change? Thanks :)