Archived

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

Multi input

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

Maybe this belongs in the directx section, maybe I''m just dumb, but I got a big question and I''m hoping someone can help me with it. I''m using directx 8 and I want to know how to get multiple input in direct input. Basically I am making a 2 player 1 keyboard 1 screen game. very basic, but I cannot get the sprites to move seperately. If you don''t get it; I mean I want the users to be able to move their respective characters(sprites)at the same time. any idea how you do this? Thanks for your help in advanced!

Share this post


Link to post
Share on other sites
What language are you using?

Basically, once every gameloop, you need to check the states of all the keys. If some a player1's keys are down, then update player1's sprite. If some of player2's keys are also down, then update player2's sprite as well.

To do this you should be doing your check of keypresses before you perform your rendering to the screen. If the keys are down, you then update appropriate variables giving the position of each players sprites. Then, when your loop reaches the rendering function, it should render the sprites according to the values of those variables.

Hope that helps a bit.

quote:
maybe I'm just dumb


You know its a waste of time posting stuff like that, both for you to type it, and for everyone else to read it. Your asking questions to try to find solutions to your problems. This demonstrates intelligent behavior. Keep in mind though, its best to try to solve problems yourself first.

[edited by - Kazgoroth on November 11, 2003 10:36:10 PM]

Share this post


Link to post
Share on other sites
Thanks for your help, I really appreciate it.
And yeah I know I''m not dumb for asking the question but sometimes I feel the solution is easier than it actually is.
Anyway thanks again I appreciate your help and if anyone else can help I would like that too. One more thing, how do you exactly check for the commands, I mean what exactly is the code. thanks

PS. I''m using MS visual C++ 6.0

Share this post


Link to post
Share on other sites
For example, you can check for A key input with this:

if ((GetKeyState(''A'') & 0x80) || (GetKeyState(''a'') & 0x80))
{
//code
};


Then you can do this with any key and write code for that action.

There are many ways to do this ...

Share this post


Link to post
Share on other sites