int screenWidth = 600;
int screenHeight = 400;
int nsqr = 40; // Full length of sides
int hsqr = nsqr/2; // Half length of sides
int xcoor = screenWidth / 2;
int ycoor = screenHeight / 2;
public void drawQuad() {
GL11.glColor3f(0.5f,0.5f,1.0f);
GL11.glBegin(GL11.GL_QUADS);
GL11.glVertex2f(xcoor-hsqr,ycoor-hsqr);
GL11.glVertex2f(xcoor+hsqr,ycoor-hsqr);
GL11.glVertex2f(xcoor+hsqr,ycoor+hsqr);
GL11.glVertex2f(xcoor-hsqr,ycoor+hsqr);
GL11.glEnd();
}
public void detectMouse() {
if(Mouse.isButtonDown(0)) {
xcoor = Mouse.getX();
ycoor = Mouse.getY();
drawQuad();
}
}
Basically, when I click the left mouse button, it should draw a square (40x40. Mouse pointer at the center of the square).
The location when it comes to the x coordinate is fine; however, at the y coordinate, it’s all messed up.
Let’s say that if I clicked at the lower half of the screen, the square will appear at the upper half like a mirror.