Today we are going to show you an easy way to create your own video game with CMD. In this article, we will be giving you an introduction to video game programming. All you need to have is just a Notepad.
Steps To Create Your Own Video Game With Cmd
Step 1: Select A Title For Your Game:
Firstly, select a unique name for your game, Then Replace ” OnlineCmag Game ” With the name you wanted in the below given code .
@echo off title OnlineCmag Game
Step 2: Select The color For Your Game:
You can set the background and foreground colors by using the CMD color codes . If you don’t know the color codes click here. Replace ” 0A ” with the required color .
@echo off title OnlineCmag Game color 0A if "%1" neq "" ( goto %1)
Step 3: Creating a menu:
Type the below given code to create a menu for your game . You can also extend your menu list by repeating the code .
:Menu cls echo 1. Start echo 2. Instructions echo 3. Exit set /p answer=Type the number of your option and press enter : if %answer%==1 goto Start_1 if %answer%==2 goto Instructions if %answer%==3 goto Exit
Step 4: Creating An Exit Option:
Type the below given code to exit the game.
:Exit cls echo We Hope You Enjoyed The Game . Thanks for playing ! pause exit /b
Step 5 : Creating An Instructions Option:
Type the below given code.
:Instructions cls echo Instructions echo. echo 'Welcome To OnlineCmag Game' pause goto Menu
Step 6: Begin The Game:
:Start_1 cls echo Hurry up ! Some bad guys Surrounded You. echo They are totally 5 gang-stars echo You are having 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 pause
Step 7: Code For Fighting And Running:
:Run_1 cls echo You ran away safely ! pause goto Start_1 :Fight_1 echo Get ready for a hardcore fight. echo The battle is waging. set /p answer= Type number 1 and press enter to continue: if %answer%==1 goto Fight_1_Loop :Fight_1_Loop set /a num=%random% if %num% gtr 4 goto Fight_1_Loop if %num% lss 1 goto Fight_1_Loop 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 Sorry, you lost the fight :( pause goto Menu :Win_Fight_1 cls echo Congrats, you won the fight!!! set /p answer='Would you like to save?' Type yes to save or type no . if %answer%=='yes' goto 'Save' if %answer%=='no' goto 'Start_2' :Save goto Start_2
Step 8: Save It:
Save this file with a ” .bat ” extension i.e something like ” OnlineCmag.bat ” . Now execute the file by double clicking on it.
Share Your Doubts And Views In Comments ….