Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Loading and storing card images  (Read 3082 times)
0 Members and 1 Guest are viewing this topic.
Offline Isvan
« Posted 2014-01-13 03:38:26 »

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.
Offline DavidW

Junior Devvie

Medals: 3
Exp: 7 years

« Reply #1 - Posted 2014-01-13 04:32:18 »

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 Smiley

Offline trollwarrior1
« Reply #2 - Posted 2014-01-13 09:32:55 »

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".
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline pjt33

« JGO Spiffy Duke »

Medals: 40
Projects: 4
Exp: 7 years

« Reply #3 - Posted 2014-01-13 16:20:39 »

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.
Offline Mads

JGO Ninja

Medals: 26
Projects: 3
Exp: 6 years

One for all!

« Reply #4 - Posted 2014-01-21 08:16:24 »

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.

Pages: [1]
  ignore  |  Print  

EgonOlsen (78 views)
2018-06-10 19:43:48

EgonOlsen (58 views)
2018-06-10 19:43:44

EgonOlsen (78 views)
2018-06-10 19:43:20

DesertCoockie (260 views)
2018-05-13 18:23:11

nelsongames (158 views)
2018-04-24 18:15:36

nelsongames (157 views)
2018-04-24 18:14:32

ivj94 (898 views)
2018-03-24 14:47:39

ivj94 (162 views)
2018-03-24 14:46:31

ivj94 (811 views)
2018-03-24 14:43:53

Solater (175 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!