X-Git-Url: https://git.sommitrealweird.co.uk/advent-of-code-2019.git/blobdiff_plain/79304811c66e5ce6d4898a33dd8f4799a5d1c5d3..56494c74c59e37db19d205a34729992c55f0b08c:/day13/screen.sh?ds=inline diff --git a/day13/screen.sh b/day13/screen.sh index 3bc3956..d3bbe6d 100644 --- a/day13/screen.sh +++ b/day13/screen.sh @@ -1,9 +1,27 @@ __arcade_score=0 clear_screen() { + # first reset then clear + echo -en '\033c' echo -en '\033[2J' } +echo_off() { + stty -echo +} + +echo_on() { + stty echo +} + +hide_cursor() { + tput civis +} + +show_cursor() { + tput cvvid +} + move_cursor() { local x=$1 local y=$2 @@ -42,14 +60,6 @@ draw_tile() { esac } -hide_cursor() { - tput civis -} - -show_cursor() { - tput cvvis -} - draw_score_board() { local value=${1:-0} local scoreboard_y=20 @@ -78,6 +88,7 @@ update_score_board() { arcade_screen_init() { clear_screen + echo_off hide_cursor draw_score_board } @@ -94,7 +105,7 @@ arcade_screen_update() { arcade_screen_finish() { move_cursor 0 23 show_cursor - echo high score: $__arcade_score + echo_on } arcade_screen() { @@ -103,10 +114,7 @@ arcade_screen() { local -A blocks # first, clear the screen and hide the cursor - clear_screen - hide_cursor - - draw_score_board + arcade_screen_init while read x; do read y