Why the tank keep shifting?
Please try this:
http://www.cs.mcgill.ca/~xliang4/test.zip
after unzip, compile by "javac *.java", execute by "java Gui". using up, down, left and right keys to move the tank.
the thing keeps bothering me is that after rotating the tank some degrees, moving it will cause it sliding away from the route it supposed to be.
would anybody give any suggestion to solve this? thanks a lot.
[423 byte] By [
tuoxie] at [2007-9-30 15:17:40]

the problem is in your drawBackBuffer() method. Your AffineTransform.rotate() method rotates around the 0,0 coordinate of the image. You need to tell it to rotate around the center. Here's how I use AffineTransforms to render my images:xform.setTransform(1, 0, 0, 1, x - screen.getX() - width/2, y - screen.getY() - height/2);
xform.rotate(theta, width/2, height/2);
g2d.drawImage(image, xform, null);
And that's it! It's done in fewer calls than your method as well. I hope that helps! Oh, and the screen coordinates are put in there because I have my camera (defined by a Rectangle) that moves around so I have to shift over my images to compensate. Good luck!