0
\$\begingroup\$

I'm programming in Java.

I have more than 200 MB of images used in my games, something like 100000 40x40ish images. I initially wanted to load them all during app initialization but it took like 2 minutes to do so.

Since I do not need them all at the same time I may load the ones I need before entering a new game state (quick loading screen), but there is still a delta time that I can't afford, so I was wondering if it wouldn't be better to gather them into larger images (sprite sheets) to reduce the cost of I/O. But here I am : if I do so, what is the best approach for rendering : splitting these big images back into smaller ones, or keeping the sprite sheets in memory and rendering the needed parts of these sheets directly using Graphics#drawImage?

I will test a simple game loop using the second option to see what happens performance-wise, and come back to compare with what you advice me to do.

I hope I was clear, don't hesitate to ask me to reword an incomprehensible of mine.

EDIT: I just tested loading using sprite sheets and I was able to do load my 200 MB in less than 10 seconds, which means that if rendering little parts of an image can be done at high rate my problem is solved.

\$\endgroup\$
4
  • \$\begingroup\$ It sounds like you've answered your own question through testing. Want to post your answer below? \$\endgroup\$
    – DMGregory
    May 7, 2020 at 22:34
  • \$\begingroup\$ I will once I tested that drawing specific parts of an image through Graphics#drawImage is done at high rate, if noone does tell me it is the case before I found it out. \$\endgroup\$ May 7, 2020 at 22:46
  • \$\begingroup\$ Although this does not answer your question, it is something you might want to consider. You could set up multiple threads to load the images asynchronously \$\endgroup\$
    – Saad Amin
    May 8, 2020 at 3:43
  • \$\begingroup\$ You mean having a menu to distract the user while I load images? \$\endgroup\$ May 10, 2020 at 16:00

0

You must log in to answer this question.

Browse other questions tagged .