c++ - Displaying Cards Side by Side -


i have create deck of cards used make poker. have created cards when printed out on screen:

---------- |k       | |        | |        | |        | |        | |        | |        | |        | |       k| ---------- 

i have card output defined so:

void deck::cardking(){ cout << "----------" << endl; cout << "|k " << setw(7) << "|" << endl; cout << "|" << setw(9) << "|" << endl; cout << "|" << setw(9) << "|" << endl; cout << "|" << setw(9) << "|" << endl; cout << "|" << setw(9) << "|" << endl; cout << "|" << setw(9) << "|" << endl; cout << "|" << setw(9) << "|" << endl; cout << "|" << setw(9) << "|" << endl; cout << "|" << setw(9) << "k|" << endl; cout << "----------" << endl; } 

my problem of right when print out entire deck in line down (vertically) so:

---------- |3       | |        | |        | |        | |        | |        | |        | |        | |       3| ---------- ---------- |10      | |        | |        | |        | |        | |        | |        | |        | |      10| ---------- ---------- |k       | |        | |        | |        | |        | |        | |        | |        | |       k| ---------- 

when need display them so:

---------  --------- |k      |  |2      | |       |  |       | |       |  |       | |       |  |       | |       |  |       | |       |  |       | |       |  |       | |       |  |       | |      k|  |      2| ---------  --------- 

what best method cards display horizontally instead of vertically? use picture of card instead of printing them out on screen?

one way around gather contents of each line

enum { eedge, etop, emid, ebot, emax }; std::ostringstream cardline[emax]; 

for each card, instead of writing screen, update cardline

void deck::cardking() {     cardline[eedge] << "---------  ";     cardline[etop]  << "|k      |  ";     cardline[emid]  << "|       |  ";     cardline[ebot]  << "|      k|  "; } 

then when need print

std::cout << cardline[eedge].str() << std::endl; std::cout << cardline[etop].str() << std::endl; (int ii = 2; ii < 9; ++ii)     std::cout << cardline[emid].str() << std::endl; std::cout << cardline[ebot].str() << std::endl; std::cout << cardline[eedge].str() << std::endl; 

then, when want new line of cards

for (int ii = 0; ii < emax; ++ii)     cardline[ii].str(); 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -