2

For development purposes of my game, I want to display the coordinates of the mouse in my window. I am having a couple of issues with this. First, the axis appears to start in the bottom left. I would like it to start in the upper left because that is what I am used to. I am currently compensating for this by subtracting the Y coordinate from the height of the window. I would prefer to not have to do this. The other issue is that my Y coordinate appears to be offset by 141 pixels and the X coordinate always stays at -1. How can I fix these issues?

    int posX = Mouse.getX();
    int posY = HEIGHT - Mouse.getY();
    g.setColor(Color.black);
    g.fillRect(0,  HEIGHT - 50, 125, 30);
    g.setColor(Color.white);
    g.drawString(posX + "," + posY, 10, HEIGHT - 45);
ShoeLace1291
  • 4,551
  • 12
  • 45
  • 81
  • I don't think there is any way to get to start in the top left. Perhaps create a wrapper function that does HEIGHT - Mouse.getY() for you? – CraftedCart Mar 19 '17 at 10:54
  • What version of Slick2D are you using? And what's your lwjgl version? Usually it starts on the Top Left and there is no offset. – LOLWTFasdasd asdad May 02 '17 at 16:02

0 Answers0