Re:Game Programming Patterns: Double Buffer (2014)
by Sharlin on Monday August 27, 2018 @02:10PM
(#17853136)
A related idea—representing state as pseudo-continuously varying values—is Conal Elliott's original formulation of functional reactive programming in the context of animation [1].
[1] Elliott, Conal; Hudak, Paul (1997), "Functional Reactive Animation" <http://conal.net/papers/icfp97/>
I've been tempted lately to model application state as the integral over time of all events (deltas) that have occurred. For example, imagine a simple game state:
If initial game state = and you have some events (deltas): You could "sum" them up (integrate over time) and get a game state of x = 5, v = 0 where t >= 5.I've found this approach kinda sucks when you add things like collision detection. Your application would have to emit velocity deltas when objects would collide. If you've got a point that bounces around in a box with perfectly elastic collisions, then over time you'd have an infinite number of these collision/velocity delta events. But as you receive new events, all your precomputed collision events are for nothing (if your player logs out). So the traditional update loop simulate each tick as it occurs seems to work best.
Is there a more general way of thinking about this integration? Maybe with respect to another variable? Perhaps it would address this problem I'm having where I feel forced to quantize my game state onto ticks.