Is there a better way to make console games than with Console.Clear ()?

I have been busy with game cycles and am going to create some games as a practice.

I currently have a steady game loop where the game updates as fast as possible and the rendering updates x times per second (25 currently)

The parsing method is basically draw + Console.Clear (), and with very high updates, the display becomes very nervous since it did not finish drawing when Console.Clear () is displayed.

Is there a better way to do something like this?

Can I write any data to the console and then replace it with other data?

+4
source share
3 answers

Assuming you re-write the full screen from the queue in each loop, you can simply replace Clear () with:

Console.SetCursorPosition(0, 0); 

And overwrite the previous screen.

+4
source

Since you're still in C #, you might need to look at the XNA Framework .

I assume that your problem comes from Console.Clear() , which is not optimized for this use, since XNA uses a similar method ( Clear() is called on GraphicsDevice ).

If you do not want to try using XNA, you may need to draw a rectangle faster (solid black or gray or whatever), rather than calling Clear() on a blank screen, and then draw it.

+3
source

You blink want to check out ConsoleLibrary

I haven't used it, but from the article / demo, it seems like this will allow you to do a bunch of neat stuff on the console.

+1
source

All Articles