Game Development Community

Game Controls

by Remyremrem · in Torque X 2D · 06/16/2009 (11:25 am) · 4 replies

I was wondering if anyone could explain how Torque X handles determining who is the "controlling player". What I'm trying to refer to is how to find who "pressed start on the press start screen", so I am not just looking to the first controller for input. Ah better way to put it :), how does Torque handle what controller the player is using and are there any examples?

Thanks!

About the author

Recent Threads


#1
06/16/2009 (11:40 am)
Technically it doesn't. You do :-)

I do it such as:

for (PlayerIndex index = PlayerIndex.One; index <= PlayerIndex.Four; index++)
{
   if (GamePad.GetState(index).Buttons.Start == ButtonState.Pressed || GamePad.GetState(index).Buttons.A== ButtonState.Pressed)
   {
       Game.Instance.CurrentPlayer = index;
   }
}

in the main game.cs file i have:
public PlayerIndex CurrentPlayer{get;set;}
hope this helps.
#2
06/16/2009 (11:54 am)
Ah OK thanks, so I do what they have on the XNA best practices and just apply that to

InputMap.BindCommand(*put CurrentPlayer here*, etc....)

?

Am I on the right track?

Thanks for the quick reply!
#3
06/16/2009 (12:00 pm)
Yes,

Thats it, you can capture the current player as in the code I pasted then when your ready to bind controls you should be able to just:

InputMap.BindCommand((int)CurrentPlayer, etc....)

Thanks
#4
06/16/2009 (12:08 pm)
Thanks for the help!