Turn-based game - world map performance issue

Hi,

I am developing a turn-based strategy game in JavaFX and I’m having performance issues when loading 60+ PNG images (each image min 300 x 300px) that represent provinces. The idea behind map generation is to use a static overall map shape and the shape of its provinces. But each province would be represented by one of four images, representing a different terrain type. Thus each time a player would start a new game the map would be changed. Also, during gameplay, province images would be changed to represent seasons change.

So, my initial idea was to have at least 60 provinces (preferably up to 100) where each province would have 4 type images and 4 seasonal images. I know … A LOT of images.

The problem I’m having is when I load more than 50 images, zooming, scrolling, and button responsiveness starts to lag on iMac. On Windows laptop, I get serious lag even with less than 30 images.

I’ve searched a lot on the internet on how to approach the programming of an image-based world map, but without success. All I could find is either hex approach or HOI or EU style approach. For now, I would like to stick with my idea of using images, so if anyone can help me solve this performance issue I would be much grateful. Or, if anyone has another idea of ho can I generate a dynamic world with provinces that can graphically change.
Also, I would like to program this myself without using game engines like Unity.

The thing is I don’t really have a much understanding of how each image and it’s size affects memory usage, so I’m basically doing a trial&error approach. And right now I’m stuck on “errors”.

Sincere thanks for all your goodwill and help!
Rach

100 images with each three 8-bit channels at 512x512 resolution would be roughly 80MByte of raw image data in vram.
That’s nothing.

Your problem is likely seated in how you use the JavaFX api to render your images and also how many you render at once!

Could you post the rendering part and some rough numbers on how many images are drawn at once with that method?
(I cannot help you with JavaFX specific stuff though, just general stuff)

Also, LibGDX might be something for you, it’s not an engine and all you need to make a snappy 2d game with gui is included.

I think we need to see some profiling data before jumping to any conclusions.

80mb of data per frame is trivial, especially as once it’s gotten to VRAM it’s fast as hell.

Cas :slight_smile:

What they said. However i have noticed in the past that png is slower loading than jpg. I was using it for a 1080p movie at the time, 100% java and jpg was no problem. But png would tank.

But again 800 odd images is nothing. You should have no problems with performance on PCs. Even really really old ones.

But always always ALWAYS profile. The bottleneck is NEVER where you think it is. Trust Us.

Definitely need to see what is happening when the lag occurs. I wouldn’t assume it is strictly because of the time taking to load everything–it could also be a result of what is done with the images once they are loaded.

One thing in the back of my mind, also, is wondering whether and how images are being used multiple times. It could make a difference if every instance is a Image or WritableImage, or if one is using multiple ImageView’s that all tap into the same base image.