Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

10
Image rotates but the rectangle collision box around the image does not
Post Flair (click to view more posts with a particular flair)
Post Body

I just recently started making my first game and I am new to using AffineTransform. I have this function that rotates the rectangle that is my player and then draws the image onto it. That works great, but the issue I am dealing with now is the collision box I have on the outline of the image does not rotate. Any help or suggestions to get me on the right track would be much appreciated!

public void render(Graphics g) {
        //Rectangle bounds = getBounds();

        AffineTransform rotation = AffineTransform.getTranslateInstance(x, y);
        rotation.rotate(Math.toRadians(angle), 32 / 2.0, 48 / 2.0);
        //Shape rotated = rotation.createTransformedShape(bounds);
        Graphics2D g2d = (Graphics2D) g;


        g2d.drawImage(tank_image, rotation, null);

        // Creates the green box around the image, but it does not rotate
        g.setColor(Color.green);
        g2d.draw(getBounds());
}

Author
Account Strength
80%
Account Age
7 years
Verified Email
Yes
Verified Flair
No
Total Karma
89
Link Karma
63
Comment Karma
26
Profile updated: 5 days ago
Posts updated: 1 year ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
5 years ago