I think it won't be easy to answer this and simple for me to understand as well.
I'm using Windows 7.
Imagine this game - a figure (let's say it's an "X") walks through a field.
The figure amd the field look like this:
[X][ ][ ][ ][ ][ ][ ][ ][ ][ ]
[ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
When you click the right arrow key, the field with the figure look like this:
[ ][X][ ][ ][ ][ ][ ][ ][ ][ ]
[ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
So you can imagine it now.
When the right arrow key is pressed, my program algorithm sees a system("cls") (and I know "system" functions are evil or something like that, so don't shout at me for that).
Clears the screen and types the stuff all over again.
When I want the 'X' to move faster, the lag is really noticeable.
It's not a huge problem for that kind of game, but I'm creating another one now that requires loads and loads of refreshes in a very short period of time.
The blinking of the screen would be unbearable.
I've seen a console game, created using C++ (as far as I know), that didn't have blinking at all. The "X" could move without a simple lag and it was incredibly smooth.
I think it wouldn't be easy to make it that way, but I wanna try. Make me an algorithm if you can that would me this possible. I might not understand it, but I'll use it on my games anyway.
I think I'd need to learn how to delete only the stuff that gets changed and not the whole foreground. Teach me a bit if you can.
It's a terrible waste of processing to clear the screen and redraw just to move a single char from one position to another. You'll be well advised to read up on ncurses, so that you just redraw the current char for x with a blank and redraw the next position.
I've decided to try ncurses first. If that doesn't work, I'll just use the cls function Need4Sleep gave me. I know ncurses should work smoother, so I'll try it first.
So now I've decided to try it and I wanna know how to start! If some of you could bother answering my another asked question here: http://www.cplusplus.com/forum/general/109857/
, that would be just great.
I have no idea what I should do :(
Thanks in advance!