W
W
WTFAYD2017-08-05 21:09:54
Graphic arts
WTFAYD, 2017-08-05 21:09:54

How is real-time console graphics implemented?

Hello! My question may sound rather vague, but I'll try to explain anyway.
Here, let's say, I wrote the working part (algorithmic) for tic-tac-toe, that is, everything works, win-lose-draw is determined, and the like. And now I need to correctly arrange the graphical part of the game in the console. Of course, while writing the algorithm, I did something similar, but it looks strange - that is, every time the player makes a move, I reprinted the game grid just below the previous grid output.
How are graphics made in console games?
For example, it seems wrong to me to clear the console window and redraw the grid after each move. Or, for example, if I want to stick a clock into the game window, do I really have to update the screen every second in this way?
That is, how are changes (color, position, etc.) monitored and made in the console output in real time or based on user actions?
Thanks in advance.
PS The language I write in is Java, but I'm interested in a more general concept of how it all happens and what is usually used for this.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
display: block, 2017-08-05
@WTFAYD

For example bash:

#!/bin/bash

echo -ne '#####                     (33%)\r'
sleep 1
echo -ne '#############             (66%)\r'
sleep 1
echo -e '#######################   (100%)\r'

Flags:
n - do not newline after output
e - turn on the interpretation of escaped characters (\r)
\r in a line means a carriage return (to the leftmost position).
Further, after the slip, we write a new line on top of the line.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question