This was my solution:
(Camera class)
Code:
public void centerOn(float x, float y) {
//try to set the given position as center of the camera by default
cameraX = (x - gc.getWidth() / (Globals.scale * 2));
cameraY = (y - gc.getHeight() / (Globals.scale * 2))
(gamestate class)
Code:
public void render(GameContainer container, StateBasedGame game, Graphics g) throws SlickException {
g.scale(Globals.scale, Globals.scale);
camera.drawMap();
camera.translateGraphics();
super.render(container, game, g); //renders all my entities
camera.untranslateGraphics();
g.scale(1,1);
...
@Override
public void mouseWheelMoved(int change) {
if (change < 0 && Globals.scale > 1f) {
Globals.scale -= 1f;
}
if (change > 0 && Globals.scale < 5f) {
Globals.scale += 1f;
}
}