-
Horizontal output?
So I'm writing a dice game that displays 5 dice on the screen at one time. Part of my code looks like this:
diceshow();
diceshow();
diceshow();
diceshow();
diceshow();
This function determines the random value of five dice and displays the 5 ascii dice on the screen. The output looks roughly like this:
Code:
---------
I I
I O I
I-------I
---------
I O I
I O I
I-------I
---------
I I
I O I
I-------I
That is, the dice are stacked vertically on the screen upon output. Lol, this would be fine, except the screen isn't big enough to display all five of the dice onscreen.
Is there a way to skip the newline somehow so that that the output comes out horizontally like this:
Code:
--------- -------- ---------
I I I O I I I
I O I I O I I O I
I-------I I-------I I------I
(Sorry for the god-awful dice here--don't have time to edit them perfectly here :))
Thanks!
-
Re: Horizontal output?
Not using standard IO, unless you want to majorly re-write your die-drawing function to only do one line at a time. Platform-specific console routines may allow you to do this more easily.
-
Re: Horizontal output?
Do your loops so you iterate by row and by die number, with an array holding the roll values. Make a function that will draw a given row (but not every row) for a given roll value.
Maybe this code snippet will explain better, I'll leave the rest of the implementation up to you:
Code:
for(int row=0; row<numRows; ++row)
{
for(int dieNum=0; dieNum<numDice; ++dieNum)
{
drawRow(diceValueArray[dieNum],row);
cout<<" ";
}
cout<<endl;
}
-
Re: Horizontal output?
Awesome, thanks. I'll see what I can do :)