I need to create file path, which is string, based on few other variables.
Deck::Deck() {
char ranks[13] = {'2', '3', '4', '5', '6', '7', '8', '9', '10',
'J', 'Q', 'K', 'A'};
char suits[4] = { 'c', 'd', 'h', 's' };
for (int rank_index = 0; rank_index < 13; rank_index++) {
for (int suit_index = 0; suit_index < 4; suit_index++) {
std::string l_file_name = std::to_string(ranks[rank_index]) +
std::to_string(suits[suit_index]) + ".png";
int l_value = rank_index + 2;
if (ranks[rank_index] == 'J') l_value = 2;
if (ranks[rank_index] == 'Q') l_value = 3;
if (ranks[rank_index] == 'K') l_value = 4;
if (ranks[rank_index] == 'A') l_value = 11;
m_deck.push_back(Card(
ranks[rank_index], suits[suit_index], l_value, l_file_name));
}
}
}
Card constructor looks like this
Card::Card(char p_rank, char p_suit, int p_value, std::string p_texture_file_name)
:m_rank(p_rank), m_suit(p_suit), m_value(p_value) {
m_texture.loadFromFile(FILE_PATH + p_texture_file_name);
m_shape.setSize((sf::Vector2f(70, 90)));
m_shape.setTexture(&m_texture);
}
and m_deck is just
std::vector<Card> m_deck;
I want to achieve string like this for example Qc.png (queen of clubs), etc, although I got some numbers into my string
5099.png Failed to load image "res\cards\5099.png". Reason: Unable to open file
For example. It doesnt convert my chars into string but into some numbers.