Thank for the tips.
by reseting the timer when he stops shooting, I fixed the problem.
Now I have a different question. I want the player to aim via mouse and therefor I need to calculate the angle of the player to the mouse.
public double getAngleOfTwoPoints(double x1, double y1,double x2, double y2) {
double DeltaX = x2-x1;
double DeltaY = y2-y1;
double angle = Math.toDegrees(Math.atan2(DeltaY, DeltaX)+ 89.65f);
return angle;
}
public void mouseMoved(MouseEvent e) {
mx = e.getX();
my = e.getY();
angle = vk.getAngleOfTwoPoints(x, y, mx, my);
e.consume();
}
public void mouseDragged( MouseEvent e ) { // called during motion with buttons down
mx = e.getX();
my = e.getY();
angle = vk.getAngleOfTwoPoints(x, y, mx, my);
firing = true;
e.consume();
}
public void mouseReleased( MouseEvent e ) { // called after a button is released
firing = false;
e.consume();
}
public void mousePressed( MouseEvent e ) { // called after a button is pressed down
mx = e.getX();
my = e.getY();
angle = vk.getAngleOfTwoPoints(x, y, mx, my);
firing = true;
e.consume();
}
thats how I calculate it. But for some reason there is a huge offset to my Mouse X,Y pos and the angle he shoots at.
Heres a pic to illustrate my problem: