Skip to main content
GameDev.net gamedev.net
🔒 Locked

How can I create a text based adventure game?

Started by wormhero1 Jul 4, 2012 at 5:02 AM 20 replies 26.5k views
Original Post
wormhero1
wormhero1
I've wanted to make games for a while now. I started learning c# about a week ago. I know some basics, but I'm still learning it. I just wanted to ask how can I start to create a text based adventure game. I have yet to find a real tutorial on it. Can anyone give me some tips on creating one?
DevLiquidKnight
DevLiquidKnight
Your going to want to make a set of rooms in some sort of format, that have a variety of things in them and then load them from say an XML file. It's somewhat of an advanced thing to build for a beginner to C#. Have you done coding in any other languages?

I would recommend you start smaller then this, perhaps try making a game where their is a grid of locations that are drawn to the screen and it lets you move through the grid somewhat like a map. You can imagine using an array to store the information of where the person is, and then moving them through the array based on where they want to go. Then each area could have say a chance of getting attacked by say a monster, and then it would switch to a combat system. Where you would fight this monster before you can move again.

This thread may also prove useful.
JDGamedev
JDGamedev
I made a SUPER SIMPLE and probably poorly done text game in Java (which is very similar to C#). If you want to check it out as an example you can see the game and a link to the source on my website.

What I did was build a class for each major concept that I wanted. Items, rooms, entities(players and monsters). The rooms were a bit tough to tackle. The simplest way I could imagine doing it was assigning exits to each room which were just other rooms themselves. When a player went though an exit they were put in the next room. If there was no exit in that direction(N S E or W) then it was null and did not allow traversal.

My source code will explain in better but if you have any questions, feel free to ask: myself and the other programmers here will be able to help. Good luck.
nugget850
nugget850
This is my first coding language. What are some suggestions for creating a game simpler?
JDGamedev
JDGamedev

This is my first coding language. What are some suggestions for creating a game simpler?


I think just about everyone would like simpler (read better) code. What I find helps me the most is making sure that I know what I want to do before I start coding. Thinking about what you are going to program is a huge part of programming. Even if you don't know exactly what data structures you will use to solve a problem, just make sure that you understand what needs to get done.

My answer is pretty abstract, but there really is no language specific advice to give for that question. It's all about how you tackle the problem.
kseh
kseh
It's already been mentioned and I'll repeat the fact that there's a lot of techniques that you can probably learn yet that would make it easier to produce a text adventure. However with careful thought about what you already know and some creativity you should be able to come up something that will help you feel like what you're learning is worthwhile and in the direction that you've been hoping for. If I recall, my first text adventure used little more than a couple of switches and a whole lot of if statements. Code wise, it was horrible. But it more or less did what I wanted it to and I was proud of the result.

First I used pen and paper to draw a map which I think was just a 5 * 5 grid. I planned which directions the player could go for each location. I also figured out what text I would print for each location. For whatever location the player was in, I'd print the text, then collect input regarding which direction the player wants to move, if it's a valid direction then move the player to the desired location, and repeat.

As for challenges of some kind to complete, you will need to know what those challenges are and how the player would be expected to beat them. Developing a combat system is one option but it might be a bit early for that. It'd probably be easier to think of something like, there's a giant frog blocking the player's way in one location. You would track the fact that the frog is in this room and so long as it is in this room, attempts to travel through one exit will be disallowed. The player recalls that in another location is a jar of flies. He travels back to the room with the jar. The player is somehow given the option to get the jar. The fact that the player now has the jar in his possession is tracked. The player returns to the frog. The player drops the jar (again tracking the fact the jar is in the player's possession). When the jar is dropped in this specific room, the frog chases the flies and is no longer blocking your path.

You can do the sort of stuff I described above by just setting some variables, using if statements, and printing to the screen. Nothing spectacular at all. If there's one reason to not proceed yet though, it is that using only those techniques, you *will* end up with a large mess of code that will be difficult to manage and identify where problems are occurring. Organizing things into classes and being able to load data from files could help that. Truth be told though. if you have no experience with that sort of thing you're just as likely to end up with a giant mess that doesn't work either. So the best tips I can give would be to; get creative with what you know, plan the best you can, give the plan a try, don't be afraid to fail, learn something about what you did, and repeat.
larspensjo
larspensjo

So the best tips I can give would be to; get creative with what you know, plan the best you can, give the plan a try, don't be afraid to fail, learn something about what you did, and repeat.

I couldn't agree more. Either you succeed with what you want to do, which is fine. Or you don't succeed to get what you want. The failure is unfortunately one of the best ways to learn. That is when you start to appreciate design patterns. Without having done the failure first, it can be hard to understand why a specific design patterns are used.
DavitosanX
DavitosanX
To the OP, if you think that a text game is easier to do than a graphical one, you may be mistaken. Really, learning to display an image on the screen isn't particularly difficult. If you already have a basic grasp on your language of choice, it's at most a one-day endeavor.

If you like, take a look at Inform 6 or 7. It's a programming language designed specifically to write interactive fiction. You'll realize soon that those games' complexity is staggering. Don't shy away from graphics. Once you start getting the hang of it, the results will be very satisfying.

Of course, if you mean to program a text adventure, do try out Inform. After all, some of the greatest games of all time are interactive fiction (The Lurking Horror, anyone?)
Starting out in game programming? Me too! Check out my blog, written by a newbie, for the newbies. http://myowngamejourney.blogspot.mx/   Also, if you don't mind a 5 seconds ad, here's a great free ebook for beginners on the subject of pygame: http://bit.ly/19Bem2q
frob
frob

Not so much a tutorial on the genre, but I built a mini text adventure as a step in the process, documented here.

Khatharr
Khatharr

A thread for the ages...

void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.
jeskeca
jeskeca
Start by writing a one room text adventure.

Add a room.

Rinse repeat.
jacmoe
jacmoe

To the OP, if you think that a text game is easier to do than a graphical one, you may be mistaken.

Well..

A text adventure is probably the most focused type of game you can make. The complexity of assets like textures, models, animations, whatever is not there. :)

You can concentrate on the text, the logic and the code.

That sounds easier in my ears.

Too many projects; too much time
MarkS_
MarkS_

Well, I've been wanting to make one for years, but...

jacmoe
jacmoe

D'oh - did not notice that the OP posted this in 2012 biggrin.pnglaugh.png

Too many projects; too much time
MarkS_
MarkS_

I've actually been wanting to make one for years, but I've also had that pic waiting for years... Perfect timing! I get to use that pic and this thread might just spur me on to make a text adventure game! Now I just need a story. But that's a topic for another thread in another forum...

As a side note, although completely relevant, the forum software alerts you when you are about to post in a thread older than 60 days:

Khatharr
Khatharr

We should change it to also warn if the topic itself is over a certain age.

void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.
MarkS_
MarkS_

I disagree. They lost favor with the introduction of interactive computer graphics, but the lack of graphics makes the developer focus on the story; Something that I think has been lost. The lack of graphics has one other advantage and that is that you must actually think to win. Depending on the amount of time spent developing the story and world, they can be even more challenging than CGI-based games. You easily forget where you are in the world, what direction to go, what inventory you have. It's like playing Skyrim blindfolded. You have to use your imagination and memory. You need both of those less with visuals.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.