#!/bin/bash function DetectInput //判断输入的数据,控制方向 { while [[ 1 ]] do c="" read -n 1 c //读取输入的字母 echo -ne "\r \r" //清除输入的字母 if [[ $c == "a" || $c == "j" || $c == "A" || $c == "J" ]] then kill -36 $pidShowSnake //改变贪吃蛇的运动轨迹 elif [[ $c == "w" || $c == "i" || $c == "W" || $c == "I" ]] then kill -37 $pidSh