-
April 16th, 2009, 09:07 PM
#1
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!
-
April 16th, 2009, 09:22 PM
#2
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.
-
April 17th, 2009, 04:50 PM
#3
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;
}
-
April 17th, 2009, 08:08 PM
#4
Re: Horizontal output?
Awesome, thanks. I'll see what I can do
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|