I made a text based game that runs in your cmd

maelbrazil

Young Hero
Level 1
5%
Joined
Aug 8, 2025
Messages
29
Level up in
71 posts
Reaction score
87
Points
127
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
 

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

Anybody out there enjoy "Magic Tower" style games?

If you don't know, these are basically hard "Optimization Puzzles". You have a 2d map and...
Read more

Are there any good Capstone games?

After nearly losing my lungs laughing while watching Civvie 11 systematically tear every single...
Read more

SEGA didn’t market the Nomad.

Going through Pandamonium’s video on SEGA’s FY 1997, going through a leaked document. Very...
Read more

Kirby Air Riders discussion thread (spoilers ahead)

Figured I'd create a thread for this game since it recently dropped today so have...
Read more

Hidden Gems on GBA

Self explanatory, post underrated or games that just aren't talked about

I'll start, Sonic...
Read more

Online statistics

Members online
85
Guests online
586
Total visitors
671

Forum statistics

Threads
14,978
Messages
359,186
Members
895,814
Latest member
POVEDA

Today's birthdays

Advertisers

Back
Top