Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'm messing around with game loops and going to create some games as practice.

Currently I have a steady game loop up where the game is updated as fast as possible and the rendering is updated x times a second (25 currently)

The rendinging method is basically a draw + Console.Clear() and at very high updates the display becomes very jittery since it's not finished drawing when Console.Clear() hits.

Is there a better way of doing something like this?

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

like image 795
Ólafur Waage Avatar asked Jan 24 '23 07:01

Ólafur Waage


1 Answers

Assuming you Write a full screen from topleft again in every loop you could simply replace the Clear() with:

 Console.SetCursorPosition(0, 0);

And overwrite the previous screen.

like image 109
Henk Holterman Avatar answered Jan 30 '23 02:01

Henk Holterman