My camera is just a float x and y and I use g.translate(-cam.cameraX+400, -cam.cameraY+300); to translate the graphics. I have the numbers hard coded just for testing purposes.
How would I take into account the camera so my mouse picking works correctly.
Code:
double mousetileX = Math.floor((double)mouseX/tiles.tileWidth);
double mousetileY = Math.floor((double)mouseY/tiles.tileHeight);
double playertileX = Math.floor(playerX/tiles.tileWidth);
double playertileY = Math.floor(playerY/tiles.tileHeight);
double lengthX = Math.abs((float)playertileX - mousetileX);
double lengthY = Math.abs((float)playertileY - mousetileY);
double distance = Math.sqrt((lengthX*lengthX)+(lengthY*lengthY));
if(input.isMousePressed(Input.MOUSE_LEFT_BUTTON) && distance < 4) {
if(tiles.map[(int)mousetileX][(int)mousetileY] == 1) {
tiles.map[(int)mousetileX][(int)mousetileY] = 0;
}
}