Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

sirSolarius

Flow of control for input in game engines?

This topic is 5130 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m designing an input system for my game engine, but I''m not sure what the best design for it is. Obviously, I''m going to have a seperate input class. So the input class has an update() function. I was thinking about having a seperate class with an STL map of keyboard codes (I''m using directinput) and then function pointers. Is that a good idea? Is there a better way to do things?

Share this post


Link to post
Share on other sites
Advertisement
There isn't enough information in your post regarding Input system design. There are some questions to answers:
- what are the means of input ?
- who will use that input (computer character, GUI widgets, ...) ?
- are there different means of handling the input (GUI Buttons handle differently than computer character when clicked on)?

From these questions, you will derive your needs for implementations.

Regarding my own engine, here are my needs:
- Input: mouse / keyboard / AI scripts.
- Input used: computer character, GUI widgets, World Map.
- There are different reactions to input.

I add to this the need of being OS independant.

I define a Controller class for the OS that will process mouse and keyboard input. AI scripts have their own controller.
Each client for the input will use a Listener class that listens to a Controller.

class Controller:
public:
Set_Event(pType, pData)
Data Check_Event(pType)

templateclass Listener:
public:
Listener(Controller* pController)
bool Listen(T* pT)
private:
Controller* _Controller

A computer character will use a Listener<Ccharacter> while a GUI widget will use a Listener<Widget>.
The Widget will process input by calling its own function Listener::Listen(this). Listen will check data within its controller then change the State within the widget.

So within the game, you get:
for each Computer Character: ProcessInput() then ProcessState()

Hope that helps.


Ghostly yours,
Red.
[EDIT: greater than and less than characters]

[edited by - Red Ghost on May 10, 2004 3:45:06 AM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!