shell脚本编写的俄罗斯方块游戏代码

2019-09-23 09:40:36丽君

        ((t2 = iTop + 14))
        echo -ne "33[3${cScoreValue}m33[${t2};${t1}H${iLevel}"
        echo -ne "33[0m"
}

 
#退出时显示GameOVer!
function ShowExit()
{
        local y
        ((y = iTrayHeight + iTrayTop + 3))
        echo -e "33[${y};0HGameOver!33[0m"
        exit
}

 
#显示用法.
function Usage
{
        cat << EOF
Usage: $APP_NAME
Start tetris game.

  -h, --help              display this help and exit
      --version           output version information and exit
EOF
}

 
#游戏主程序在这儿开始.
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
        Usage
elif [[ "$1" == "--version" ]]; then
        echo "$APP_NAME $APP_VERSION"
elif [[ "$1" == "--show" ]]; then
        #当发现具有参数--show时,运行显示函数
        RunAsDisplayer
else
        bash $0 --show&        #以参数--show将本程序再运行一遍
        RunAsKeyReceiver $!        #以上一行产生的进程的进程号作为参数
fi