I made a text based game that runs in your cmd

maelbrazil

Young Hero
Level 1
12%
Joined
Aug 8, 2025
Messages
34
Level up in
66 posts
Reaction score
111
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
 

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

Viewpoint 2064 final version found and released

Youtube channel Hard4Games have released hours ago a full new complete N64 game, from 1999. This...
Read more

Let's play chess!!

The goal is simple: move one piece at a time, whoever slays a king first wins.
Each member will...
Read more

Whoop Whoop!!!

Yeah, I love me some ICP and juggalo music. Don't hate, I'm not bothing anybody...
Read more

Favorite Hatsune Miku song(s)

Simply put, what songs our Goddess has graced our ears with?

My top 3 must be:

Gold Medal...
Read more

Online statistics

Members online
55
Guests online
572
Total visitors
627

Forum statistics

Threads
14,978
Messages
361,950
Members
896,068
Latest member
sunfish_isloved

Today's birthdays

Advertisers

Back
Top