I'm trying to create a multi line ascii art animation using Intellij, and for that I'm creating an array of strings and I refer to each element of the array as a frame.
After that, in order for that to work, I need to change what was printed to the console each time unit x.
I do know that I can replace the last line printed to the console with "\r" like so:
for (int i = 0; i <= 100; i++)
{
Thread.sleep(200);
System.out.printf("\r %s ", i);
}
however it doesn't delete the older lines printed.
The next thing that I've tried is to clear the console before each 'frame' printed but IntelliJ Idea doesn't have console like Visual Studio so, from what I understand, there is no way to clear the entire console from the code.
So I do know that there is no way to delete the console in intellij but is there any other solution or a workaround for that problem?
to make things more simple I'll add an example. Let's say I want to print this weight lifting animation (ascii art taken from - https://ascii.co.uk/art/stickman)
O--,---,--O
._O_. O--=-O-=--O \ O /
_._ ,_O_, O--<-+->--O '-' - -
/ O \ ,-O-, O--(---)--O X v -
\| |/ O--=---=--O >'> / \ / ) / \
O--+=-=+--O 2"2 - - - - ~ z = =
So I'm creating a 2d array of strings for the frames
(after that ill create the frame with String.join("\n", < frame elements >)).
String[][] frames =
{
{
" ",
" ",
" _._ ",
" / O \\ ",
" \\| |/ ",
"O--+=-=+--O"
},
{
" ",
" ",
" ,-O-, ",
" O--=---=--O ",
" 2"2 "
},
{
" ",
" ,_O_, ",
" O--(---)--O ",
" >'> ",
" - - "
},
{
" ._O_. ",
" O--<-+->--O ",
" X ",
" / \\ ",
" - - "
},
{
" O--=-O-=--O ",
" '-' ",
" v ",
" / ) ",
" ~ Z "
},
{
" O--,---,--O ",
" \\ O / ",
" - - ",
" - ",
" / \\ ",
" = = "
}
}
and in each time unit x+1 I want the console to show frames[x+1] instead of frames[x].
any ideas?