Sunday 9 February 2014

Code for Game in CMD - Copy and Paste into Notepad and save as Game.bat

@echo off

title My Game
Color 0A
if "%1" neq "" (goto %1)

:Menu
cls
echo 1. Start
echo 2. Instructions
echo 3. Exit
set /p answer=Select number and press Enter.
if %answer%==1 goto Start_1
if %answer%==2 goto Instructions
if %answer%==3 goto Exit

:Exit
echo Thanks for Playing!
exit /b

:Instructions
cls
echo Instructions
echo.
echo [Enter Text Here]
pause
goto Menu

:Start_1
cls
echo 3 demons appear
echo You have a high chance of winning.
set /p answer=Would you like to fight or run?
if %answer%==fight goto Fight_1
if %answer%==run goto Run_1

:Run_1
cls
echo You ran away safely!
pause
goto Start_1
:Fight_1

echo You have chosen to fight!
echo The battle has begun!
goto Fight_Loop_1
:Fight_Loop_1

set /a num=%random%
if %num% gtr 4 goto Fight_Loop_1
if %num% lss 1 goto Fight_Loop_1
if %num%==1 goto Lose_Fight_1
if %num%==2 goto Win_Fight_1
if %num%==3 goto Win_Fight_1
if %num%==4 goto Win_Fight_1
:Lose_Fight_1

cls
echo You have been defeated!
pause
set /p answer=Would you like to try again?
if %answer%==yes goto Start_1
if %answer%==no goto Menu
:Win_Fight_1

cls
echo Well done! You have defeated the enemy!
set /p answer=Would you like to save?
if %answer%==yes goto Save_1
if %answer%==no goto Start_2

:Save_1
echo Game Saved!
pause
goto Start_2
:Start_2

cls
echo A dragon appears
echo You have a fair chance of winning
set /p answer=Would you like to fight or run?
if %answer%==fight goto Fight_2
if %answer%==run goto Run_2

:Run_2
cls
echo You ran away safely!
pause
goto Start_2

:Fight_2
echo You have chosen to fight!
echo The battle has begun!
goto Fight_Loop_2

:Fight_Loop_2
set /a num=%random%
if %num% gtr 4 goto Fight_Loop_2
if %num% lss 1 goto Fight_Loop_2
if %num%==1 goto Lose_Fight_2
if %num%==2 goto Lose_Fight_2
if %num%==3 goto Win_Fight_2
if %num%==4 goto Win_Fight_2

:Lose_Fight_2
cls
echo You have been defeated!
pause
set /p answer=Would you like to try again?
if %answer%==yes goto Start_2
if %answer%==no goto Menu

:Win_Fight_2
cls
echo Well done! You have defeated the enemy!
set /p answer=Would you like to save?
if %answer%==yes goto Save_2
if %answer%==no goto Start_2

:Save_2
echo Game Saved!
pause
goto Start_1