Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Clearing text off Console

This topic is 5719 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

what if only in a certain area?

Easy way of programming: Code, Graphics, Swearing....

[edited by - XDarkScar on April 17, 2003 10:28:03 PM]

Share this post

Link to post
Share on other sites
I''m not sure, but what I do is if there''s always something there (i.e. game board) I make a function and redraw it each time something changes.

Share this post

Link to post
Share on other sites
Original post by nobodynews
I think I know what might work. First, you need a function that can set the cursor position based on x,y coordinates. These are usually compiler dependant. Let''s say the function is gotoxy(int x, int y) First say you have this as on your screen(the numbers are the window bounderies/coordinates):

3 xxxxxx
4 xxxxxx
5 xxxxxx
And you want to erase the x''s. This is how the function should look:

void eraseScreenRect(int left, int top, int right, int bottom) {
for(int j = 0; j <= (top-bottom); j++) { // number of lines to erase

gotoxy(left, top+j); // go to start of box, then each new line

for(int i = 0; i <= (right - left); i++) { // number of spaces to print

cout << " ";
conio.h gotoxy:
To clear the x''s, you would call the function like this:
eraseScreenRect(2, 3, 7, 5);

http://www.jsquaredproductions.com/tutorials/ASCII_Attack_Ch1-2.html it may or may not work with vc++, I heard it doesn''t.

More on console functions: http://www.gametutorials.com/Tutorials/C/C_Pg3.htm

EDIT: various stuff. Oh, I haven''t tested this code, but hopefully it works and/or you get the jist.
EDIT2: Also, on the second link I gave, check out the section on "Introduction to Console Functions" and read over the source. The function that you want to use is SetConsoleCursorPosition

[edited by - nobodynews on April 17, 2003 11:14:44 PM]

gotoxy is only for borland compilers.

-~-The Cow of Darkness-~-

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!