console game

Started by
7 comments, last by SKATIN_HARD 18 years, 7 months ago
is there any real easy way to clear a console while running your game? I'm thinking it would clean up my console game really good not having all the previous text above that makes things hard to read.
"Only two things are infinite, the universe and human stupidity, and I'm not sure about the former." - Albert Einstein (1879-1955) That is so very true...
Advertisement
Please specify the language and environment you are using...

.NET 2.0 has a lot of nice console commands...

Cheers
Without knowing what programming language you're using it's hard to make more than a general recommendation. Did you try just printing out a bunch of new lines?
You could print x '\n' where x is the maximum number of rows, or if you know you are on windows you could use "system("clr");". There is probably better ways than these, but those where the one I used when programming console games.

EDIT: Assumed you where using C++, the '\n' could be used in other languages too, but the system("clr") would be used in another way.
sorry, c++ would be the language, using windows XP and visual c++ 6
"Only two things are infinite, the universe and human stupidity, and I'm not sure about the former." - Albert Einstein (1879-1955) That is so very true...
What language/platform/OS are you developing for/on? If you're using windows you can clear the console using the FillConsoleOutputCharacter(), FillConsoleOutputAttribute() or FillConsoleOutputCharacter() Win32 API functions to fill the visible area with the desired character/color.

arm
I was actually wondering the same thing as the original poster... What I think he means is, is there someway to clear the screen, much like the BASIC command 'CLS'.

I know of an old trick where you could write directly to the video memory at 0x800 for monochrome and 0xC000 (I think) for color. However, I tried it, it wasn't pretty. I may have done it wrong though.

It could be done with an old compiler, (any 16 bit compiler or DOS 32 bit compiler), or even look for a copy of PowerBASIC. But, that's not what the OP is asking for :D .
----------------------------Check out my crappy games...
Quote:Original post by Tarkus
I was actually wondering the same thing as the original poster... What I think he means is, is there someway to clear the screen, much like the BASIC command 'CLS'.


Not portably. Some people advocate system("cls"); -- it is an aberration.

arm has already posted the correct solution for MS Windows console applications.

Quote:I know of an old trick where you could write directly to the video memory at 0x800 for monochrome and 0xC000 (I think) for color. However, I tried it, it wasn't pretty. I may have done it wrong though.


You can't do that in protected mode. That era is dead and buried. Use the API calls that have been mentioned.

"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
system("cls"); is what I use. It tends to work well so I just go with that.

This topic is closed to new replies.

Advertisement