So basically, I am making a pretty basic 2D RPG game. I am discovering that my code is incredibly inefficient. I was wondering, (I have sort of asked this before in other threads), how should this be done?
Right now I have what is essentially a JComponent loaded at every tile in the current "room". That would be... 62,500 JComponents at once, each with an image loaded to it.
So clearly this is not the way to go. I am using a JPanel, not a canvas. I was told originally on some forum to stay away from anything in the AWT package, but I am quickly finding that that statement is false... So should I be drawing to a canvas instead? What is the difference?
Also, I had another idea. I was going to add a bunch of images together onto one giant JComponent to form the "texture" of the terrain. Then I would add in the trees and such to the same JComponent, then I would add in the units. Then I would simply create my own classes which would hold the least amount of data possible to animate and control all of the images. Also, I was going to only load what is currently visible, to save memory.
Would that be an effective method? If you don't feel like answering anything else, please just respond to the last question. That is the most important one.
Also, I would have a thread on each object for the image swapping, moving the images on the screen, and then one for controlling the actual commands. Each would be added to a thread pool, for a total of 3 thread pools. Would that be acceptable?