Im trying to make a roguelike game, and everytime you move it needs to clear the screen then reprint it, but I didnt use system(cls), I used this as a function:
This was almost what I wanted... It doesnt flicker at all, but it doesnt remove everything on the screen, only replaces it basically... So anything new text doesnt cover shows up around the new text...Here are the pictures:
First code: http://img683.imageshack.us/img683/2803/flicker.jpg
Second code: http://img686.imageshack.us/img686/5001/nonflicker.jpg
So how can I edit the second one to remove everything like the first one while not flickering?
The easiest way to get rid of the flickering is to erase the old text which is not covered by the new text by printing blanks on that position. Otherwise you have to create a second buffer to write in. If writing is done you can swap it with the screen buffer.
By updating only those parts that change, you reduce update time and visual artifacts are reduced to the stuff that is changing anyway... This is the way that ncurses does it.
More than two buffers is also a waste. You only need two: one that is visible while you draw on the other. The only visual artifact is in the swap. If done properly, it is nearly instantaneous. If not done properly, then you get tearing. For video games, you only need to update when drawing is done, so the possibility of tearing is eliminated.