I made a text based game that runs in your cmd

koldWinter

Young Hero
Level 1
31%
Joined
Aug 8, 2025
Messages
48
Level up in
52 posts
Reaction score
148
Points
377
Location
Brazil
Good morning::pikachu-sleep

As you can see we have 3 files here, the prototype of the game [dark_night_v1], a one I created to test the inventory [inventory_test] and finally the "complete" version, which we'll be executing right now [dark_night_v2]:

1763637453324.png


To start things off we have the text describing the scene, a list of commands of what the character can do and an input for the player to type their actions based on the list.

1763637685763.png


> stay

1763637724704.png


When we reach an end in the game, the input name changes to "Restart" and if you type:
> restart
The terminal will be cleared and the game will reset.

> go

1763637914107.png


Now we have 3 more commands.
Whenever you use:
> inventory
It will display the items that you've currently collected:

Nothing ::peacemario

1763638163635.png


And also, when you use the inventory command the text and the available commands will be showed once again so the player doesn't lose track of what's happening in the scene if he uses too many > inventory s.

Now if you decide to > pick_up the shovel and then check your inventory again, you'll see that it is there now.

1763638381695.png


We're almost in the end here, because when you start > walk ing you'll be able to choose a direction to go:

1763638527338.png


And now, whatever direction you choose will lead to a restart:

1763638581336.png



I'm really enjoying studying programming by myself and this little project was definitely great for my learning process. I'd recommend beginners to give this little challenge a shot if there is some extra time.
Dunno if anybody will be interested on checking out the actual code, if so, i can send the .txt of the bat file.
Have a good day y'all
 
Congrats. it looks solid and clean. could you provide the code?
 
Congrats. it looks solid and clean. could you provide the code?

Sure, there you go
::slime-roll


Code:
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION

:START

SET commandCall=Command?
SET errorMessage=Invalid
SET :: shovel=0
SET :: key=0


ECHO =================================
ECHO.
ECHO You are a man in a red cloak. Even though it's cold, you want to go outside.
ECHO.
ECHO =========== COMMANDS ============
ECHO.
ECHO go / stay
ECHO.
ECHO =================================
ECHO.

SET /P command0=%commandCall%

IF /I %command0%==go (
    ECHO.
    GOTO A
)

IF /I %command0%==stay (
    ECHO.
    ECHO You decide to stay. The tea will be ready soon.
    GOTO END
) ELSE (
    ECHO.
    ECHO %errorMessage%
    GOTO START
)

:A

ECHO =================================
ECHO.
ECHO You leave your cosy hut. Now you are at your balcony admiring the shiny stars that can only be seen this far from the smoke. You see your shovel laying around. Pick it up?
ECHO.
ECHO =========== COMMANDS ============
ECHO.
ECHO pick_up / don't_pick_up / inventory
ECHO.
ECHO =================================
ECHO.

SET /P command1=%commandCall%

IF /I %command1%==pick_up (
    SET :: shovel=1
    ECHO.
    ECHO You picked up the shovel.
    ECHO.
    GOTO AA
)

IF /I %command1%==don't_pick_up (
    ECHO.
    ECHO You did not pick the shovel
    ECHO.
    GOTO AA
)

IF /I %command1%==inventory (
    ECHO.
    CALL :Inventory
    GOTO A

) ELSE (
    ECHO.
    ECHO %errorMessage%
    GOTO A
)

:AA

ECHO =========== COMMANDS ============
ECHO.
ECHO walk / inventory
ECHO.

SET /P command2=%commandCall%

IF /I %command2%==walk (
    GOTO AAA
)

IF /I %command2%==inventory (
    ECHO.
    CALL :Inventory
    GOTO AA
)

:AAA

ECHO =================================
ECHO.
ECHO You start walking. Where are you headed to?
ECHO.
ECHO =========== COMMANDS ============
ECHO.
ECHO north / east / west
ECHO.
ECHO =================================
ECHO.

SET /P command3=%commandCall%

IF /I %command3%==north (
    ECHO.
    ECHO You go north.
    ECHO.
    GOTO END
)

IF /I %command3%==east (
    ECHO.
    ECHO You go east
    ECHO.
    GOTO END
)

IF /I %command3%==west (
    ECHO.
    ECHO You go west
    ECHO.
    GOTO END
)

IF /I %command3%==inventory (
    ECHO.
    CALL :Inventory
    GOTO AAA
)


) ELSE (
    ECHO.
    ECHO %errorMessage%
    GOTO AAA
)

:Inventory
ECHO.

FOR /F "tokens=1* delims==" %%i IN ('SET :: ') DO (
   
    IF "%%j"=="1" (
        ECHO.
        ECHO =========== INVENTORY ============
        ECHO %%i
    )
)

ECHO.
EXIT /B

:END

ECHO.
ECHO.

SET /P commandEnd=Restart?

IF /I %commandEnd%==restart (
    CLS
    GOTO START
) ELSE (
    ECHO.
    ECHO %errorMessage%
    GOTO END
)

ECHO.

PAUSE
 
Sure, there you go
::slime-roll


Code:
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION

:START

SET commandCall=Command?
SET errorMessage=Invalid
SET :: shovel=0
SET :: key=0


ECHO =================================
ECHO.
ECHO You are a man in a red cloak. Even though it's cold, you want to go outside.
ECHO.
ECHO =========== COMMANDS ============
ECHO.
ECHO go / stay
ECHO.
ECHO =================================
ECHO.

SET /P command0=%commandCall%

IF /I %command0%==go (
    ECHO.
    GOTO A
)

IF /I %command0%==stay (
    ECHO.
    ECHO You decide to stay. The tea will be ready soon.
    GOTO END
) ELSE (
    ECHO.
    ECHO %errorMessage%
    GOTO START
)

:A

ECHO =================================
ECHO.
ECHO You leave your cosy hut. Now you are at your balcony admiring the shiny stars that can only be seen this far from the smoke. You see your shovel laying around. Pick it up?
ECHO.
ECHO =========== COMMANDS ============
ECHO.
ECHO pick_up / don't_pick_up / inventory
ECHO.
ECHO =================================
ECHO.

SET /P command1=%commandCall%

IF /I %command1%==pick_up (
    SET :: shovel=1
    ECHO.
    ECHO You picked up the shovel.
    ECHO.
    GOTO AA
)

IF /I %command1%==don't_pick_up (
    ECHO.
    ECHO You did not pick the shovel
    ECHO.
    GOTO AA
)

IF /I %command1%==inventory (
    ECHO.
    CALL :Inventory
    GOTO A

) ELSE (
    ECHO.
    ECHO %errorMessage%
    GOTO A
)

:AA

ECHO =========== COMMANDS ============
ECHO.
ECHO walk / inventory
ECHO.

SET /P command2=%commandCall%

IF /I %command2%==walk (
    GOTO AAA
)

IF /I %command2%==inventory (
    ECHO.
    CALL :Inventory
    GOTO AA
)

:AAA

ECHO =================================
ECHO.
ECHO You start walking. Where are you headed to?
ECHO.
ECHO =========== COMMANDS ============
ECHO.
ECHO north / east / west
ECHO.
ECHO =================================
ECHO.

SET /P command3=%commandCall%

IF /I %command3%==north (
    ECHO.
    ECHO You go north.
    ECHO.
    GOTO END
)

IF /I %command3%==east (
    ECHO.
    ECHO You go east
    ECHO.
    GOTO END
)

IF /I %command3%==west (
    ECHO.
    ECHO You go west
    ECHO.
    GOTO END
)

IF /I %command3%==inventory (
    ECHO.
    CALL :Inventory
    GOTO AAA
)


) ELSE (
    ECHO.
    ECHO %errorMessage%
    GOTO AAA
)

:Inventory
ECHO.

FOR /F "tokens=1* delims==" %%i IN ('SET :: ') DO (
  
    IF "%%j"=="1" (
        ECHO.
        ECHO =========== INVENTORY ============
        ECHO %%i
    )
)

ECHO.
EXIT /B

:END

ECHO.
ECHO.

SET /P commandEnd=Restart?

IF /I %commandEnd%==restart (
    CLS
    GOTO START
) ELSE (
    ECHO.
    ECHO %errorMessage%
    GOTO END
)

ECHO.

PAUSE
That's pretty interesting. Thanks for sharing and wish you luck on your journey::coolmines
 
A nice work keep it up.
 

Users who are viewing this thread

Connect with us

Support this Site

RGT relies on you to stay afloat. Help covering the site costs and get some pretty Level 7 perks too.

Featured Video

Latest Threads

Anyone here folllow the Premier League?

im a Tottenham Hotspurs fan from the US. Who do you guys follow?

COYS
Read more

Did anyone here grow up with the Atari 2600?

Man, I love that sexy Atari beast... There's something about its games, graphics, sound effects...
Read more

Most annoying enemies in games

A lot of games have those enemies that the programmers probably were baked when they were...
Read more

Attack Of The Robots!

Was thinking about this during a recent 60 Minutes segment covering Boston Dynamics' "Atlas", a...
Read more

Emulation Frontend

One of the things I love about Duckstation is how it is organized, I love how you can see all...
Read more

Online statistics

Members online
130
Guests online
509
Total visitors
639

Forum statistics

Threads
15,923
Messages
386,441
Members
898,276
Latest member
Jajejia

Today's birthdays

Advertisers

Back
Top