[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[游戏娱乐] Brain Memory Challenge,挑战你脑袋的记忆力

本帖最后由 raymai97 于 2011-9-2 22:33 编辑

代码有点长,需要4个外部文件(2个wav 2个exe),所以建议大家直接下载压缩包

这次这个版本,亮点在于滚动文字动画和颜色效果,个人感觉很赞的说~ 就是cls有点多,有点闪~

代码:
  1. @echo off
  2. set user=%username%
  3. title Brain Memory Challenge
  4. setlocal enabledelayedexpansion
  5. mode con cols=70 lines=18
  6. set anim=1
  7. set sound=1
  8. call :resetani
  9. call :initintro
  10. call :aniintro
  11. call :shinenormal
  12. echo.
  13. echo      Are you ready? Press any key to continue.
  14. pause>nul
  15. :menu
  16. call :resetani
  17. call :initmenu
  18. if "!anim!"=="1" (call :ani) else (call :static)
  19. :menu2
  20. call :static
  21. set /p choice=Choice:
  22. if "%choice%"=="1" goto playgame
  23. if "%choice%"=="2" goto settings
  24. if "%choice%"=="3" goto help
  25. if "%choice%"=="4" goto about
  26. if "%choice%"=="5" start "" "http://brainmemchallenge.blogspot.com/"&goto menu2
  27. call :shinewrong
  28. goto menu2
  29. :playgame
  30. call :initgame
  31. :playgame2
  32. set /a ques+=1
  33. set numdisp=
  34. for /l %%i in (1 1 8) do (set numdisp=!random:~-1!!numdisp!)
  35. call :resetani
  36. call :initready
  37. if "!anim!"=="1" (call :ani2) else (call :static2)
  38. call :shinenormal
  39. cls
  40. echo.
  41. echo.           [    Question: %ques%^/10        Score: %score%^/10    ]
  42. echo.
  43. echo.               Remember it now!
  44. echo.
  45. echo.               Secret number: !numdisp!
  46. sleep 5000
  47. cls
  48. echo.
  49. echo.           [    Question: %ques%^/10        Score: %score%^/10    ]
  50. echo.
  51. echo.               OK, now you enter the secret number...
  52. echo.
  53. echo.               Secret number: ????????
  54. echo.
  55. echo.                  [PRESS ENTER TO ENTER THE NUMBER]
  56. pause>nul
  57. echo.
  58. set numenter=
  59. set /p numenter=Number:
  60. if "!numenter!"=="!numdisp!" (
  61. set /a score+=1
  62. call :resetani
  63. call :initcorrect
  64. if "!sound!"=="1" start /b gplay correct.mp3>nul 2>nul
  65. if "!anim!"=="1" (call :ani2) else (call :static2)
  66. goto abc
  67. ) else (
  68. if "%numenter%"=="" set numenter=blank..
  69. call :resetani
  70. call :initwrong
  71. if "!sound!"=="1" start /b gplay wrong.mp3>nul 2>nul
  72. if "!anim!"=="1" (call :ani2) else (call :static2))
  73. :abc
  74. echo.
  75. echo Press any key to continue...
  76. pause>nul
  77. if "%ques%"=="10" (
  78. call :resetani
  79. call :initfinal
  80. if "!anim!"=="1" (call :ani2) else (call :static2)
  81. echo Press any key to back to main menu
  82. pause>nul
  83. goto menu
  84. )
  85. goto playgame2
  86. :settings
  87. call :resetani
  88. call :initsettings
  89. if "!anim!"=="1" (call :ani) else (call :static)
  90. :settings2
  91. call :initsettings
  92. call :static
  93. set /p choice=Choice:
  94. if "%choice%"=="1" if "!sound!"=="1" (set sound=0&goto settings2) else (set sound=1&goto settings2)
  95. if "%choice%"=="2" if "!anim!"=="1" (set anim=0&goto settings2) else (set anim=1&goto settings2)
  96. if "%choice%"=="3" goto username
  97. if "%choice%"=="4" goto menu
  98. call :shinewrong
  99. goto settings2
  100. :username
  101. call :resetani
  102. call :initusername
  103. set skip=
  104. if "!anim!"=="1" (call :ani3) else (call :static3)
  105. cls&set choice=
  106. call :static3
  107. set /p choice=You want to change your name to?:
  108. if "%choice%"=="" goto settings
  109. set user=%choice%
  110. echo.
  111. echo.      Name Changed...
  112. call :shinenormal
  113. goto menu
  114. :about
  115. call :resetani
  116. call :initabout
  117. set skip=
  118. if "!anim!"=="1" (call :ani3) else (call :static3)
  119. call :static3
  120. echo Press any key to back to main menu...
  121. pause>nul
  122. goto menu
  123. :help
  124. call :resetani
  125. call :inithelp
  126. set skip=
  127. if "!anim!"=="1" (call :ani3) else (call :static3)
  128. call :static3
  129. echo Press any key to back to main menu...
  130. pause>nul
  131. goto menu
  132. :shinewrong
  133. for /l %%i in (1 1 3) do (
  134. color 04
  135. sleep 100
  136. color 0c
  137. sleep 100)
  138. color 0f
  139. exit /b
  140. :shinenormal
  141. for /l %%i in (1 1 3) do (
  142. color 03
  143. sleep 100
  144. color 0b
  145. sleep 100)
  146. color 0f
  147. exit /b
  148. :shinecorrect
  149. for /l %%i in (1 1 3) do (
  150. color 02
  151. sleep 100
  152. color 0a
  153. sleep 100)
  154. color 0f
  155. exit /b
  156. :resetani
  157. set /a echo=0,echo2=0,echo3=0,echo4=0
  158. set choice=
  159. exit /b
  160. :initintro
  161. set introl1=    ::                  ::
  162. set introl2=    ::     .::::  .::::    :::::.
  163. set introl3=    :::::. ::    ::  :: :: ::  ::
  164. set introl4=    ::  :: ::    :: .:: :: ::  ::
  165. set introl5=    :::::  ::     :: :: :: ::  :: memory
  166. set introl6=         ::           :: ::
  167. set introl7=         ::           :: :: .::::.        .::::: .::::.
  168. set introl8=  .::::: ::::.  .:::: :: :: ::  :: :::::. ::  :: ::  ::
  169. set introl9=  ::     :: :: ::  :: :: :: :::::: ::  ::  ::::: ::::::
  170. set introla=  ::     :: :: :: .:: :: :: ::     ::  ::     .: ::   
  171. set introlb=  :::::: :: ::  :: :: :: ::  ::::: ::  :: :::::   :::::
  172. set dot=............................................................
  173. set /a echo=0,echo2=0,echo3=60
  174. exit /b
  175. :initmenu
  176. set menuprompt=Welcome %user%
  177. set menul1=1. Play now
  178. set menul2=2. Settings
  179. set menul3=3. How To Play
  180. set menul4=4. About
  181. set menul5=5. Offical Blog
  182. set skip=
  183. set echo=18
  184. set echo2=0
  185. set choice=
  186. exit /b
  187. :initsettings
  188. set menuprompt=Settings
  189. if "!sound!"=="1" (set menul1=1. Turn off sound) else (set menul1=1. Turn on sound)
  190. if "!anim!"=="1" (set menul2=2. Turn off animation) else (set menul2=2. Turn on animation)
  191. set menul3=3. Change name
  192. set menul4=4. Back
  193. set menul5=
  194. set skip=
  195. set echo=10
  196. set echo2=0
  197. set choice=
  198. exit /b
  199. :initgame
  200. set /a score=0,ques=0
  201. exit /b
  202. :initready
  203. cls
  204. set readyl1=        .::::: .::::.  ::
  205. set readyl2=        ::     ::  ::  ::
  206. set readyl3=        ::  :: ::  ::  ''
  207. set readyl4=         ::::: '::::'  ::
  208. set readyl5=  :::::.  ::::::   .:.   :::.  ::   ::  .::::
  209. set readyl6=  ::  ::  ::      :: ::  :: ::  :: ::  ''  ::
  210. set readyl7=  :::::   :::::: ::::::: :: ::    ::      ::
  211. set readyl8=  ::  ::  ::     ::   :: :: ::    ::     ''
  212. set readyl9=  ::   :: :::::: ::   :: :::'     ::     ::
  213. set echo3=50
  214. set echo4=20
  215. set tmp=1
  216. exit /b
  217. :aniintro
  218. if !echo!==40 if !echo2!==60 if !echo3!==0 exit /b
  219. if !echo!==40 (if not !echo2!==60 set /a echo2+=5) else (set /a echo+=2)
  220. if !echo2! geq 30 set /a echo3-=5
  221. cls
  222. echo.
  223. echo.    !introl1:~0,%echo%!
  224. echo.    !introl2:~0,%echo%!
  225. echo.    !introl3:~0,%echo%!
  226. echo.    !introl4:~0,%echo%!
  227. echo.    !introl5:~0,%echo%!
  228. if !echo!==40 (
  229. echo.    !dot:~0,%echo2%!
  230. if !echo2! geq 30 (
  231. echo.
  232. echo.    !introl6:~%echo3%!
  233. echo.    !introl7:~%echo3%!
  234. echo.    !introl8:~%echo3%!
  235. echo.    !introl9:~%echo3%!
  236. echo.    !introla:~%echo3%!
  237. echo.    !introlb:~%echo3%!
  238. )
  239. )
  240. sleep 50
  241. goto aniintro
  242. :ani
  243. cls
  244. if not "%skip%"=="1" (
  245. if not "!echo!"=="0" set /a echo-=2
  246. if not "!echo2!"=="22" set /a echo2+=2
  247. if "!echo!"=="0" if "!echo2!"=="22" set skip=1
  248. echo.
  249. echo.
  250. echo.    !menuprompt:~%echo%!
  251. echo.
  252. echo.         !menul1:~0,%echo2%!
  253. echo.                                 !menul2:~0,%echo2%!
  254. echo.         !menul3:~0,%echo2%!
  255. echo.                                 !menul4:~0,%echo2%!
  256. echo.         !menul5:~0,%echo2%!
  257. sleep 50
  258. goto ani)
  259. exit /b
  260. :ani2
  261. cls
  262. if not "!echo3!"=="0" set /a echo3-=2
  263. echo.
  264. echo.           [    Question: %ques%^/10        Score: %score%^/10    ]
  265. echo.
  266. echo.         !readyl5:~%echo3%!
  267. echo.         !readyl6:~%echo3%!
  268. echo.         !readyl7:~%echo3%!
  269. echo.         !readyl8:~%echo3%!
  270. echo.         !readyl9:~%echo3%!
  271. if "!echo3!"=="0" (
  272. if "!tmp!"=="1" sleep 1000&set tmp=
  273. if "!tmp2!"=="1" call :shinewrong&set tmp2=
  274. if "!tmp3!"=="1" call :shinecorrect&set tmp3=
  275. set /a echo4-=2)
  276. if "!echo3!"=="0" (
  277. echo.
  278. echo.
  279. echo.
  280. echo.              !readyl1:~%echo4%!
  281. echo.              !readyl2:~%echo4%!
  282. echo.              !readyl3:~%echo4%!
  283. echo.              !readyl4:~%echo4%!
  284. )
  285. sleep 50
  286. if "!echo3!"=="0" if "!echo4!"=="0" exit /b
  287. goto ani2
  288. :ani3
  289. cls
  290. if not "%skip%"=="1" (
  291. if not "!echo!"=="0" set /a echo-=2
  292. if not "!echo2!"=="55" set /a echo2+=5
  293. if "!echo!"=="0" if "!echo2!"=="55" set skip=1
  294. echo.
  295. echo.    !title:~%echo%!
  296. echo.
  297. echo.    !pmt1:~0,%echo2%!&echo.
  298. echo.    !pmt2:~0,%echo2%!&echo.
  299. echo.    !pmt3:~0,%echo2%!&echo.
  300. echo.    !pmt4:~0,%echo2%!&echo.
  301. echo.    !pmt5:~0,%echo2%!&echo.
  302. sleep 50
  303. goto ani3)
  304. exit /b
  305. :inithelp
  306. set title=How to play
  307. set pmt1=Welcome to Brain Memory Challenge.bat
  308. set pmt2=The game will show you a group of number, then all you
  309. set pmt3=need to do is remember the number and type it after the
  310. set pmt4=number disappears.
  311. set pmt5=Note: You only have 5 seconds to remember it.
  312. set /a echo=8
  313. exit /b
  314. :initabout
  315. set title=About
  316. set pmt1=I'm the author of this program, Raymai.
  317. set pmt2=Thanks to Karl M. Syring for the gplay.exe.
  318. set pmt3=Thanks to Herbert Kleebauer for the sleep.com.
  319. set pmt4=Thanks to Valve for the sound.
  320. set pmt5=If you wanna use my code, add my name to your program's "about".
  321. set /a echo=8
  322. exit /b
  323. :initusername
  324. set title=Change your name
  325. set pmt1=Here's the way you can change your name.
  326. set pmt2=Current Name: %user%
  327. set pmt3=Current Windows Username: %username%
  328. set pmt4=  * To go back, just leave blank and enter
  329. set pmt5=Note: The change only valid for this session.
  330. set /a echo=16
  331. exit /b
  332. :initwrong
  333. set readyl1=
  334. set readyl2=YOU TYPED: !numenter!
  335. set readyl3=
  336. set readyl4=THE CORRECT NUMBER IS: !numdisp!
  337. set readyl5=    :: :: :: :::::  .:::. ::  :: .:::: ::
  338. set readyl6=    :: :: :: ::  :: :: :: ::: :: ::    ::
  339. set readyl7=    :: :: :: :::::  :: :: :: ::: :: :: ::
  340. set readyl8=    :: :: :: :: ::  :: :: ::  :: :: :: ''
  341. set readyl9=     ::  ::  ::  ::  :::  ::  :: ::::: ::
  342. set echo3=32
  343. set echo4=22
  344. set tmp2=1
  345. exit /b
  346. :initcorrect
  347. set readyl1=
  348. set readyl2=WOW, THE NUMBER YOU TYPED IS TRUE
  349. set readyl3=
  350. set readyl4=YOU'RE COOL, KEEP IT UP
  351. set readyl5= ::::  :: :: :: :::::: .::::: .:::. .::::::. :::::: ::
  352. set readyl6=::  :: :: :: :: ::     ::     :: :: :: :: :: ::     ::
  353. set readyl7=:::::: :: :: :: :::::: '::::. :: :: :: :: :: :::::: ::
  354. set readyl8=::  :: :: :: :: ::         :: :: :: :: :: :: ::     ''
  355. set readyl9=::  ::  ::  ::  :::::: :::::'  :::  :: :: :: :::::: ::
  356. set echo3=42
  357. set echo4=22
  358. set tmp3=1
  359. exit /b
  360. :initfinal
  361. if !score! leq 2 set grade=Bad
  362. if !score! geq 3 if !score! leq 5 set grade=Acceptable
  363. if !score! geq 6 if !score! leq 8 set grade=Good
  364. if !score! equ 9 set grade=Great
  365. if !score! equ 10 set grade=Excellent
  366. set readyl1= YOUR NAME: !user!
  367. set readyl2= SCORE: !score!
  368. set readyl3= GRADE: !grade!
  369. set readyl4=
  370. set readyl5=   ::::.  :::::: .::::: ::  :: ::    ::::::
  371. set readyl6=   :: ::  ::     ::     ::  :: ::      ::
  372. set readyl7=   ::::   :::::: '::::. ::  :: ::      ::
  373. set readyl8=   :: ::  ::         :: ::  :: ::      ::
  374. set readyl9=   ::  :: :::::: :::::'  ::::  ::::::  ::
  375. set echo3=36
  376. set echo4=22
  377. exit /b
  378. :static
  379. cls
  380. echo.
  381. echo.
  382. echo.    !menuprompt!
  383. echo.
  384. echo.         !menul1!
  385. echo.                                 !menul2!
  386. echo.         !menul3!
  387. echo.                                 !menul4!
  388. echo.         !menul5!
  389. echo.
  390. echo.
  391. exit /b
  392. :static2
  393. cls
  394. echo.
  395. echo.           [    Question: %ques%^/10        Score: %score%^/10    ]
  396. echo.
  397. echo.         !readyl5!
  398. echo.         !readyl6!
  399. echo.         !readyl7!
  400. echo.         !readyl8!
  401. echo.         !readyl9!
  402. if "!tmp!"=="1" sleep 1000&set tmp=
  403. if "!tmp2!"=="1" call :shinewrong&set tmp2=
  404. if "!tmp3!"=="1" call :shinecorrect&set tmp3=
  405. echo.
  406. echo.
  407. echo.
  408. echo.              !readyl1!
  409. echo.              !readyl2!
  410. echo.              !readyl3!
  411. echo.              !readyl4!
  412. exit /b
  413. :static3
  414. cls
  415. echo.
  416. echo.    !title!
  417. echo.
  418. echo.    !pmt1!&echo.
  419. echo.    !pmt2!&echo.
  420. echo.    !pmt3!&echo.
  421. echo.    !pmt4!&echo.
  422. echo.    !pmt5!&echo.
  423. exit /b
复制代码
呵呵~ 代码有点乱的说~ 希望大家多多支持啦~

附件: 您需要登录才可以下载或查看附件。没有帐号?注册
为何批处理不适合做界面
为何随风讨厌call命令
http://bbs.bathome.net/thread-4482-1-10.html

本帖最后由 weichenxiehou 于 2011-9-3 08:39 编辑

兄台写的代码还真是长啊,不简单啊……闪烁的效果在下觉得可以考虑运用批处理多行回退来改进。有兴趣的话可以研究下本人在http://www.bathome.net/thread-11607-1-1.html中在显示方面所做的努力,呵呵
看得多说得多,远比不上写得多。

TOP

回复 2# weichenxiehou


感谢你的回复,去谷歌了一下“批处理多行回退”,虽然可以解决闪动的问题,但是我的动画貌似不适合,因为我的不是单行,而是多行啊~
无论如何,谢谢你的回复。

对了,觉得我这个批处理的动画做得ok么?好看么?
为何批处理不适合做界面
为何随风讨厌call命令
http://bbs.bathome.net/thread-4482-1-10.html

TOP

老实说,我有点心灰意冷…… 怎么 没有其他人回帖了…… 也许你们会觉得这个游戏很白痴…… 作弊易如反掌…… 但毕竟在界面那方面我用了不少心血啦…… 怎么就不能支持一下呢……
为何批处理不适合做界面
为何随风讨厌call命令
http://bbs.bathome.net/thread-4482-1-10.html

TOP

如果你继续做这些东西,心只能越来越冷,不如多花点时间帮他人答疑解惑吧。
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

版主说的对,批处理应该用来做更实际的东西

TOP

回复 3# raymai97
总的来说,还是很不错啦,写这些东西练练手,提升下技术可以,但也别陷进去了,毕竟我觉得批处理的初衷不是这个哦,加油!
看得多说得多,远比不上写得多。

TOP

看看左上角,“批处理之家”下面的那一条蓝背白底的字。

TOP

回复 4# raymai97


    小意思咯,我写过的、发过的比你的多了去了,捧场的稀稀拉拉,我也没觉得有什么。技术是自己的,学到了自己高兴。作品嘛,自我感觉好就好。
    正如楼上所言,仅当练手好了,毕竟看起来你的思路和技术还有待提高。
寂寞是黑白的,但黑白不是寂寞,是永恒。BAT 需要的不是可能,而是智慧。

TOP

本帖最后由 garyng 于 2011-9-13 17:39 编辑

每个帖子都有往下沉的时候......

想赞的是:楼主的英文太好了!!!!!
哪里人啊?

小小的建议而已~
WOW, THE NUMBER YOU TYPED IS TRUE
WOW, THE NUMBER YOU TYPED IS CORRECT

The game will show you a group of number, then all you...
The game will show you a group of number, then what you...

Thanks to Karl M. Syring for the gplay.exe.
Thanks to Karl M. Syring, the author of gplay.exe.

Thanks to Herbert Kleebauer for the sleep.com.
Thanks to Herbert Kleebauer, the author of sleep.com.

TOP

楼主很用心,很强大!

TOP

返回列表