Hi guys,

I'm using opengl to create a 2-player pong game.

I've added controls to both players. One player is using the 'A' and 'D' keys to control his racket while the other is using the left and right arrow keys.

The key event code is like this:
Code:
void dKeyPressed(int key, int x, int y) 
{
	switch (key) 
	{
		case GLUT_KEY_LEFT:
			drawer->moveBat(0, vl);
			break;
		case GLUT_KEY_RIGHT:
			drawer->moveBat(0, vr);
			break;
	}
}

void nKeyPressed(unsigned char key, int x, int y)
{
	if(key==97||key==65) 
	{
		drawer->moveBat(1, vl);
	}
	if(key==68||key==100)
	{
		drawer->moveBat(1, vr);
	}
	if(key==32)
	{
		drawer->restart();
	}
}
and the moveBat in the Drawer class is like this:
Code:
void Drawer::moveBat(int bat_id, cyclone::Vector3 &force)
{
	game->bat[bat_id]->body->addForce(force);
}
Each time a key is pressed, a certain amount of force is added to the racket to make it move. I'm using the cyclone physics engine, the addForce(Vector3 &f) function is provided by the engine.

I noticed that if I press key 'a' and the left arrow key at the same time, only one racket is moving. If I try to press the key again to make the other one move, the current one stops.

Any idea what am I doing wrong here?

Thanks!