[erlang-questions] Good architecture principals

Colin Z theczintheroc2007@REDACTED
Fri Apr 11 17:04:06 CEST 2008


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.

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.

 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.

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.

How is something like this usually handled in Erlang?

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?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080411/1d89e571/attachment.htm>


More information about the erlang-questions mailing list