Loading and storing card images

For the past two weeks I’ve been thinking up ways to store a large amount of card images. (Think Magic the Gathering artwork on each card). Currently we have around 100 cards, the resolution for each card image is going to be around 128 wide and 256 tall, and if scaling becomes and issue maybe even bigger(Game is on mobile devices).

The player should also be able to view each card in his/her graveyard (Meaning I can dispose of the textures as soon as something dies) Combat is turn based, so I can load files during the opponents turn. My issue is mostly how to store the images. Do I have each card have its own file then load each file individually, or do I contain several large images that are then cut up into the small textures that I need.

Storing and loading each file by its self means I can load only the files I need and not waste memory, but will take longer. While loading big files would be faster but a greater waste of system space.

I’m stuck and thus have come here for help, also I’m using LibGDX and the game is targeted for mobile devices.

Thanks ahead of time.

I would just load a large texture map at first and worry about optimizations if it becomes an issue. Like you said, you can load needed textures while at that time and it doesn’t really matter how long it takes. I’m sure someone else here probably has more useful info for you though :slight_smile:

Pretty simple. Make a hashmap for cards that player CAN SEE. So for example, if player can see 3 certain cards on the table and 4 cards in his hand, put 7 cards with 7 images into that hashmap. If player opens up the graveyard, and has 5 cards in the graveyard, put those cards into hasmap.

Assuming the game will be between 2 players, and each player would have a maximum of 100 cards, I think you could just load ALL the cards images that are available in game. I would start by doing that. Just load all images that will be available in that specific match. If you have memory/performance issues, than you should start optimizing.

So yah, just start by loading all the cards. If you have issues, load cards that player can see, and remove cards from memory that player doesn’t see. Loading like 1, 2, 3, 10 images wouldn’t cause any performance problems whatsoever. If you don’t do that EVERY frame, but only on certain events, such as opening a graveyard, you might only experience a very little “freeze”.

What’s SVG support like on your platform? If you can use that then it would solve the scaling problem and probably use less memory than bitmaps.

Starting with the assumption that “the game will contain too many cards to load into ram at once” might be a bad idea.
How big is a single card texture, in terms of memory usage?

Are you storing entire cards, or just the artwork? For less ram usage, you can load in just the artwork and the text by itself, and render the assembled cards.