Hey folks,
I have a question about performance of drawing elements to the screen and maybe some suggestion at the current scheme I do use to draw the components in my game screen.
I will explain from the beginning what I’m doing and if I’m doing something(or everything wrong) indicate me what is wrong.
Components Loading
- I got my game graphics stored in png images
- I’m using MediaTracker to see when some image is fully loaded
- While I’m loading graphics, I analyze the image content and convert color(255,0,255) to transparency and store them to Hashtable <String, BufferedImage>(I got different Hashtables, depending on what image category is)
At the moment I got in memory: creature graphics, character graphics, menu backgrounds, etc
Map Creation
- Map is created from a dat file which contains array of tile objects
- Map is only created after character does login
- At the moment after I create the map it’s 3200x3200px (is it too big??)
Drawing on screen
- All of my components are drawn in personized JLabel(class which extends JLabel)
- When map loaded JLabel is created and in paint method of JLabel map image is drawn
- When characters are loaded, Hashtable <String, JLabel> is filled with characters and kept in memory for repaints
- When map objects are loaded JLabel is created and put in another Hashtable <String, JLabel>
- I got update function which calculates and changes the offsets and positions of elements
- After update is done I’m creating temporary render array were I put the JLabels in the order of drawing them on screen
- Repaint is done
Thanks is advance

