Event Bubbling in reverse

I’ve been thinking about an architecture for a game engine (this is something that i do for fun). I’m pretty bully on the whole event-based design for an engine, and have been thinking about event propagation. How would this work in an Object Oriented design?

The idea in my head involves a high level container i’m calling a Room. A Room might contain several Players, Bots, and other game objects. I’d like to be able to easily add behaviour for different “events” that could happen in the Room. An example would be when a new Player enters the Room. A ‘NEWPLAYER’ event would be broadcast to all the objects in the Room. The trick is that objects might have sub-objects themselves. Say a Player in the Room has a wand of auto-attack. This wand listens for a ‘NEWPLAYER’ event, and then takes some kind of action itself. Because the wand is a sub-item of the Player, the Player, when it receives the ‘NEWPLAYER’ event would have to re-broadcast it to all its sub-items. And so on, till all the items in the Room have received the event.

I’m not sure if it would be as easy as adding a function which is the name of the event to an object, which would then get called when that event is passed, or if i’d want something a bit more complex.

I’m also trying to figure out how this can integrate with the Fibranet package, specifically the NanoThreads bits.

Leave a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

About this Entry

This page contains a single entry by Jos Yule published on March 3, 2006 3:34 PM.

Learning how to tell time and spell was the previous entry in this blog.

More thinking about events... is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Powered by Movable Type 4.01