Okay, I understand your need for an SSCCE, so I created (my first) one.
I managed to replicate the problem with under 200 lines of code. On my system this demo compiled and ran perfectly (only the flickering was still there of course). I stripped everything that had nothing to do with it. So basically we have two source files now: the screen manager and the game manager.
The screen manager: http://pastebin.com/WeKpxEXW
The game manager: http://pastebin.com/p3C5m8UN
You can compile this code with this make file (I use a ported version of Linux' make for Windows): CC = javac BASE = nl/jorikoolstra/jLevel CLASS_FILES = classes/$(BASE)/Game/GameMain.class classes/$(BASE)/Graphics/ScreenManager.class
jLevel: $(CLASS_FILES)
@echo Done.
classes/%.class : src/%.java
@echo Compiling src/$*.java to $@ [command: $(CC) src/$*.java ] ...
@$(CC) -Xlint:unchecked -d classes -classpath src src/$*.java
Where the source files are placed in the /src
directory and the classes in the /classes
directory.
After compilation to byte-code the game can be started using the following .bat file:
@set STARUP_CLASS=nl.jorikoolstra.jLevel.Game.GameMain
@set ARGUMENTS=1280 1024 32
@java -cp classes;resources %STARUP_CLASS% %ARGUMENTS%
Note that the ARGUMENT
variable depends on your own screen settings and that you have to change it so that the game is displayed in the right resolution for your screen.
true
, also when I try to vut out the full screen mode the buffering strategy fails with:Exception in thread "main" java.lang.IllegalStateException: Component must have a valid peer
. I'm pretty sure my drivers are up to date though. – Coimbatoreif (hwnd == null) hwnd.dispose();
, although that could not cause the flickering. My advice is to go back to basics with a trivial application that creates a window with a buffer strategy and draws something simple to it. Make sure that works, then keep incorporating parts of the full game until it goes wrong. – Impignorate