As an exercise, I'm working on putting together a simple physics and collision detection library for a video game and I'm looking for some advice on good Erlang architecture.<br><br>Right now I have the concept of a cell which uses gen_event and acts as a sort of hub for physics processes to communicate.<br>
<br> A physics process is spawned with a cell PID to talk to and uses timer:send_interval to send itself update messages at a certain resolution (ie: every 33ms for a 30 frames per second simulation). When it gets an update message, it applies physics calculations to get its new position and then sends a {moved, self(), NewPosition} message to the cell which uses gen_event to notify all the other interested physics processes. <br>
<br>When a physics process gets a "moved" message, it can compare the EntityPosition with its own position to see if a collision has occurred and act accordingly.<br><br>How is something like this usually handled in Erlang?<br>
<br>Given that a simulation might have thousands of physics processes, is it bad that I'm using a timer for each one? Would it be better to have a single process with a single timer and a list of physics records to partition and update? <br>
<br><br><br>