java - How do I take out a specific card from a deck image? -


i want take out card deck image. how can without downloading every single card separately? don't want initialize 52 cards in class.

right now, randomize colour , value , finds picture in source folder. possible take 1 card out single deck image?

bild = imageio.read(new file("source folder/" + colour + value + ".png"));       

you should initialize them don't have hands.

you should create 1 image contains every single card , load it. bufferedimage class provides getsubimage(int x, int y, int w, int h); , returning piece (a card) of bufferedimage.

you can populate array of card while looping through image of deck.

    for(int = 0; i<4; i++){         for(int j = 0; j < 13; j++){             deckarray[13 * + j] == image.getsubimage(i * cardwidth,                                                        j * cardheight,                                                         cardwidth,                                                         cardheight);         }     } 

something this. note i'm assuming 4*13 images os sheet , no space between them. have find way track cards, 1 in array no matter how store them, because definietly don't want loading image every time want use it.

it's not tested , not 100% sure did math corretly, quick reference how achive this.


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -