Reputation: 1
Can games be created to run on the Command Prompt?
Upvotes: 0
Views: 2006
Reputation: 21
You may be interested in "batch" files or ".bat". These can be created in Notepad. If you are strictly wanting to stay in Command Prompt though you could try "copy con C:\anywhere\anyname.bat" and what ever you type will be saved in that file after pressing CTRL+Z when done.
So in theory....
Create the file first. copy con C:\movegame.bat Enter the following code.
@setlocal enableextensions enabledelayedexpansion
@echo off
title movement
color 0a
set length=
set height= a
:controls
cls
echo Use WASD to move your character ([]).
echo.
for %%a in ( %height% ) do echo.
echo %length%[]
choice /c wasd /n
if %errorlevel% equ 1 call:up
if %errorlevel% equ 2 call:left
if %errorlevel% equ 3 call:down
if %errorlevel% equ 4 call:right
:left
set length=!length:~0,-1!
goto controls
:right
set length=%length%
goto controls
:up
set height=!height:~0,-2!
goto controls
:down
set height=%height% a
goto control
CTRL+Z (This will save the file)
Then you can run the batch file. WASD to move. C:\movegame.bat
So much more can be done, this is simply 29 lines. Check out the following article about the above batch file.
Batch Game Movement (Tutorial)
If you are looking for ideas or inspiration, try out Zork. It's all text based adventure. QBasic or Basic may interest you as well.
Upvotes: 2