How do you print out the menu in main_menu function?
I see that you have a MENU array, and then you initialize MENU_OPTION with value 0. But how do you move the pointer to iterate through each value of the array to print out its value, especially since you're just using separate if statements? That is, how does that '0' change to '1', '2', etc.? Does bash just know to go through the array to see if it finds a value that equals the one you've put on the right side of the '=' in your if statements?
main_menu() {
MENU=( 'New' 'Load' 'Credits' 'Quit' )
MENU_OPTION=${MENU_OPTION:=0}
printf "\033c"
printf "%s\n\n" "${SWORD_IMAGE:=$(< images/sword)}"
if [[ ${MENU[$MENU_OPTION]} = 'New' ]]; then
printf " \e[1;32m1. New Game\e[m\n\n"
else
printf " 1. New Game\n\n"
fi
if [[ ${MENU[$MENU_OPTION]} = 'Load' ]]; then
printf " \e[1;32m2. Load Game\e[m\n\n"
else
printf " 2. Load Game\n\n"
fi
if [[ ${MENU[$MENU_OPTION]} = 'Credits' ]]; then
printf " \e[1;32m3. Credits\e[m\n\n"
else
printf " 3. Credits\n\n"
fi
if [[ ${MENU[$MENU_OPTION]} = 'Quit' ]]; then
printf " \e[1;32m4. Quit\e[m\n\n"
else
printf " 4. Quit\n\n"
fi
Edited by Ben Taylor