Messaging and user input

Started by
1 comment, last by GameDev.net 17 years, 1 month ago
Greetings, I am in the process of writing a game engine. I am using the component-based entity approach where each game entity contains a list of components that define the behavior of the entity, rather than using a inheritance hierarchy. I have a messaging system in place that allows the engine to pass messages to components that in turn can react to the changes. What i'm wondering about is if I should use this messaging system to pass simple user input events to the components. Like if the user moves the mouse or presses a key. The reason i'm having second thoughts about this is because it would probably hog alot of performance? or am I just paranoid? Maybe I should write a seperate system that allows components to just read user input when needed instead? Anyone how have created a similar engine or system and have experience from this?
Advertisement
At the very least, you should implement some sort of intermediate layer between user input and object messages. What if you want game objects to send messages to other ones? What if the player wants to change the keys used to execute a certain action, what if more than one action should be triggered with a keypress, etc.
Don't worry about performance until profiling tells you too. Design your engine, build it and experiment. This engine will likely never be finished but you will learn a lot from it, making your next one that much better.

This topic is closed to new replies.

Advertisement