Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Function to say a given command
- say_command() {
- espeak -ven+f3 "$1"
- }
- score=0
- while true; do
- # Generate a random command
- command=$((RANDOM % 3))
- case $command in
- 0) say_command "Bop It"; key="B" ;;
- 1) say_command "Twist It"; key="T" ;;
- 2) say_command "Pull It"; key="P" ;;
- esac
- # Read user input
- read -n 1 -t 3 input
- # Convert input to uppercase
- input=$(echo "$input" | tr '[:lower:]' '[:upper:]')
- # Check if input matches the command
- if [ "$input" == "$key" ]; then
- score=$((score + 1))
- echo "Correct! Score: $score"
- else
- echo "Wrong! Game Over. Final Score: $score"
- break
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment