Help with fixing screen position

Hey guys,

I am trying to make print a pattern with * on a 1010 two dimensional array in a for loop and I want the incoming 1010 to overlap the previous 1010 so that the * look like it is moving. is there a way to fix the screen position?
ever time it prints a 10
10 the screen moves.

using a shell script

Please help.

trying to make a bing snake game

With no indication of which operating system, shell, or window manager you're using it is hard to guess at what might work in your environment, but I would start by looking at the man pages for the clear and tput commands; especially looking to see if tput cup row column might be of use.

1 Like

Thank you. I am using unix OS
I found

printf "\e[?25h\e[5;0H\e[0m"

which fixed my problem
I will definitely explore tput and clear

Using Terminal escape codes.

1) Clear Screen.
printf "%b" "\x1B[2J\x1B[H"

2) Terminal "reset", mainly for CygWin.
printf "%b" "\x1Bc\x1B[2J\x1B[H"

3) Write into the Terminal Title Bar.
printf "%b" "\x1B]0;YOUR TEXT HERE...\x07"

4) For bash, ksh and the like, a sleep command using read with KB override as a function.
delay()
{
	read -r -n 1 -s -t "$1"
}

5) Printing plotting and drawing is easy take a look here:-

1 Like