Skip to main content
added 269 characters in body
Source Link
Caleth
  • 66k
  • 2
  • 53
  • 101

The main reason you are seeing flickering is that you are drawing individual characters as fast as std::cout will let you.

By default on windows, std::cout will buffer the characters you stream to it until you supply a newline. Because there are many newlines in each board, this means that the console will draw line by line. Once it is done drawing once, you immediately start drawing again. This will scroll the lines of the console, so there isn't a consistent position of the top and bottom rows. When your screen goes to draw, those borders will be in an arbitrary position.

I would check if you still have flicker if there is a wait-time between draws, as a modern computer should be able to update an entire console window in a fraction your screen's refresh time. Adding a wait of approximately the time between redraws of your screen (~16ms for a 60Hz screen) will (mostly) ensure that your bottom row will be the bottom of the console output when the screen is drawn.

#include <thread> int main(){ while(true){ auto next_frame = std::chrono::steady_clock::now() + std::chrono::milliseconds(16); board(); std::this_thread::sleep_until(next_frame); } return 0; } 

The main reason you are seeing flickering is that you are drawing individual characters as fast as std::cout will let you.

By default on windows, std::cout will buffer the characters you stream to it until you supply a newline. Because there are many newlines in each board, this means that the console will draw line by line. Once it is done drawing once, you immediately start drawing again. This will scroll the lines of the console, so there isn't a consistent position of the top and bottom rows. When your screen goes to draw, those borders will be in an arbitrary position.

I would check if you still have flicker if there is a wait-time between draws, as a modern computer should be able to update an entire console window in a fraction your screen's refresh time. Adding a wait of approximately the time between redraws of your screen (~16ms for a 60Hz screen) will (mostly) ensure that your bottom row will be the bottom of the console output when the screen is drawn.

The main reason you are seeing flickering is that you are drawing individual characters as fast as std::cout will let you.

By default on windows, std::cout will buffer the characters you stream to it until you supply a newline. Because there are many newlines in each board, this means that the console will draw line by line. Once it is done drawing once, you immediately start drawing again. This will scroll the lines of the console, so there isn't a consistent position of the top and bottom rows. When your screen goes to draw, those borders will be in an arbitrary position.

I would check if you still have flicker if there is a wait-time between draws, as a modern computer should be able to update an entire console window in a fraction your screen's refresh time. Adding a wait of approximately the time between redraws of your screen (~16ms for a 60Hz screen) will (mostly) ensure that your bottom row will be the bottom of the console output when the screen is drawn.

#include <thread> int main(){ while(true){ auto next_frame = std::chrono::steady_clock::now() + std::chrono::milliseconds(16); board(); std::this_thread::sleep_until(next_frame); } return 0; } 
added 79 characters in body
Source Link
Caleth
  • 66k
  • 2
  • 53
  • 101

The main reason you are seeing flickering is that you are drawing individual characters as fast as std::cout will let you.

By default on windows, std::cout will buffer the characters you stream to it until you supply a newline. Because there are many newlines in each board, this means that the console will draw line by line. Once it is done drawing once, you immediately start drawing again. This will scroll the lines of the console, so there isn't a consistent position of the top and bottom rows. When your screen goes to draw, those borders will be in an arbitrary position.

Once it is done drawing once, you immediately start drawing again. I would check if you still have flicker if there is a wait-time between draws, as a modern computer should be able to update an entire console window in a fraction your screen's refresh time. Adding a wait of approximately the time between redraws of your screen (~16ms for a 60Hz screen) will (mostly) ensure that your bottom row will be the bottom of the console output when the screen is drawn.

The main reason you are seeing flickering is that you are drawing individual characters as fast as std::cout will let you.

By default on windows, std::cout will buffer the characters you stream to it until you supply a newline. Because there are many newlines in each board, this means that the console will draw line by line. This will scroll the lines of the console, so there isn't a consistent position of the top and bottom rows.

Once it is done drawing once, you immediately start drawing again. I would check if you still have flicker if there is a wait-time between draws, as a modern computer should be able to update an entire console window in a fraction your screen's refresh time.

The main reason you are seeing flickering is that you are drawing individual characters as fast as std::cout will let you.

By default on windows, std::cout will buffer the characters you stream to it until you supply a newline. Because there are many newlines in each board, this means that the console will draw line by line. Once it is done drawing once, you immediately start drawing again. This will scroll the lines of the console, so there isn't a consistent position of the top and bottom rows. When your screen goes to draw, those borders will be in an arbitrary position.

I would check if you still have flicker if there is a wait-time between draws, as a modern computer should be able to update an entire console window in a fraction your screen's refresh time. Adding a wait of approximately the time between redraws of your screen (~16ms for a 60Hz screen) will (mostly) ensure that your bottom row will be the bottom of the console output when the screen is drawn.

Source Link
Caleth
  • 66k
  • 2
  • 53
  • 101

The main reason you are seeing flickering is that you are drawing individual characters as fast as std::cout will let you.

By default on windows, std::cout will buffer the characters you stream to it until you supply a newline. Because there are many newlines in each board, this means that the console will draw line by line. This will scroll the lines of the console, so there isn't a consistent position of the top and bottom rows.

Once it is done drawing once, you immediately start drawing again. I would check if you still have flicker if there is a wait-time between draws, as a modern computer should be able to update an entire console window in a fraction your screen's refresh time.