代码有点长,需要4个外部文件(2个wav 2个exe),所以建议大家直接下载压缩包
这次这个版本,亮点在于滚动文字动画和颜色效果,个人感觉很赞的说~ 就是cls有点多,有点闪~
代码:- @echo off
- set user=%username%
- title Brain Memory Challenge
- setlocal enabledelayedexpansion
- mode con cols=70 lines=18
- set anim=1
- set sound=1
- call :resetani
- call :initintro
- call :aniintro
- call :shinenormal
- echo.
- echo Are you ready? Press any key to continue.
- pause>nul
- :menu
- call :resetani
- call :initmenu
- if "!anim!"=="1" (call :ani) else (call :static)
- :menu2
- call :static
- set /p choice=Choice:
- if "%choice%"=="1" goto playgame
- if "%choice%"=="2" goto settings
- if "%choice%"=="3" goto help
- if "%choice%"=="4" goto about
- if "%choice%"=="5" start "" "http://brainmemchallenge.blogspot.com/"&goto menu2
- call :shinewrong
- goto menu2
-
- :playgame
- call :initgame
- :playgame2
- set /a ques+=1
- set numdisp=
- for /l %%i in (1 1 8) do (set numdisp=!random:~-1!!numdisp!)
- call :resetani
- call :initready
- if "!anim!"=="1" (call :ani2) else (call :static2)
- call :shinenormal
- cls
- echo.
- echo. [ Question: %ques%^/10 Score: %score%^/10 ]
- echo.
- echo. Remember it now!
- echo.
- echo. Secret number: !numdisp!
- sleep 5000
- cls
- echo.
- echo. [ Question: %ques%^/10 Score: %score%^/10 ]
- echo.
- echo. OK, now you enter the secret number...
- echo.
- echo. Secret number: ????????
- echo.
- echo. [PRESS ENTER TO ENTER THE NUMBER]
- pause>nul
- echo.
- set numenter=
- set /p numenter=Number:
- if "!numenter!"=="!numdisp!" (
- set /a score+=1
- call :resetani
- call :initcorrect
- if "!sound!"=="1" start /b gplay correct.mp3>nul 2>nul
- if "!anim!"=="1" (call :ani2) else (call :static2)
- goto abc
- ) else (
- if "%numenter%"=="" set numenter=blank..
- call :resetani
- call :initwrong
- if "!sound!"=="1" start /b gplay wrong.mp3>nul 2>nul
- if "!anim!"=="1" (call :ani2) else (call :static2))
- :abc
- echo.
- echo Press any key to continue...
- pause>nul
- if "%ques%"=="10" (
- call :resetani
- call :initfinal
- if "!anim!"=="1" (call :ani2) else (call :static2)
- echo Press any key to back to main menu
- pause>nul
- goto menu
- )
- goto playgame2
-
- :settings
- call :resetani
- call :initsettings
- if "!anim!"=="1" (call :ani) else (call :static)
- :settings2
- call :initsettings
- call :static
- set /p choice=Choice:
- if "%choice%"=="1" if "!sound!"=="1" (set sound=0&goto settings2) else (set sound=1&goto settings2)
- if "%choice%"=="2" if "!anim!"=="1" (set anim=0&goto settings2) else (set anim=1&goto settings2)
- if "%choice%"=="3" goto username
- if "%choice%"=="4" goto menu
- call :shinewrong
- goto settings2
-
- :username
- call :resetani
- call :initusername
- set skip=
- if "!anim!"=="1" (call :ani3) else (call :static3)
- cls&set choice=
- call :static3
- set /p choice=You want to change your name to?:
- if "%choice%"=="" goto settings
- set user=%choice%
- echo.
- echo. Name Changed...
- call :shinenormal
- goto menu
-
- :about
- call :resetani
- call :initabout
- set skip=
- if "!anim!"=="1" (call :ani3) else (call :static3)
- call :static3
- echo Press any key to back to main menu...
- pause>nul
- goto menu
-
- :help
- call :resetani
- call :inithelp
- set skip=
- if "!anim!"=="1" (call :ani3) else (call :static3)
- call :static3
- echo Press any key to back to main menu...
- pause>nul
- goto menu
-
- :shinewrong
- for /l %%i in (1 1 3) do (
- color 04
- sleep 100
- color 0c
- sleep 100)
- color 0f
- exit /b
-
- :shinenormal
- for /l %%i in (1 1 3) do (
- color 03
- sleep 100
- color 0b
- sleep 100)
- color 0f
- exit /b
-
- :shinecorrect
- for /l %%i in (1 1 3) do (
- color 02
- sleep 100
- color 0a
- sleep 100)
- color 0f
- exit /b
-
- :resetani
- set /a echo=0,echo2=0,echo3=0,echo4=0
- set choice=
- exit /b
-
-
- :initintro
- set introl1= :: ::
- set introl2= :: .:::: .:::: :::::.
- set introl3= :::::. :: :: :: :: :: ::
- set introl4= :: :: :: :: .:: :: :: ::
- set introl5= ::::: :: :: :: :: :: :: memory
- set introl6= :: :: ::
- set introl7= :: :: :: .::::. .::::: .::::.
- set introl8= .::::: ::::. .:::: :: :: :: :: :::::. :: :: :: ::
- set introl9= :: :: :: :: :: :: :: :::::: :: :: ::::: ::::::
- set introla= :: :: :: :: .:: :: :: :: :: :: .: ::
- set introlb= :::::: :: :: :: :: :: :: ::::: :: :: ::::: :::::
- set dot=............................................................
- set /a echo=0,echo2=0,echo3=60
- exit /b
-
- :initmenu
- set menuprompt=Welcome %user%
- set menul1=1. Play now
- set menul2=2. Settings
- set menul3=3. How To Play
- set menul4=4. About
- set menul5=5. Offical Blog
- set skip=
- set echo=18
- set echo2=0
- set choice=
- exit /b
-
- :initsettings
- set menuprompt=Settings
- if "!sound!"=="1" (set menul1=1. Turn off sound) else (set menul1=1. Turn on sound)
- if "!anim!"=="1" (set menul2=2. Turn off animation) else (set menul2=2. Turn on animation)
- set menul3=3. Change name
- set menul4=4. Back
- set menul5=
- set skip=
- set echo=10
- set echo2=0
- set choice=
- exit /b
-
- :initgame
- set /a score=0,ques=0
- exit /b
-
- :initready
- cls
- set readyl1= .::::: .::::. ::
- set readyl2= :: :: :: ::
- set readyl3= :: :: :: :: ''
- set readyl4= ::::: '::::' ::
- set readyl5= :::::. :::::: .:. :::. :: :: .::::
- set readyl6= :: :: :: :: :: :: :: :: :: '' ::
- set readyl7= ::::: :::::: ::::::: :: :: :: ::
- set readyl8= :: :: :: :: :: :: :: :: ''
- set readyl9= :: :: :::::: :: :: :::' :: ::
- set echo3=50
- set echo4=20
- set tmp=1
- exit /b
-
- :aniintro
- if !echo!==40 if !echo2!==60 if !echo3!==0 exit /b
- if !echo!==40 (if not !echo2!==60 set /a echo2+=5) else (set /a echo+=2)
- if !echo2! geq 30 set /a echo3-=5
- cls
- echo.
- echo. !introl1:~0,%echo%!
- echo. !introl2:~0,%echo%!
- echo. !introl3:~0,%echo%!
- echo. !introl4:~0,%echo%!
- echo. !introl5:~0,%echo%!
- if !echo!==40 (
- echo. !dot:~0,%echo2%!
- if !echo2! geq 30 (
- echo.
- echo. !introl6:~%echo3%!
- echo. !introl7:~%echo3%!
- echo. !introl8:~%echo3%!
- echo. !introl9:~%echo3%!
- echo. !introla:~%echo3%!
- echo. !introlb:~%echo3%!
- )
- )
- sleep 50
- goto aniintro
-
- :ani
- cls
- if not "%skip%"=="1" (
- if not "!echo!"=="0" set /a echo-=2
- if not "!echo2!"=="22" set /a echo2+=2
- if "!echo!"=="0" if "!echo2!"=="22" set skip=1
- echo.
- echo.
- echo. !menuprompt:~%echo%!
- echo.
- echo. !menul1:~0,%echo2%!
- echo. !menul2:~0,%echo2%!
- echo. !menul3:~0,%echo2%!
- echo. !menul4:~0,%echo2%!
- echo. !menul5:~0,%echo2%!
- sleep 50
- goto ani)
- exit /b
-
- :ani2
- cls
- if not "!echo3!"=="0" set /a echo3-=2
- echo.
- echo. [ Question: %ques%^/10 Score: %score%^/10 ]
- echo.
- echo. !readyl5:~%echo3%!
- echo. !readyl6:~%echo3%!
- echo. !readyl7:~%echo3%!
- echo. !readyl8:~%echo3%!
- echo. !readyl9:~%echo3%!
- if "!echo3!"=="0" (
- if "!tmp!"=="1" sleep 1000&set tmp=
- if "!tmp2!"=="1" call :shinewrong&set tmp2=
- if "!tmp3!"=="1" call :shinecorrect&set tmp3=
- set /a echo4-=2)
- if "!echo3!"=="0" (
- echo.
- echo.
- echo.
- echo. !readyl1:~%echo4%!
- echo. !readyl2:~%echo4%!
- echo. !readyl3:~%echo4%!
- echo. !readyl4:~%echo4%!
- )
- sleep 50
- if "!echo3!"=="0" if "!echo4!"=="0" exit /b
- goto ani2
-
- :ani3
- cls
- if not "%skip%"=="1" (
- if not "!echo!"=="0" set /a echo-=2
- if not "!echo2!"=="55" set /a echo2+=5
- if "!echo!"=="0" if "!echo2!"=="55" set skip=1
- echo.
- echo. !title:~%echo%!
- echo.
- echo. !pmt1:~0,%echo2%!&echo.
- echo. !pmt2:~0,%echo2%!&echo.
- echo. !pmt3:~0,%echo2%!&echo.
- echo. !pmt4:~0,%echo2%!&echo.
- echo. !pmt5:~0,%echo2%!&echo.
- sleep 50
- goto ani3)
- exit /b
-
- :inithelp
- set title=How to play
- set pmt1=Welcome to Brain Memory Challenge.bat
- set pmt2=The game will show you a group of number, then all you
- set pmt3=need to do is remember the number and type it after the
- set pmt4=number disappears.
- set pmt5=Note: You only have 5 seconds to remember it.
- set /a echo=8
- exit /b
-
- :initabout
- set title=About
- set pmt1=I'm the author of this program, Raymai.
- set pmt2=Thanks to Karl M. Syring for the gplay.exe.
- set pmt3=Thanks to Herbert Kleebauer for the sleep.com.
- set pmt4=Thanks to Valve for the sound.
- set pmt5=If you wanna use my code, add my name to your program's "about".
- set /a echo=8
- exit /b
-
- :initusername
- set title=Change your name
- set pmt1=Here's the way you can change your name.
- set pmt2=Current Name: %user%
- set pmt3=Current Windows Username: %username%
- set pmt4= * To go back, just leave blank and enter
- set pmt5=Note: The change only valid for this session.
- set /a echo=16
- exit /b
-
- :initwrong
- set readyl1=
- set readyl2=YOU TYPED: !numenter!
- set readyl3=
- set readyl4=THE CORRECT NUMBER IS: !numdisp!
- set readyl5= :: :: :: ::::: .:::. :: :: .:::: ::
- set readyl6= :: :: :: :: :: :: :: ::: :: :: ::
- set readyl7= :: :: :: ::::: :: :: :: ::: :: :: ::
- set readyl8= :: :: :: :: :: :: :: :: :: :: :: ''
- set readyl9= :: :: :: :: ::: :: :: ::::: ::
- set echo3=32
- set echo4=22
- set tmp2=1
- exit /b
-
- :initcorrect
- set readyl1=
- set readyl2=WOW, THE NUMBER YOU TYPED IS TRUE
- set readyl3=
- set readyl4=YOU'RE COOL, KEEP IT UP
- set readyl5= :::: :: :: :: :::::: .::::: .:::. .::::::. :::::: ::
- set readyl6=:: :: :: :: :: :: :: :: :: :: :: :: :: ::
- set readyl7=:::::: :: :: :: :::::: '::::. :: :: :: :: :: :::::: ::
- set readyl8=:: :: :: :: :: :: :: :: :: :: :: :: :: ''
- set readyl9=:: :: :: :: :::::: :::::' ::: :: :: :: :::::: ::
- set echo3=42
- set echo4=22
- set tmp3=1
- exit /b
-
- :initfinal
- if !score! leq 2 set grade=Bad
- if !score! geq 3 if !score! leq 5 set grade=Acceptable
- if !score! geq 6 if !score! leq 8 set grade=Good
- if !score! equ 9 set grade=Great
- if !score! equ 10 set grade=Excellent
- set readyl1= YOUR NAME: !user!
- set readyl2= SCORE: !score!
- set readyl3= GRADE: !grade!
- set readyl4=
- set readyl5= ::::. :::::: .::::: :: :: :: ::::::
- set readyl6= :: :: :: :: :: :: :: ::
- set readyl7= :::: :::::: '::::. :: :: :: ::
- set readyl8= :: :: :: :: :: :: :: ::
- set readyl9= :: :: :::::: :::::' :::: :::::: ::
- set echo3=36
- set echo4=22
- exit /b
-
- :static
- cls
- echo.
- echo.
- echo. !menuprompt!
- echo.
- echo. !menul1!
- echo. !menul2!
- echo. !menul3!
- echo. !menul4!
- echo. !menul5!
- echo.
- echo.
- exit /b
-
- :static2
- cls
- echo.
- echo. [ Question: %ques%^/10 Score: %score%^/10 ]
- echo.
- echo. !readyl5!
- echo. !readyl6!
- echo. !readyl7!
- echo. !readyl8!
- echo. !readyl9!
- if "!tmp!"=="1" sleep 1000&set tmp=
- if "!tmp2!"=="1" call :shinewrong&set tmp2=
- if "!tmp3!"=="1" call :shinecorrect&set tmp3=
- echo.
- echo.
- echo.
- echo. !readyl1!
- echo. !readyl2!
- echo. !readyl3!
- echo. !readyl4!
- exit /b
-
- :static3
- cls
- echo.
- echo. !title!
- echo.
- echo. !pmt1!&echo.
- echo. !pmt2!&echo.
- echo. !pmt3!&echo.
- echo. !pmt4!&echo.
- echo. !pmt5!&echo.
- exit /b
复制代码 呵呵~ 代码有点乱的说~ 希望大家多多支持啦~
链接: https://pan.baidu.com/s/1R9kl9mcMXip6vK64bYnsfA?pwd=sgvw |