No problem. I usually suck at descriptions.
- I had a class called ADConstants where I was defining card properties but I deleted that last night. And went to using a text file.
Ok, Card is an object. That has the following properties.
- label
- image
- name
- type
- cost to play
- event triggered
These properties are stored in a txt file that is read into a 2 dimensional array. With all the card properties.
I have a class called deck. Which will read the text file and load a deck, creating an array of card objects.
After this the system retrieves the array of card IDs stored somewhere (JDBC most likely, but currently just on the client side). Its is just an array of ints which refrence the IDs of the master array of card objects.
So deck object has an array of card objects (100 so far). And the player as an aray of integers, which when called to be displayed. They fetch the card data, the total cards a player can have showing on screen is 4.
So player 1 is dealt 4 cards.
Card size is 145x200 and is a PNG file. So to display the card I have to load the image.
So my question is which is a better design to follow.
I create the PNG of the card with all the following displayed as part of the card.
- name
- type
- flavor text
- cost to play
- what it does (event triggered)
- main image
- Downside
If I change anything I need to recreate the card
*Upside
Quicker to create
Easier to manage
Less images to load,
most likely quicker performance
What I have then is a PNG that is 145x200 and holds all the card info.
Or I do the following:
- Card Template is a blank PNG of a card with no name or image or any text at all on it.
I create a PNG of the cards main image. I then keep loaded all the time my card template. I know exactly where the card will be placed. So I add labels:
- lblNameC1, where the name would be on the template
- lblCostC1, where the cost appears
And so on.
So I paint down the template then load the JLabels
And I just load the cards main image over top where I need it on the template.
When I’m done with that card I clear the labels and load the next cards values into them.
*Downside
1 more image loading into memmory
more processing time setting all the labels.
I can cash the image, but will have to reload labels if the same card comes up
Have to come up with a way to store the flavor text of the card in some kind of easy to manage reader.
*Upside
Quicker to add more cards, since I just have to create small simple images.
Any change in the text file and it will auto reflect to the player with no need for a whole new card PNG
I can also email you a picture of a card if that will help you understand a little better, I bet its hard to imagine.
After writing it out a little better, the last option is looking better, but I’m not sure how much performance it will cost me using the labels and loading and displaying 2 images. The set up of the labels will be a pain in the ass as well.
My last question is, should I keep the card images loaded in memmory until the end of the game. So if anyone else plays the same card it loads the image quicker. Or should I dispose of it after is been played and thrown out.
- Players could have 20 of the same card (in theory)