LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: Jack on March 31, 2013, 20:46:03

Title: Two players on the same keyboard
Post by: Jack on March 31, 2013, 20:46:03
Hi. 8)
I'm trying to display two object moved by different keys (different players)... I've a class "Player" which contains:
public void pollInput()
{

while (Keyboard.next())
{
if (Keyboard.getEventKeyState())
{
if(Keyboard.getEventKey() == kRight) {
//
} else if(Keyboard.getEventKey() == kLeft) {
//
}else if(Keyboard.getEventKey() == kUp) {
//
} else if(Keyboard.getEventKey() == kDown) {
//
} else {
//
}
} else {
///
}
}


and the class that should display all which contains:
public void start()
{

//...

while(!Display.isCloseRequested())
{

//....

player[0].pollInput();
player[1].pollInput();
}


the first player works fine, but the second player's object doesn't move... Any idea to solve the problem? Thx..  ;D
Title: Re: Two players on the same keyboard
Post by: Jack on April 01, 2013, 11:21:43
solved!