0

I am using Slick2D to code a little game, and after a lot of time that already went into it, I changed my mind and decided that I indeed want the game to be resizable. So I tried to use the app.setResizable() command, as suggested on the Slick2D wiki (and here: How to make slick2d resizable). But my eclipse just didnt find that method, so I looked it up on the Internet again, and noticed that all attributes and methods reliative to resizing are missing (such as wasResized(), isResized(), setResizable(), etc..). I have the latest version of Slick2D and eclipse, and probably the answer is pretty obvious, but I have been looking for hours and just cant find it.

Thanks for your help.

Community
  • 1
  • 1
flotothemoon
  • 1,882
  • 2
  • 20
  • 37

1 Answers1

2

In your StateBasedGame, in your main method, you can call lwjgl's Display object,

 Display.setResizable(true);

This will allow you to resize/maximize the Display window. Make sure you have a recent version of lwjgl!

If you would like to resize the window and make sure the graphics object refreshes it size, you should call this in your update method:

    if(Display.getWidth() != container.getWidth() || Display.getHeight() != container.getHeight()) {
        try {
            app.setDisplayMode(Display.getWidth(), Display.getHeight(), false);
            app.reinit();
        } catch(Exception e) {
            e.printStackTrace();
        }
    }

And app is your AppGameContainer class. If you are doing gamestates, you can send a reference to the state when it is initialized. If not, you can make a global reference to your container so you can use this snippet of code anywhere in the class.

Samich
  • 579
  • 4
  • 13
  • Thank you very much for answering, but I already know that. My problem is that I want it to be resizable when you hover over the window border (I don't know how to describe it, I hope you know what I mean) so that the user can change the size like he wants. – flotothemoon Mar 14 '14 at 15:35
  • check the edited answer ;) Also, I suggest looking into the Display object of the LWJGL library. There are a lot of useful methods there for the window itself. – Samich Mar 14 '14 at 21:30