guys i need help on how i can implement a way on how to read multiple key pressing from the keyboard e.g like when i am pressing the left key and a i press the shoot or pass button i want my player to pass the ball.Currently my game agent stops responding for a while when i press another key .e.g when i press the up button from the left button the player stops for a while and then heads upwards.i want the movements to be smooth
public void keyPressed(KeyEvent e) {
if(g_SoccerPitch.GameOn() && g_SoccerPitch != null){
switch (e.getKeyChar()) {
case 'w':
case 'W':{
g_SoccerPitch.UserControlledTeam.UserControlledPlayer().MoveUp();
chaseBall();
}
break;
case 's':
case 'S':{
g_SoccerPitch.UserControlledTeam.UserControlledPlayer().MoveDown();
chaseBall();
}
break;
case 'a':
case 'A':{
g_SoccerPitch.UserControlledTeam.UserControlledPlayer().MoveLeft();
chaseBall();
}
break;
case 'd':
case 'D':{
g_SoccerPitch.UserControlledTeam.UserControlledPlayer().MoveRight();
chaseBall();
}
break;
case 'm':
case 'M':{
//shoot ball if ball withinin kicking range and team is in control
if(g_SoccerPitch.UserControlledTeam.InControl() && g_SoccerPitch.UserControlledTeam.UserControlledPlayer().BallWithinKickingRange()){
g_SoccerPitch.UserControlledTeam.UserControlledPlayer().UserPlayerShootBall();
}
}
break;
case 'l':
case 'L':{
//if team in control pass the ball else chase the ball
if(g_SoccerPitch.UserControlledTeam.InControl()){
if(g_SoccerPitch.UserControlledTeam.UserControlledPlayer().BallWithinReceivingRange()){
g_SoccerPitch.UserControlledTeam.UserControlledPlayer().UserPlayerPassBall();
}
} else{
g_SoccerPitch.UserControlledTeam.UserControlledPlayer().Steering().SeekOn();
g_SoccerPitch.UserControlledTeam.UserControlledPlayer().Steering().SetTarget(g_SoccerPitch.Ball().m_vPosition);
if(g_SoccerPitch.UserControlledTeam.UserControlledPlayer().AtTarget()){
g_SoccerPitch.UserControlledTeam.UserControlledPlayer().Steering().SeekOff();
}
}
}
break;
}//end switch
here is my code snippet and its in java