3 Questions on Outputting ASCII characters (and other things)
What''s the best command to output non-keyboard ASCII characters?
For example, if I wanted to draw a border around something in a DOS Console using the ASCII line art characters, what would be the best command to use? Could you give an example or two? Would I use cout, puts, printf, or something else completely?
Also, as a second question, is there a ''not so complicated'' way to change the foreground color of output text that is FAST? I''m currently using some WIN32 Console commands to get a handle to the standard console and change the colors that way. It works, but when you are drawing a map to the screen and each character is a different color, it really slows it down.
Oh, and might as well throw out a Third question... Is there a way to output characters to a backbuffer then flip them onto the screen? I know you can do that with graphics, but can you do that with text? What would be the best way of approaching that? I have ALLEGRO installed but I''m not good at using it yet. Does ALLEGRO support stuff like that?
Thanks for the help. GameDev.net is Great!
~~~~~~~~~~~
Chris Vogel
~~~~~~~~~~~
WyrmSlayer RPG - In Early Development
Hmmm... Console Funtions arent slow to me
Just make some functions that apply them and youre good to code!
What are you exually using Win32 or Console? Cuz Console will just WRITE all the things again, it wont FLIP!
[edited by - pipo declown on September 16, 2002 11:49:16 AM]
Just make some functions that apply them and youre good to code!
What are you exually using Win32 or Console? Cuz Console will just WRITE all the things again, it wont FLIP!
[edited by - pipo declown on September 16, 2002 11:49:16 AM]
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
quote: Original post by Pipo DeClown
Hmmm... Console Funtions arent slow to me
Just make some functions that apply them and youre good to code!
What my code is doing is...
Change color to Map[x][y].tilecolor
GotoXY(x,y)
cout Map[x][y].tile
Repeat....
Map is about 15x30 characters. Without the Change Color code, it''s drawn to the screen without even a flicker. With the Change color code, you can see it draw each line by line, and it takes about 2 seconds to draw all the chars. Not a horrible amount of time, but slower than I wanted.
~~~~~~~~~~~
Chris Vogel
~~~~~~~~~~~
WyrmSlayer RPG - In Early Development
quote: Original post by Pipo DeClown
Hmmm... Console Funtions arent slow to me
Just make some functions that apply them and youre good to code!
What are you exually using Win32 or Console? Cuz Console will just WRITE all the things again, it wont FLIP!
[edited by - pipo declown on September 16, 2002 11:49:16 AM]
I''m using a Win32 Console App. So It''s a DOS Console under Windows.
~~~~~~~~~~~
Chris Vogel
~~~~~~~~~~~
WyrmSlayer RPG - In Early Development
Oh, and here is the code I''m using to set the Foreground Color of Text in my Win32 DOS Console.
Also, anyone have an answer to Question 1?
~~~~~~~~~~~
Chris Vogel
~~~~~~~~~~~
void setForeColor(int c){ static HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); WORD wAttrib = 0; CONSOLE_SCREEN_BUFFER_INFO csbi; GetConsoleScreenBufferInfo(hConsole,&csbi); wAttrib = csbi.wAttributes; wAttrib &= ~(FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY); if (c & 1) wAttrib |= FOREGROUND_BLUE; if (c & 2) wAttrib |= FOREGROUND_GREEN; if (c & 4) wAttrib |= FOREGROUND_RED; if (c & 8) wAttrib |= FOREGROUND_INTENSITY; SetConsoleTextAttribute(hConsole, wAttrib);}
Also, anyone have an answer to Question 1?
~~~~~~~~~~~
Chris Vogel
~~~~~~~~~~~
WyrmSlayer RPG - In Early Development
September 16, 2002 11:12 AM
There are two basic alternatives. One thing that might be causing your problem is that ''cout'' is buffered output. So try switching to ''putchar()'' or some similar function and see if that helps.
If that doesn''t work, and it turns out that changing the colors really is an irreducible bottleneck, then you want to change the output scheme. Sort your display list by color so that your color changes happen as infrequently as possible.
-D
As far as outputting things to the screen, the biggest difference between functions is how buffered they are. If you are doing character by character output with gotoXY()''s in between, then choose a less buffered command. If you are printing a bunch of stuff sequentially then go with a more buffered command.
-D
If that doesn''t work, and it turns out that changing the colors really is an irreducible bottleneck, then you want to change the output scheme. Sort your display list by color so that your color changes happen as infrequently as possible.
-D
As far as outputting things to the screen, the biggest difference between functions is how buffered they are. If you are doing character by character output with gotoXY()''s in between, then choose a less buffered command. If you are printing a bunch of stuff sequentially then go with a more buffered command.
-D
Anyone else have any insite on Questions 1 or 3?
I need to know how to output extended ASCII commands to draw using ASCII art. I''m assuming I could do this with any standard output command like cout or printf, but what is the format? For example if I wanted to output a line that consisted of ASCII Chars... 158, then 20 153''s, then a 141, what''s the best way to do that?
also, is there a way using ALLEGRO or something else to write a full screen of text and color info off-screen then flip it to the screen all at once? I know I could do this with a language called EUPHORIA, but I''m not sure how with C.
Thanks!
~~~~~~~~~~~
Chris Vogel
~~~~~~~~~~~
I need to know how to output extended ASCII commands to draw using ASCII art. I''m assuming I could do this with any standard output command like cout or printf, but what is the format? For example if I wanted to output a line that consisted of ASCII Chars... 158, then 20 153''s, then a 141, what''s the best way to do that?
also, is there a way using ALLEGRO or something else to write a full screen of text and color info off-screen then flip it to the screen all at once? I know I could do this with a language called EUPHORIA, but I''m not sure how with C.
Thanks!
~~~~~~~~~~~
Chris Vogel
~~~~~~~~~~~
WyrmSlayer RPG - In Early Development
Here's a little tidbit that people surprisingly tend not to know. If you know all of the character codes you can input them by pressing and holding alt, typing the character code on the numpad and then releasing alt.
As an example, look at the ASCII smiley face in my signature.
_____________________________
And the Phoenix shall rise from the ashes...
--Thunder_Hawk -- ¦þ
______________________________
[edited by - Thunder_Hawk on September 16, 2002 4:08:31 PM]
As an example, look at the ASCII smiley face in my signature.
_____________________________
And the Phoenix shall rise from the ashes...
--Thunder_Hawk -- ¦þ
______________________________
[edited by - Thunder_Hawk on September 16, 2002 4:08:31 PM]
______________________________________________________________________________________The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ"So. Any n00bs need some pointers? I have a std::vector<n00b*> right here..." - ZahlmanMySite | Forum FAQ | File Formats______________________________________________________________________________________
quote: Original post by Thunder_Hawk
Here''s a little tidbit that people surprisingly tend not to know. If you know all of the character codes you can input them by pressing and holding alt, typing the character code on the numpad and then releasing alt.
As an example, look at the ASCII smiley face in my signature.
_____________________________
And the Phoenix shall rise from the ashes...
--Thunder_Hawk -- ¦þ
______________________________
[edited by - Thunder_Hawk on September 16, 2002 4:08:31 PM]
Thanks for the tip. I know that works in DOS based compilers, I used to use it in QBASIC all the time. However, not all the characters seem to come through right in MSVC''s standard font.
~~~~~~~~~~~
Chris Vogel
~~~~~~~~~~~
WyrmSlayer RPG - In Early Development
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement