3 ms·
Even real-time games are often best implemented as a pure function of state. This has a lot of advantages for keeping track of everything, especially in games w
by chowells 4y ago
Even real-time games are often best implemented as a pure function of state. This has a lot of advantages for keeping track of everything, especially in games with a network component. Of course, it doesn't mean the function from state to UI doesn't get to use mutable state - that's often critical for performance. What's important is logically separating the game state from the UI, such that any game state can be isolated, serialized, and de-serialized at will.
- crooked-v 4y agoI've had a very silly project in progress for a while along those lines to implement a Game Boy emulator entirely in Redux (state) and React (screen output, with pixels mapped to the appropriate bits). If I ever finish I imagine it will be incredibly slow, but it would allow for 'time traveling' the entire emulator state.
- elwell 4y agoI explored a little what it would mean to use pure functions to generate state for a game that has a little physics: https://github.com/celwell/wordsmith/blob/master/src/cljs/wordsmith/physics.cljs https://github.com/celwell/wordsmith/blob/master/src/cljs/wo...