Global messaging system
Hi.
I'm designing some of the core of my game, and is having a little problem knowing if I'm picking the best solution for the job. The game will be a roguelike, so there will be many traps, monsters etc. on the map at any time.
My first thought would be to use events (I'm using .Net), but thinking about it, I realised that everything had to listen to every object, so I started designing a messaging system.
Every object tells the messaging system what kind of messages it wishes to listen to (attacking, door opening, player moving, monster dieing etc.). Once a player makes a move it sends a moving message to the messaging system. Everything that does something sends a message to the messaging system, and at the end of the turn, the messaging system loops thru the queue and dispatches the messages to all the objects that is interested in a messagetype like this.
I've allready programmed a test, and it seems to be working ok.
But this will be a very central element in the core of the game, and I do not wish to screw up being required to refactor 6 months after I start the development.
Can anyone see a better sollution for a system like this?
EDIT: I have moved this message to game programming as it fits more in that forum
[Edited by - simhau on August 5, 2004 1:57:25 PM]
That's how the Windows apps are programmed, seems to work for them. It's very flexible, but requires you to write code to serailize and deserialize the messages.
it's a good system. i have a very large messaging system in my little AI project. the one difference is that there is a global message queue which handles a lot of global things but then there's also queues for each "entity". i find it much easier if entities can talk directly to one and other instead of say.. an entity getting the ID or pointer of another one and sending a global message and the global messenger telling the other entity what to do. i use linked lists to keep the memory to a minimum. seems to be plenty fast enough.
don't know exactly what your needs are though. messaging systems are very powerful as it allows you to communicate between objects in a more common sense way instead of say one object calling a member function of another. you just send it a message.
don't know exactly what your needs are though. messaging systems are very powerful as it allows you to communicate between objects in a more common sense way instead of say one object calling a member function of another. you just send it a message.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement