Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (109)
games submitted by our members
Games in WIP (536)
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 826 times)
0 Members and 1 Guest are viewing this topic.
Offline Isvan
« Posted 2014-01-13 04: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 Member


Medals: 3
Exp: 7 years



« Reply #1 - Posted 2014-01-13 05: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

Hello!
Offline trollwarrior1
« Reply #2 - Posted 2014-01-13 10: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
« Reply #3 - Posted 2014-01-13 17: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 09: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  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CogWheelz (18 views)
2014-07-30 21:08:39

Riven (26 views)
2014-07-29 18:09:19

Riven (15 views)
2014-07-29 18:08:52

Dwinin (13 views)
2014-07-29 10:59:34

E.R. Fleming (34 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (44 views)
2014-07-24 01:59:36

Riven (44 views)
2014-07-23 21:16:32

Riven (30 views)
2014-07-23 21:07:15

Riven (31 views)
2014-07-23 20:56:16
List of Learning Resources
by SilverTiger
2014-07-31 18:29:50

List of Learning Resources
by SilverTiger
2014-07-31 18:26:06

List of Learning Resources
by SilverTiger
2014-07-31 13:54:12

HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54
java-gaming.org 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‑gaming.org
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!