[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Event handling



> > Re: Net
> >   BSD sockets.  Anything else we need to know?  Dan,
> >   maybe you can comment here - all of the network
> >   programming I've done has been unix-based client-
> >   server stuff, never games.
> 
> It probably needs a layer on top of this. Based on a rant by John
> Carmack in his .plan, I had the idea of doing an unified event system,
> that has most everything as event emitters or sinks. For example, the
> timer is an emitter, and sound and video processing are sinks for it.
> Anyway. Too much vapor for the moment, I'll shut up.

I've chosen to handle events a little differently in my game.  I've
written a very simple event queue class (Yes, a class.  I using C++
because I think OOP just makes sense... call me weird...) that events
can be appended to as they occur.  Somewhere in the main loop, they are
processed.  I've done this because game events can be generated by any
number of things: user input, network traffic, a collision, someone's
health dropping to 0, a certain time being reached...  I've found this
quite easy to work with, so far.

I like you idea of emitters and sinks, though.  If you ever get
something like this going, I'd love to see it in code.

Later,
Ian