Archived

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

How to handle user Input ??

This topic is 5744 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

My group is making a game engine,and i have beed assigned to complete a/some class(es) to handle user input.But i haven''t any correct idea how to do it ~~ My idea is: Making a Input manager which contain a linked list to hold all input handler, and input handler is an interface to create all action in the game.
  
HANDLERNODE
{
char* Key_ID;
CINPUTHANDER handler;
HANDLERNODE* Next;
}

CINPUTMANAGER
{
LinkedList<HANDLERNODE> HandlerList;
int totalNode;
void register(char* Key_ID, CINPUTHANDER Handler); 
CINPUTHANDER getHandler(char* Key_ID);
}

CINPUTHANDER
{
virtual void execute();
};

CINPUT
{
Init();
InitKeyboard();
InitMouse();
getInput();
};

//In the game code:


CINPUT input;
CINPUTMANAGER inputManager;

KeyCode key=input.getinput();
for (int i=0; i< totalNode; i++)
{
  hr=getHandle(Key);
  if (hr != NULL)
      hr->execute();
};
  
please give me some suggestions

Share this post


Link to post
Share on other sites