I’m making a deck of cards. I have each image of the cards in a 2D array with each value of the array representing suit[4] and rank[13]. I’m trying to use random to randomly pull an image from it but it just cycles through numerous cards at once.
class DeckCards {
int randoSuit;
int randoRank;
PImage cardBack;
PImage newCard;
CardImages card = new CardImages();
void pickCard(){
randoSuit = (floor(random(4)));
randoRank = (floor(random(13)));
newCard = card.cardFaces[randoSuit][randoRank];
}
void display(int xCardPos, int yCardPos){
pickCard();
image(newCard, xCardPos, yCardPos);
}
void stationaryDeck(int xDeckPos, int yDeckPos){
image(cardBack, xDeckPos, yDeckPos);
}
class CardImages{
PImage cardFront;
PImage[][] cardFaces = new PImage[4][13];
There’s a large chunk of code beneath this to fill in the .png’s to each PImage variable and assigns them all to the array.
Could you elaborate on both the chunk of code with the for loops and the structure of the class, mainly the DeckCards class. I can definitely separate the two if that’s a better idea as well