Jump to content
  • Advertisement

Archived

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

XDarkScar

Clearing text off Console

This topic is 5639 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

Advertisement
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
quote:
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):

+01234567890
0
1
2
3 xxxxxx
4 xxxxxx
5 xxxxxx
6
7
8
9
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 << " ";
}
}
return;
}
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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!