Hi!
I have a turret that moves in a circle around the edge of the screen, and fires towards the center of the screen. The problem is that the bullets move in an "L" shaped path instead of a nice, smooth triangular path. Here is the relevant function for the bullet -
What am I missing? How do I get the bullet to move in a diagonal?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | public void moveToCenter() { if (getX() > 280 ) { setLocation(getX()- 1 , getY()); } if (getX() < 280 ) { setLocation(getX()+ 1 , getY()); } if (getY() > 280 ) { setLocation(getX(), getY()- 1 ); } if (getY() < 280 ) { setLocation(getX(), getY()+ 1 ); } } |