|
|
|
|
|
by x1000
2852 days ago
|
|
I thought this would only apply to rendering graphics, but after reading the "When To Use It" section, I realized I've done double buffering on entire game states before (~2 years ago project). At the beginning of my update loop, I'd (deep) copy the current game state into a new object and begin incrementally updating the copy. Then I'd reassign right before Thread.sleeping (or whatever language idiom) until the next game loop "tick". Wasn't too fond of my C# deep copy solution:
var serialized = JsonSerializer.Serialize(this);
return JsonSerializer.Deserialize<GameState>(serialized); I took an interested in functional programming, pure functions, immutability, etc. soon after. |
|