Slick2d - Fit Camera to game resolution

Hey guys,

so I’ve implemented a scrolling camera to my game which works fine for me.
But if I change the resolution of my game, e.g. from 800x600 to 1280x960 the field of view of the player increases extremly.

This is my camera class:
http://pastebin.java-gaming.org/8a70696904d1d

Is there a way to increase screen resolution without increasing the field of view for the player?

Thanks!

I’m not familiar with Slick but it looks like it’s wrapped around LWJGL, so concepts are similar but I don’t know the functions to make this work. Basically what you want is your projection matrix to scale with the viewport/window.

I see the point, unfortunately my knowledge on LWJGL is limitted.
That means I understand your theoretical solution but I have no clue how I could implement it in slick2d :smiley:

I looked through the index of the Slick 2D javadoc and apparently there is no direct way to access the projection matrix. Nor do i know what version of OpenGL it’s using. Sorry buddy, I don’t know the API to tell you how to fix your problem but maybe google does.

Thanks for the help so far, yeah google didn’t help so much yet.
Slick2d, or atleast my version of it is using lwjgl 2.9.1 and this version is so far as i know using OpenGL 4.4

Looks like the issue is going to be solved with the gameContainer. Found this hope it helps

Thanks for your help!
As far as I understood the stackoverflow post right this only helps me to change the resolution of the game while it is running?
But it doesn’t tell how to fit the pov to the screenresolution nor how to access the projection matrix or did i miss something?

Try changing this

map.render(   
             tileOffsetX + offsetX,
             tileOffsetY + offsetY,
             tileIndexX, 
             tileIndexY,
                (gc.getWidth()  - tileOffsetX) / tileWidth  + 1,
                (gc.getHeight() - tileOffsetY) / tileHeight + 1, layer, false);

and switch the gc.getWidth() plus the gc.getHeight to something else, just experiment with it

if I change all gc.getWidth & gc.Height in my cameraclass to a fixed value e.g. 800x600 it works.
Thanks for the help. It doesn’t look really good tho, but thats another topic :smiley:

Cool, glad to see you got it working