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.