I guess you use the CRT unit for capturing key events and writing to different position in different colors. If that is the case, you might take a look at the
LazTermUtils package I created because of the limitiations of the CRT unit, you had the pleasure of experiencing yourself.
Quite intereting for you might be the example
ColorTest.lpr, which draws colors to the whole terminal that change every frame:
while True do
begin
//...
Term.Output.CursorGoto(0, 1);
v := (v + 1) mod 1001;
sz := Term.Size; // get the current size of the console
for i := 0 to (sz.Rows-1)*sz.Columns - 1 do // iterate through all cells (rows * -1 because the first line is used to print fps, -1 at the end because this is 0 based)
begin
Term.Output.WriteModified(' ', [HSVtoRGB(i/((sz.Rows-1)*sz.Columns), 1, Abs(v-500)/500)]); // draw each cell individually
end;
Term.Output.FlushBuffer; // as a buffering layer is used, to not have to call multiple writes to the console for each char, this will draw the whole screen at once
// ...
end;
It also provides functionality to read key presses non blocking (even key combinations with shift or ctrl), as in the example
NonBlockingReadTest.lpr, which will loop and print the current time until escape was pressed:
while true do
begin
Term.CursorGoto(0, 0);
DateTimeToString(s, 'dd.mm.yyyy hh:nn:ss', Now);
Term.Output.WriteLn(s);
Term.Output.WriteLn('To exit press escape');
if Term.Input.ReadKeyNonBlocking(key) then
if Key.SpecialKey and (Key.SpecialKeyCode = skEscape) then
Break;
Sleep(100);
end;
So if you want to build a game, you could combine these two and have a loop that first checks if a key was pressed, if so the internal state gets updated, then the size is checked and then it is computed if something needs to be redrawn.
Also unlike crt, which only supports 16 colors, LazTermUtils supports 24 bit true color. But only works on "modern" xterm compatible Terminals, so pretty much all Linux and MacOS Terminals and Windows 10 (no prior Windows versions). But the Windows terminal is really slow.