Game Development History (shell digital games)

Source: Internet
Author: User

I originally wanted to write some shell scripts to train the trainer. I just wanted to give it a guess. so there will be a follow-up event. the most primitive guess script was first written. both functionality and aesthetics are unsatisfactory. Therefore, one version is updated iteratively, and the subsequent versions are better than the previous ones.

Through this script exercise, I understand the truth that "you cannot eat hot tofu in a hurry" remains the same. Whether you start a business or do some practical work, you can start from scratch, anyone who is proud to make perfect products at one time is impractical. good products must be refined and iterated based on user needs to withstand more severe challenges.


Guess the original digital game V1

# Given an unchangeable two-digit number, the user enters a number, the program prompts the size, follow the prompts to continue the input, until the correct number is entered, the game ends.

#!/bin/bashnum="32"while truedoread -p "Please input a "double-digit": " inputif [ $input -gt $num ] ; then  echo "Try smaller!"    elif [ $input -lt $num ];then      echo "Try bigger!"  else    echo "Good! You are right!"    break;fidone


Guess digital game ultimate v2

  • Added the illegal input judgment function.

  • Added the random number function.

#!/bin/bashNUM=`echo $RANDOM$RANDOM |cut -c 2-3`while truedo  read -p "Please input a "double-digit": " input  case $input in    [0-9][0-9] )    if [ $input -gt $NUM ] ;then      echo "Try smaller!"      elif [ $input -lt $NUM ];then        echo "Try bigger!"    else        echo "Good! You are right!"      break;    fi ;;  *)  read -p "Please input a "double-digit": " input ;;  esacdone


Guess digital game ultimate v3


  • The Count statistics function is added.

  • Adds the top 10 rankings in history.

  • Added the time display function.

  • The optimization result is displayed.

#!/bin/bashNUM=`echo $RANDOM$RANDOM |cut -c 2-3`DATE=`date +%y%m%d-%H:%M`read -p "Please input your name: " USERwhile truedo  read -p "Please input a "double-digit": " inputi=$((i+1))  case $input in    [0-9][0-9] )    if [ $input -gt $NUM ] ;then      echo "Try smaller!"      elif [ $input -lt $NUM ];then        echo "Try bigger!"    else        echo "Good! You are right!"      break;    fi ;;  *)  read -p "Please input a "double-digit": " input ;;  esacdoneprintf "%-12s %s\n" "<$USER>" "your record is $i! Try better next time! $DATE" |tee -a ./record.recordprintf "\n\n"printf "%15s %6s %-8s\n" "-----" "HISTORY RECORD" "-----"cat ./record.record |sort -k5  -g|awk -F! ‘{print $1,"!",$3}‘|head -10printf "%15s %6s %-8s\n" "-----" "HISTORY RECORD" "-----"


This article is from the statby blog, please be sure to keep this source http://statby.blog.51cto.com/7588140/1554538

Game Development History (shell digital games)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.