我想将椭圆和矩形移动到同一位置。然而,当我按下左箭头和向上箭头时,椭圆形位于错误的位置。任何人都可以帮我这个。
int keyboardPress = keyboard.getKeyCode();
if(keyboardPress == KeyEvent.VK_RIGHT){
xLocation += 30;
xLocationEyes += 30;
angle = 45;
repaint();
}
else if(keyboardPress == KeyEvent.VK_LEFT){
if(xLocation == xrandomLocation + 40){
}
angle = -145;
xLocation -= 30;
xLocationEyes -= 30;
repaint();
}
else if(keyboardPress == KeyEvent.VK_DOWN){
angle = -45;
yLocation += 30;
yLocationEyes += 30;
repaint();
}
else if(keyboardPress == KeyEvent.VK_UP){
angle = -235;
yLocation -= 30;
yLocationEyes -= 30;
repaint();
}