Sry guys for asking, but my game has a slow startup and I want create a loading screen to keep the person busy until the game starts up. So does anyone know how to do this or find a faster way to startup the program. My dad said to optimise the programming code and I don't know what he means by that.

Sry guys for asking, but my game has a slow startup and I want create a loading screen to keep the person busy until the game starts up. So does anyone know how to do this or find a faster way to startup the program. My dad said to optimise the programming code and I don't know what he means by that.

What is being slow? Like Cero said, show us the code! And "optimizing" means to make something run faster by using a better algorithm or something like that.

How about your assets? to put it honest maybe you amde it too mess. I look multiple class extending JPanel so you end up having multiple Graphics object instances. There's also more than one KeyListener too.

Obviously the problem is in code that runs before the game window is displayed.

That's an awful lot of code you posted. That said, just think about what your program is doing before it ever displays its window. For example, it looks to create lots of "stuff" (you instantiate member variables outside of constructor or method bodies, which causes them to be run early on). Chances are something here is slowing you down. Without digging too deep, I'd be suspicious of the stuff done in the MapDirector class.

For example, in each iteration in your double-nested for-loop in MapDirector, you create a minimum of 2, and a maximum of 4, combination of Wall and Floor instances. This is an average of (23*33*3) = 2277 Walls/Floors, depending on what's in your map data file. Now, each Wall and Floor create their own Image to paint themselves; however, there's no need for each Wall instance (for example) to have a separate copy of the wall image. The same goes for the floors. What you should be doing is create each of these two images once, then have all Floors reference the same floor BufferedImage, and all Walls reference the same wall BufferedImage. This will save ~ 2275 image loads on your game's startup.

Another thing to keep in mind is you might want to follow standard Java code conventions, in particular those for variable names. Usually, variable and method names start with lower-case letters. Following these conventions will make your code much easier for fellow Java programmers to read, and they're pretty much universally followed.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org