With Slick, how to change the resolution during gameplay?

Posted by TheLima on Game Development See other posts from Game Development or by TheLima
Published on 2012-06-05T13:21:08Z Indexed on 2012/06/05 16:48 UTC
Read the original article Hit count: 276

Filed under:
|
|
|

I am developing a tile-based strategy game using Java and the Slick API.

So far so good, but I've come to a standstill on my options menu. I have plans for the user to be able to change the resolution during gameplay (it is pretty common, after all).

I can already change to fullscreen and back to windowed, this was pretty simple...

//"fullScreenOption" is a checkbox-like button.
if (fullScreenOption.isMouseOver(mouseX, mouseY)) {
   if (input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON)) {
      fullScreenOption.state = !fullScreenOption.state;
      container.setFullscreen(fullScreenOption.state);
   }
}

But the container class (Implemented by Slick, not me), contrary to my previous beliefs, does not seem to have any resolution-change functions! And that's pretty much the situation...I know it's possible, but i don't know how to do it, nor what is the class responsible!

The AppGameContainer class, used on the very start of the game's initialization, is the only place with any functions for changing the display-mode that I've found so far, but it's only used at the very start, and i haven't found a way to travel back to it from my options menu.

  //This is my implementation of it...
  public static void main(String[] args) throws SlickException {
    AppGameContainer app = new AppGameContainer(new Main());
//    app.setTargetFrameRate(60);
    app.setVSync(true);
    app.setDisplayMode(800, 600, false);
    app.start();
  }

I can define it as a static global on the Main, but it's probably a (very) bad way to do it...

© Game Development or respective owner

Related posts about java

Related posts about lwjgl