11111111111

 #!/bin/sh

declare -i RANDOM

#declare -a arry={0..9}

#index=$RANDOM%10

string="a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"

number="0 1 2 3 4 5 6 7 8 9"

A=($string)

N=($number)

num_a=${#A[*]} 

num_n=${#N[*]}

count=0

i=0

#wordgame.sh

trap "my_exit" 2 #ctrl+c

function my_exit()

{

    Clear

echo "You'd just hitted <15> at number: $i"

    echo "I'll exit ...."

    break 1

}

clear

    echo ""

        echo ""

        echo ""

        echo ""

    echo ""

    echo "          ###################################################"

    echo "          ***************************************************"

    echo "          ***************************************************"

    echo "                      欢迎你使用本游戏        "

    echo "              如果有不好的地方请给出你宝贵的意见或建议      "

    echo "                     祝你游戏愉快        "

        echo "          ***************************************************"

        echo "          ***************************************************"

        echo "          ###################################################"

    sleep 3s

    clear

    echo "请等待进入游戏..........."

    sleep 1

    echo “3”

    sleep 1

    clear

    echo “2”

sleep 1

clear

echo“1”

sleep 1

    clear

while true

do

    echo "进入数字练习模式.................1"

    echo "进入字母练习模式.................2"

    echo "退出游戏.........................q|Q|3"

    read a

    case $a in

    1)

       clear

       echo "欢迎来到数字练习模式。。。。;"

       echo "。。。。。请选择游戏难度。。。。。。;"

       sleep 1s

       clear

    while true

    do

       echo "简单模式游戏。。。。。。。。。。。1"

       echo "中等模式游戏¡。。。。。。。。。。。2"

           echo "退出当前模式。。。。。。。。。。q|Q"

       echo "请输入你所选择游戏难度:"

       read b

       sleep 1s

       clear

       case $b in

       1)

       while [ "$i" != "5" ]

       do

       s=$(($RANDOM%10))

       echo -e "\033[47;31;5m $s \033[0m"

       read -n 1 -t 2 c

       if [ "$c" == $s ]; then

           count=$(($count+1))

       else

           count1=$(($count1+1))

       fi

       echo "正确个数为$count,错误个数为$count1"

       i=$(($i+1))

       done ;;

       2) 

       while [ "$i" != "5" ]

                do

                s=$(($RANDOM%10000+1000))

                echo " $s "

                read -n 1 -t 1 d

                if [ "$c" == $s  ]; then

                        count=$(($count+1))

                else

                        count1=$(($count1+1))

                fi

                echo "正确个数:$count,错误个数:$count1"

       i=$(($i+1))

                done ;;

       q|Q)   echo "1s后退出当前游戏模式"

           sleep 1s

           clear

           break 1;;

        *)      echo -e "你输入的信息有误请从新输入。。。。";;

       esac

    done;;

2)

       clear

       echo "。。。。。欢迎来到字母练习模式。。。。"

       echo "。。。。。请选择游戏难度。。。。。。。"

       sleep 1s

    while true

    do

       clear

       echo "简单字母练习难度。。。。。。。。。。。1"  

       echo "中等字母练习难度。。。。。。。。。2"

       echo "退出当前模式。。。。。。。。。。。。。q"

       echo "请输入你的选择:"

       read e

       sleep 3s

       clear

       case $e in

       1)

       while [ "$i" != "10" ]

       do

       s=${A[$((RANDOM%num_a))]}

       echo -e "\033[47;31;5m $s \033[0m"

       read -t 2 a

       if [ "$a" == $s ]; then

                        count=$(($count+1))

                else

                        count1=$(($count1+1))

                fi

                i=$(($i+1))

       done

       echo "正确个数:$count,错误个数:$count1";;

       2)                  

       while [ "$i" != "10" ]

                do

                s=${A[$((RANDOM%num_a))]}${A[$((RANDOM%num_a))]}${A[$((RANDOM%num_a))]}

                echo -e "\033[47;31;5m $s \033[0m"

                read -t 2 a

                if [ "$a" == $s ]; then

                        count=$(($count+1))

                else

                        count1=$(($count1+1))

                fi

                i=$(($i+1))

                done

                echo "正确个数:$count,错误个数:$count1";;

                q)    echo "1s后退出当前游戏模式"

                        sleep 1s

           clear

                        break 1;;

                 *)      echo -e "你输入的信息有误请从新输入。。。。";;

                esac

    done;;

q|Q|3)  echo "1s后退出游戏"

        sleep 1s

        clear

        exit 0;;

    *)  echo -e "你输入的信息有误请从新输入。。。。";;

        esac

done

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值