Created
April 11, 2023 16:26
-
-
Save R3DHULK/ae0cd190ecce2672c5fcff09ee81dc7f to your computer and use it in GitHub Desktop.
Simon Says In batch programming
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @echo off | |
| title Simon Says Game | |
| setlocal enabledelayedexpansion | |
| echo Welcome to Simon Says! | |
| echo. | |
| echo Simon says, press any key to start... | |
| pause >nul | |
| set /a level=1 | |
| set "sequence=" | |
| set "user_sequence=" | |
| :game_loop | |
| cls | |
| echo Level %level% | |
| echo. | |
| :: Generate the sequence | |
| set "sequence=" | |
| for /l %%i in (1,1,%level%) do ( | |
| set /a "random_num=!random! %% 4 + 1" | |
| if !random_num! equ 1 ( | |
| set "sequence=!sequence!R" | |
| ) else if !random_num! equ 2 ( | |
| set "sequence=!sequence!G" | |
| ) else if !random_num! equ 3 ( | |
| set "sequence=!sequence!B" | |
| ) else ( | |
| set "sequence=!sequence!Y" | |
| ) | |
| ) | |
| :: Display the sequence | |
| echo Simon says: !sequence! | |
| timeout /t 2 >nul | |
| :: Get user input | |
| set "user_sequence=" | |
| echo Your turn: | |
| set /p "user_sequence=" | |
| :: Validate user input | |
| if "%user_sequence%"=="!sequence!" ( | |
| echo Correct! | |
| set /a level+=1 | |
| ) else ( | |
| echo Incorrect. Game Over! | |
| echo Your final level is %level% | |
| pause >nul | |
| exit | |
| ) | |
| goto game_loop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment