Skip to content
Snippets Groups Projects
Commit 182ac23e authored by Leo's avatar Leo
Browse files

afficher_plateau

parent 09bb61d5
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env bash
# $1 est une liste des coo de pomme, $2 est une liste du corps du snake, $3 est un entier de la longueur du plateau
function afficher_plateau {
for i in {0.."$3"}
do
for y in {0.."$3"}
do
if [ "$i" -eq 0 ] || [ "$y" -eq 0 ] || [ "$i" -eq getPlateauLongueur ] || [ "$y" -eq getPlateauLargeur ]
then
echo -n " ⬛";
elif test "$i" -eq "${1[0]}" && test "$y" -eq "${1[1]}"
then
echo -n " 🟥";
else
body_part=0
for part in "${2[@]}"; do
IFS="," read part_x part_y <<< "$part"
if [[ "$i" -eq "$part_x" && "$y" -eq "$part_y" ]]; then
echo -n " 🟩"
body_part=1
break
fi
done
if [[ "$body_part" -eq 0 ]]; then
echo -n " ⬜"
fi
fi
done
echo ""
done
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment