(no title)
x1000 | 7 years ago
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:
type GameState = {
x: float; // x coordinate
t: float; // current time
v: float; // velocity variable
}
If initial game state = { x: 0,
t: 0,
v: 0, };
and you have some events (deltas): [{t: 1, v:1}, {t:2, v:-1 /*this is deltaV, so back to v: 0*/}, {t: 3, v:2}, {t:5, v:-2}]
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.
Sharlin|7 years ago
[1] Elliott, Conal; Hudak, Paul (1997), "Functional Reactive Animation" <http://conal.net/papers/icfp97/>