RPGDXThe center of Indie-RPG gaming
Not logged in. [log in] [register]
 
 
Post new topic Reply to topic  
View previous topic - View next topic  
Author Message
Gardon
Scholar


Joined: 05 Feb 2006
Posts: 157

PostPosted: Sun Feb 26, 2006 5:55 am    Post subject: Input [quote]

Ok, so what I'm trying to do (and tell me if this is utterly stupid) to handle input in my game is handle all the events in the Input class, then pass an array of events to the handler (in this case Engine)

What I'm basically doing is checking for keypresses, mouse events, etc. and adding them to a vector to be passed back.

What I'm currently trying to do is make a struct:

Code:
struct m_key
{
      bool m_pressed;
      int m_key;
}

and

struct m_mouse
{
       int posX;
       int posY;
       bool leftDown;
       bool middleDown;
       bool rightDown;
}


that way, i can handle structs in my input class and have the other classes deal with the input (I'm adding these structs to vectors as they are added because I want to know the order of the keys (for console input in-game)


Or is this a totally bad Idea? I'm trying to keep my classes as separate as possible, so Input has no interaction with anything else, but it's becoming increasingly difficult.

Thanks in advance,

Jason
Back to top  
RuneLancer
Mage


Joined: 17 Jun 2005
Posts: 441

PostPosted: Sun Feb 26, 2006 8:26 am    Post subject: [quote]

You should use the boards' search function. Someone already posted a thread about this. ( http://forums.rpgdx.net/viewtopic.php?t=1521 ) Seeing as this person seems to be working on a very, very similare project as yours and had the exact same problem in that thread, many posts already made there will apply to your current dillema. Posting there would prevent having people reiterate what's already been said.

Just sayin'.

Anyhow, how is this handled? Do you update the states in an array of keys or just run through this vector to figure out which state a key is in? If it's the latter, yes, that's a bad idea.
_________________
Endless Saga
An OpenGL RPG in the making. Now with new hosting!

Back to top  
DrunkenCoder
Demon Hunter


Joined: 29 May 2002
Posts: 559

PostPosted: Mon Feb 27, 2006 12:32 pm    Post subject: [quote]

From your previous post I gather that you're using SDL, SDL provides event driven input, you should use it. At least if you got any plans on actually building a robust input system that won't end up a horrible kludge.

Here's a simple example: http://www.libsdl.org/cgi/docwiki.cgi/Event_20Examples
_________________
If there's life after death there is no death, if there's no death we never live. | ENTP
Back to top  
Post new topic Reply to topic Page 1 of 1 All times are GMT
 



Display posts from previous:   
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum