0

I'm trying to make it to where I get smooth animations within the visual studio terminal with ASCII.

I've tried looking and everywhere and I cant find a good solution. I have a grid of numbers such as

000000000
000000000
000000000
000000000
000000000

and I want to clear the console and update the grid. The problem is when I clear the terminal with "\033[H\033[2J" it works, and I can rewrite the updated grid. But it gets a blocky glitchy flickery look to it. So, I tried pausing the thread in the correct place but that made it even worse. So, I came to the conclusion that maybe I could only change what number or little sector such as (0,0) and that would eliminate the blocky-ness on all the other numbers or sectors but the ones that were changed would still appear blocky. I am trying to make Snake so this could replace the smooth motion of the snake if I made it in a retro style. However, I can't figure out what String is used to position the cursor or delete and replace a specific character. Any help would be appreciated.

My code for testing:

import java.util.*;
public class TerminalSnake{
    public static void main(String[] args){
        while(true){
            System.out.print("\033[H\033[2J");
            // System.out.flush();
            for(int i = 0; i<10; i++){
                System.out.println("0000000000000000");
            }
            try{
                Thread.sleep(50);
            } catch(InterruptedException e) {
            }
        }
    }
}
  • Maybe Reference `Printing ANSI color codes in java works on VS Code terminal but not in CMD?`( https://stackoverflow.com/questions/74319252/printing-ansi-color-codes-in-java-works-on-vs-code-terminal-but-not-in-cmd ) – life888888 Jan 13 '23 at 17:20
  • I'm not trying to change the color of the text. Thats relatively simple. I'm trying to create animation within the terminal smoothly. – 404-No Social Skills Found Jan 13 '23 at 17:38

0 Answers0