[Slick2D] Translating relative mouse coordinates to world coordinate? [SOLVED]

        I am trying to have planets that you can click on and get information in my open world space game, but the mouse coordinates return relative to the screen, so the top left is always 0 no matter where in the world my player is (even if the planet is 9000 pixels away). Also, I am translating my screen in an awkward way because I have no idea how to make a camera class or even how to start.

Code in the planet class to check if the mouse is there.

if(input.getMouseX() <= maxX && input.getMouseX() > minX && input.getMouseY() < maxY && input.getMouseY() > minY){
				mouseHovered = true;
			}

Code in a render method acting as the “Camera”


g.translate(-player.getX() - 80 + container.getWidth() / 2,
				-player.getY() - 40 + container.getHeight() / 2);
		

I realize this code will probably be of no use since the question is pretty straightforward, but its there anyways just in case you guys want to call me out on something.

Do this to the mouse coordinate:

float x, y; // mouse coordinates
x += player.getX() + 80 - container.getWidth();
y += player.getY() + 40 - container.getHeight();

That should fix the mouse coordinates.

Hope that helps,
CopyableCougar4

So would this be how to do this?

            mouseX = input.getMouseX();
	mouseY = input.getMouseY();
	mouseX += player.getX() + 80 - container.getWidth();
	mouseY += player.getY() + 40 - container.getHeight();

and just pass the mouseX and y coordinates to the planet class?

Alright, the code you gave me was really offcentered, but I divided by 2 and it works now, thank you! :smiley:

            mouseX += player.getX() + 80 - container.getWidth() / 2;
	mouseY += player.getY() + 40  - container.getHeight() /2;