LoCo Day 18

Today I implemented the fundamental movement and collision detection logic for the game. It’s fairly simple, but I shouldn’t need to elaborate on it too much more when I implement the actual game on top of it. I also implemented a transactional queue to hold a player’s moves before the game processes them; if a player sends multiple moves in rapid succession, it’s possible they’ll arrive at the server faster than the game can consume them, one move per time step. Using a TChan doesn’t work, since it would retry the transaction if the queue were empty, whereas a player not having a move queued up is perfectly valid, and in fact would be the normal situation. My transactional queue (implemented as a queue wrapped in a TVar) simply returns Nothing if the queue is empty, which the game will then interpret as being no change in the player’s movement direction.

Comments Off