Have you ever noticed how Minecraft, one of the most successful and beloved (indie) games of recent years, doesn’t remember your window size and position between sessions? Unless you have full-screen mode enabled, it always starts in the same little window, which I suspect most players immediately resize.

You would think that this would be a pretty simple convenience to implement. I don’t know why Notch didn’t choose to do so, but I suspect that it has something to do with LWJGL and the deficiencies of its Display object.

Any LWJGL app that wishes to render to the screen must first initialize an instance of Display. By default this creates a new window, but it lacks certain methods that you might expect to be present. You can’t, for example, check whether or not the window has been maximized.

To get around this, it’s possible to bind the Display object to a Java AWT canvas object instead, which can then be attached to an AWT window over which you have a bit more control.

When I started Shootah I originally adopted the first method, then switched to the second for the sake of user-friendliness.

The thing is, now that I’ve added support for game controllers, a bug has arisen which is causing the app to lock up when deleting the AWT frame at shutdown time. It only happens if I enable the LWJGL controller interface, even if I do nothing but immediately delete it. It seems that LWJGL controllers don’t play nice with AWT’s message queue. After a few frustrating evenings spent dicking around with it, I think that, for the sake of simplicity, I’m going to drop the frame and go back to just letting the Display object create the game window.

This might mean that the next release will actually lose the ability to recreate the game window exactly as it was the last time you played, but sod it. There’s more important stuff to be getting on with.

Other than that, the new controller code is working well, but there’s still some tweaking and additional content I want to add before the next build. It should work with any USB game controller, though the default button mapping is based on the XBox 360 pad. Customizable controls will be available in a future release.

Leave a Reply