Why aren't you using sprite sheets? If you are rendering that many different images at once, even if they are small, you will inevitably run into massive performance issues because of the many calls to glBindTexture. Maybe you could post a couple of the images -- there may be plenty of ways of compressing that information in order to reduce load time and distribution filesize.
You should not use FileInputStream unless you are certain the file will not be packed into your executable JAR.
Why are you destroying the mouse and keyboard before loading? You should only destroy these things at the end of your application life-cycle, i.e. when the user is exiting your game.
A loading screen works like this...
1.
Render the loading screen; i.e. progress bar at current position and text that says "Loading."
2.
Load a single resource and move forward in your list of "resourcesToLoad."
3.
Finish the frame and repeat.
The pseudo-code for your whole application will look like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| Stack<String> imagesToLoad = new Stack<String>(); HashMap<String, Image> images = new HashMap<String, Image>(); int totalImages;
... in game init ...
imagesToLoad.push("res/skill1.png"); imagesToLoad.push("res/skill2.png"); imagesToLoad.push("res/skill3.png"); ..etc...
totalImages = imagesToLoad.size();
while (!Display.isCloseRequested()) { render(); update(); Display.update(); Display.sync(60); }
... in LoadingScreen render ... if (imagesToLoad.size()==0) { ... we are done, fade to next game screen ... } else { progressBar.setValue( (totalImages - imagesToLoad.size()) / (float)totalImages ); progressBar.render(); }
... in LoadingScreen update ... if (imagesToLoad.size() > 0) { String str = imagesToLoad.pop(); images.put(str, loadTexture(str)); } else { loadScreen(Screens.GAME_SCREEN); } |