CardVisualizer is a C++ library for drawing playing cards in various designs directly in the terminal. Easily display individual or multiple cards with different design variations, including options for showing turned (hidden) cards.
- Draw individual cards with different variations.
- Draw multiple cards side by side.
- Display a turned card with different design variations.
-
Clone the repository:
git clone https://github.com/imraghavojha/CardVisualizer.git cd CardVisualizer
-
Compile the library:
g++ -std=c++11 -o card_visualizer main.cpp CardDrawer.cpp
-
Run the example:
./card_visualizer
Create a Card
object with the following constructor:
Card card_name("CardName", 'Symbol', 'Design', Variation, Turned);
CardName
: The name of the card (e.g., "Ace", "King").Symbol
: The symbol of the card (e.g., 'A' for Ace, 'K' for King).Design
: The design character of the card (e.g., 'S' for Spades).Variation
: The design variation of the card. Possible values are 1 (Minimalist), 2 (Ornate), 3 (Rounded), 4 (Dotted), 6 (Slashed).Turned
: A boolean value indicating whether the card is turned (hidden) or not.
Draw a single card using draw_card
:
#include "CardDrawer.h"
int main() {
CardDrawer::Card ace_of_spades("Ace", 'A', 'S', 3, false); // Rounded design
CardDrawer::draw_card(ace_of_spades);
return 0;
}
Draw multiple cards side by side using draw_multiple_cards
:
#include "CardDrawer.h"
#include <vector>
int main() {
std::vector<CardDrawer::Card> cards = {
{"Ace", 'A', 'H', 1, false},
{"King", 'K', 'S', 2, false},
{"Queen", 'Q', 'D', 3, false},
{"Jack", 'J', 'C', 4, false},
{"Ten", 'T', 'H', 6, false}
};
CardDrawer::draw_multiple_cards(cards);
return 0;
}
Draw a turned card with Turned
set to true
:
#include "CardDrawer.h"
int main() {
CardDrawer::Card turned_card("Turned", ' ', ' ', 1, true); // Turned card
CardDrawer::draw_card(turned_card);
return 0;
}
For a card with name "Ace", symbol 'A', design 'S', and Rounded design (Variation 3):
.-------.
(A )
( )
( S )
( )
( A)
'-------'
For cards with names "Ace", "King", "Queen", "Jack", and "Ten":
+-------+ +-------+ +-------+ +-------+ +-------+
|A | |K | |Q | |J | |T |
| | | | | | | | | |
| H | | S | | D | | C | | H |
| | | | | | | | | |
| A| | K| | Q| | J| | T|
+-------+ +-------+ +-------+ +-------+ +-------+
For a turned card:
+-------+
| |
| |
| |
| |
| |
| |
+-------+
This project is licensed under the MIT License - see the LICENSE file for details.