Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9125197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:44:51+00:00 2026-06-17T06:44:51+00:00

I am using Java Slick StateBaeedGame and want to rotate my rectangles for my

  • 0

I am using Java Slick StateBaeedGame and want to rotate my rectangles for my collisions, I know this is possible to do for visual purposes using the Graphics or Graphics2D object but that does not modify the rectangle itself, the rectangle that is originally listed with the variables and called for in the graphics method does not rotate, to make things more clear here is some code:

    java.awt.geom.Rectangle2D.Float rectTwo = new Rectangle2D.Float(460 + buckyPositionX, 50 + buckyPositionY, 100, 100);

public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException{
      worldMap.draw(buckyPositionX,buckyPositionY); //draw the map at 0,0 to start
      bucky.draw(shiftX,shiftY); //draw bucky at 320, 160 (center of the screen)


    g.rotate(460 + buckyPositionX, 50 + buckyPositionY, 40);
    g.fillRect((float)rectTwo.getX(), (float)rectTwo.getY(), (float)rectTwo.getWidth(), (float)rectTwo.getHeight());
      }

The rectangle rectTwo will be shown as rotation when I load my GUI but it is not actually rotated, if I test for a collision the rectangle is still at 0 degrees.

So, how do I get my rectangle variable to change its angle?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T06:44:52+00:00Added an answer on June 17, 2026 at 6:44 am

    Generally, you can’t.

    What you can do, is transform the path of the shape…

    PathIterator pathIterator = shape.getPathIterator(AffineTransform.getRotateInstance(Math.toRadians(33.5)));
    

    This isn’t much use to you right now, but you can then use a Path2D#append to append the path back into a Shape object…

    GeneralPath path = new GeneralPath();
    path.append(pathIterator, true);
    

    Which would allow you to paint it…

    ((Graphics2D)g).fill(path);
    

    This, of course, assumes that your Graphics context is a Graphics2D instance.

    This also means, that you can’t maintain a direct reference to a Rectange2D, but would need to use Shape instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to play with graphics using Java/Slick 2D. I'm trying to get my
Using Java (1.6) I want to split an input string that has components of
Using Java sockets, I made a simple server. This works because it sends data
When using java.jdbc in clojure is it possible to use delete-rows with a complex
By using java reflection, we can easily know if an object is an array.
Is it possible to generate a certificate signing request using Java code without using
I'm using the Slick java game lib and I've used the Slick implementation of
I am using slick for java since a few days and got a serious
How to export to runnable java file with eclipse using slick and lwjgl (Light
I have a java game using lwjgl and slick-util. It works perfectly on my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.