0

I'm trying to make a game where the player sometimes have to rotate, but I can't figure out a way to make it rotate more each time, here's what I've got: Graphics2D g2d = (Graphics2D) g;

    AffineTransform at = new AffineTransform();

    at.translate(300, Main.height - 115);

    if(rotateright) {
        at.rotate(Math.PI / 15);
    } else if(rotateleft) {
        at.rotate(Math.PI / 15);

    }

    at.scale(0.125, 0.125);

    at.translate(-texture.getWidth() / 2, -texture.getHeight() / 2);

    g2d.drawImage(texture, at, null);

This method makes it rotate just fine, but I can't find a way to make it rotate more each time, so this method pretty much just rotates it, but only once, and then it just stops. Is there anyway to add to the rotation or something?

ItzBenteThePig
  • 696
  • 1
  • 9
  • 19
  • Keep track of the current rotation value, based on the speed of the rotation and the amount of time the object has been rotating, then simply render the object at it's current angle. Something like [this](http://stackoverflow.com/questions/26005726/rotate-an-animated-gif-imageicon-using-affinetransform/26006540#26006540) – MadProgrammer Feb 06 '16 at 21:17

1 Answers1

2

you're always starting of with the image in the normal rotation (0 deg/RAD rotated), and then radiating it by PI/15 RAD. if you want it to rotate over time, you will need to multiply PI/15 with a value that will be changing over the duration of your animation.

Matthias
  • 2,622
  • 1
  • 18
  • 29