Saved Bookmarks
| 1. |
Solve : BATCH GAME HELP!!? |
|
Answer» Is there any way to make a PLAYER earn points in a batch file game??The qustion makes no sense as stated...Quote from: lewy on August 11, 2011, 01:10:46 AM Is there any way to make a player earn points in a batch file game?? You can have a player ACCUMULATE points and on exit write the number to a file and read the score in the next time the game is run. Please note, in English we only use ONE question mark at a time. Code: [Select]@echo off echo *************** echo * * echo * Simple Game * echo * * echo *************** echo. set /p player="Your name? " set score=0 if exist %player%.score ( for /f %%A in (%player%.score) do set score=%%A echo Welcome back %player% ) else ( echo Hello new player %player% set score = 0 ) echo Your score is %score% set /p answer="5 + 5 = " if %answer% equ 10 ( echo correct set /a score+=1 ) else ( echo incorrect ) echo Your score is %score% set /p answer="8 - 3 = " if %answer% equ 5 ( echo correct set /a score+=1 ) else ( echo incorrect ) echo Your score is %score% set /p answer="25 x 4 = " if %answer% equ 100 ( echo correct set /a score+=1 ) else ( echo incorrect ) echo Your score is %score% echo Saving your score... echo %score% > %player%.score echo Goodbye Thoughts - You would NEED to think about if you want the player to retain points after they have stopped the script or if you want the points to be maintained within memory for only the time frame of running the script. Points can be used using the math dos variable set \a points=1+%points% and if you want it saved to a file you would redirect the points to a file name.Quote from: Darth on October 05, 2011, 06:55:15 PM Points can be used using the math dos variable set \a points=1+%points% This is exactly what I already wrote, except you GOT the slash around the wrong way. |
|