The toggled situation

It all started from a tiny toggle which led me into a state of deep reflection, so much that I spent three days munching over toggle and check-box usability and how they impact intended user…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




How to Create your own Text Adventure

Text adventures are a fun, creative way to tell interactive stories, and they’re easier to make than you think!

Inform is a programming language made specifically for creating text adventures.

It makes it easy for anyone to create their own, whether you know how to program or not. Unlike other programming languages, it’s mostly made of existing English words and grammar!

When you open Inform, you’ll see a welcome screen, like below. Click “Project” under “Create New” to start your text adventure. Give it a great name!

Inform Welcome Menu

The bulk of writing text adventures in Inform relies on three ideas: objects, descriptions, and relationships.

Every room, item, and person that is in your text adventure is defined as an object in the code. You make these objects come to life by providing descriptions of them and having them form relationships through actions.

Inform will give you a little bit of code to start out with, including the definition of your first room. It has defined “Example Location” as a room using this line of code:

However, “Example Location” is a really boring name for a room, so instead I’m going to make it my bedroom.

You might have guessed this already, but all you need to do to run your code is to press the big button in the top left corner that says go!

Go button in Inform

After pressing run, your code will compile and run. It should look something like this:

Running game

When you type in a command and press enter, the software will generate a response based on your code.

You, the player, are an object in the game. Since you’re the only thing in the bedroom, all you can successfully do right now is interact with yourself (try “examine me,” “kiss me,” and “rub me” 😜).

Being by yourself in an empty room isn’t super fun, so the next step is to create your setting. Go back to your code and add a description to your room. This is how the room will be described to the player.

For example, here is how I would define the description of my room:

The description can be as brief or long as you like.

If you run your code again, you can see the description of your room!

Now the player can see things in the room, but they still can’t interact with anything!

So, we’re going to add an object that the player can interact with. By default, players can pick up and drop any object that you put into the room.

Since this is my bedroom and I like to read, I’m going to put a book in the middle of my bed. To create an object, you just need to mention what it’s called and what room it’s in. You can also add a blurb about the object that will be included in the room’s description.

So, now my code reads

Instead of using the name of the specific room, you can also just use “here” to refer to the most recently defined room.

Try running your code again. Now, you can pick up and drop your object!

Some text adventures will take place in one room, but most have multiple rooms for players to move through and explore! You can create another room the same way we created the first one — defining it and adding a description.

Since my first room is a bedroom, I’m going to add a living room. To allow the player to move from one room to another, you have to define how the two rooms are located in relation to one another using cardinal directions.

If I run my code and use the command “east” while I’m in the bedroom, I will move into the living room and if I use “west” while I’m in the living room, I’ll move back to the bedroom.

Try it out for yourself!

Since I have a book and a bookshelf, I want to be able to put my book onto the bookshelf. We can make this happen by creating a bookshelf object that is a container.

A container is a special type of object that you can put other objects into.

We can turn an object into a container using the phrase “is a container.”

This line of code creates a bookshelf object in the living room and allows for things to be put inside of it.

To try it out, run the code and enter “pick up book” while you’re in the bedroom. Then, move to the living room and use the command “put book in bookshelf” to put the book on the bookshelf.

No game is complete without and ending.

To create an ending, we’re going to use a conditional statement to check if the book is in the bookshelf. If it is, we’ll end the game.

We will want to check this condition every turn. This can be done with the following line of code:

Once you have an end condition, you can run and play the whole game! By default, after the game ends, the player will have the options to restart, restore a saved game, quit, or undo.

This is just the start of what you can accomplish with Inform! You can create a whole text adventure with just the ideas from the steps above or you can dive deeper into what you can do with Inform!

Happy adventuring! 👏

Complete Code:

Add a comment

Related posts:

Higher Education System Simplified

Do not forget to study abroad. The overview of the reasons why you should consider studying in Australia will help you choose the right destination for you. VIT Australia institute is a world-class…

The musings of a Waste Water Olympian and the future of biotech

Anna Puglisi is the Director of Biotechnology Programs and Senior Fellow at Georgetown’s Center for Security and Emerging Technology (CSET). Previously she served as the National Counterintelligence…

Homemade small white bean soup made with ham broth

Reaching into the cupboard for a favorite canned soup may be convenient and somewhat satisfactory. And I agree some brands are very well made and flavorful. But with convenience comes the price of…