Refreshing a...console?

Started by
9 comments, last by Lacutis 18 years, 9 months ago
Well, time to reveal what I've been planning: CONSOLE TETRIS!! Problem is, I don't want to keep printing more text! I wan't to remove old text and replace with new text. Possible? Not possible?
The best thing to do is just choose whatever you think you'd prefer, and go for it. -Promit
Advertisement
Use system("CLS");
Assuming Windows, you can write directly to coordinates in the console using the WriteConsoleOutput() family of functions. In *nix, you can use a curses library like ncurses.
Quote:Original post by Gink
Use system("CLS");


Exactly what I needed, thanks.
The best thing to do is just choose whatever you think you'd prefer, and go for it. -Promit
Quote:Original post by SiCrane
In *nix, you can use a curses library like ncurses.

And there's also pdcurses which is cross platform.

Quote:Original post by orcfan32
Quote:Original post by Gink
Use system("CLS");


Exactly what I needed, thanks.


But I don't think this way is very effective. It calls an external program where it executes a command to clear the screen. It might make your game slow at updating itself. You could try the second approach listed here, http://support.microsoft.com/default.aspx?scid=kb;en-us;99261, which should make you program more effective.

Edit: How to I create clickable URL's?
What does CLS stand for?
Well, nevermind clearing the entire screen. How would I clear a certain line??
The best thing to do is just choose whatever you think you'd prefer, and go for it. -Promit
Quote:Original post by Dark_Flame
What does CLS stand for?


ClearScreen ;)
Quote:Original post by orcfan32
Well, nevermind clearing the entire screen. How would I clear a certain line??


In Tetris, when you need to do this (or something like it), you'll have to move stuff down into the space anyway. What you want to do is maintain a buffer inside your program that describes the current "appearance" of the game, and periodically redraw that to screen. As blocks fall/lines form/etc., update the buffer by copying/clearing/resetting data within it.

This topic is closed to new replies.

Advertisement