Now I think I'll write a console engine for Java for daggers, in C # I implemented it quite easily, because there is cursor control, but there was a problem with Java

public void cellDraw() { //отрисовка зависит от свойств //Пустая ячейка IsBlank if(this.IsBlank == true) { System.out.println("-----"); System.out.println("- -"); System.out.println("-----"); } //Крестик IsTic else if (this.IsTic == true) { System.out.println("-----"); System.out.println("- X -"); System.out.println("-----"); } 

The primitive blocks from hyphens are displayed, respectively, the next block should start with the N - position of the line in the console, the analogy in C # Console.SetCursorPosition(x,y) .

    1 answer 1

    This can be done using control sequences, which can be read about, for example, here: https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences

    In Java, this can be implemented using the following method:

     public static void setCursorPorision(int x, int y) { final char escCode = 0x1B; System.out.print(String.format("%c[%d;%df", escCode, y, x)); } 

    PS: It seems that this method does not work in Windows, alas.