Text Based Games

Questions regarding game mechanics and graphic programming should go here.

Moderators: Darobat, RecursiveS, Dante Shamest, Bugdude, Wizard

Text Based Games

Postby Alexanders01 » Wed Feb 25, 2009 5:25 pm

This is a rather newbie question, but it is still better fitted to this forum, methinks. I've been getting back to more basic gaming lately, playing MUDs and text-based RPGs/adventures for laughs and interest's sake, and I had a thought (as crazy as that sounds): what kind of data types are people using to store this kind of information?

I've done a little snooping around out of curiousity, and from what I have seen I don't imagine many of these text-based -type games get made in C++ terribly often, but I am interested in how they store things like rooms. Items and such I at least understand to some extent: just generic classes with tons of unique versions of them. But what about the actual world? Would one store that kind of information in an array of Room class objects, or perhaps an integer array and have descriptions assigned somehow to those arrays (or grouped together in a struct)? Seems that even the people who make these things have very differing opinions on the subject, so I thought I would get the opinions of some of you folks who are really aware of how easy or efficient some of the data structures would be in cases where they would need to hold various types of information (strings for descriptions, integers for locations, some way to relate those locations to the locations of the other rooms, etc.).

Not a desparately needed answer since I have no plans to make a game, but just a semi-interesting topic for discussion.
Posts: 102
Joined: Wed Jun 25, 2008 11:20 am

Re: Text Based Games

Postby packetpirate » Wed Jun 09, 2010 4:02 pm

From my understanding, most people use 2-Dimensional arrays to store the layout of the room. Most games read in the layout of the room (like a simple map editor) from a file. They store each character in the array. Now say we have Xs representing walls, an H representing the hero, an O representing where he has to go, and something else representing enemies. When you press keys, the programmer could alter the position of the H on the screen. For example, to move down, he could say that when you press the down arrow, he would add 1 from the 2-D array in the column bracket... for example.

Code: Select all
//user presses down key
playerPOS = room[currentRow][currentColumn + 1];

Does that make any sense?
Posts: 2
Joined: Wed Jun 09, 2010 3:48 pm

Re: Text Based Games

Postby Isaac Remuant » Thu Jun 10, 2010 11:28 am

Once you start adding objects, enemies and stuff you'll find easier to just point to the tile instead of having a copy to the value but yeah, start simple with 2d arrays of structure tiles that will hold whatever you think you need.

Roguelikes are a great place to practice a lot of algorithms and also make use of interesting OOP.

Good luck.
Isaac Remuant
Posts: 3
Joined: Thu Apr 08, 2010 6:41 am

Re: Text Based Games

Postby KajolThappar » Mon Sep 13, 2010 11:09 pm

Mate I play Online Text games and all I can recommend you are these, one of them I found so addictive I used to stay up until 10 in the morning on it.
Posts: 8
Joined: Mon Sep 13, 2010 11:06 pm

Re: Text Based Games

Postby mylanguage » Fri May 20, 2011 4:59 pm

Since we are on the topic, what are some of the C++ games that we know of? I have been using a youtube to mp3 converter to try and gather some audio of examples on YouTube but I need more information. I would love to spend a few days playing around with them to see how people are programming the functionality with so many variables. I have also been hearing some rumors flying lately of big gaming servers moving their text based game codes to cloud hosting and performance has increased ten fold. It seems like this progression could actually be kind of a cool learning lesson.
User avatar
Posts: 6
Joined: Thu May 19, 2011 10:49 am

Re: I tried something interesting you can check below.

Postby libra65 » Mon Dec 21, 2020 5:39 am

Hello! I read your article frequently and it's awesome and helpful. You provided great knowledgeable information. Such a great site. It's my Blog You can Visit Here.
Posts: 1
Joined: Mon Dec 21, 2020 5:38 am

Re: I tried something interesting you can check below.

Postby daniallevi65 » Thu Jan 14, 2021 4:58 am

I appreciated your professional way of writing on this topic. You have made it easy for me to understand. Good and precise info. Such a great site. It's my Blog You can Visit Here.
Posts: 1
Joined: Thu Jan 14, 2021 4:57 am

Daniel Leo

Postby Danileo21 » Fri Jan 15, 2021 1:34 am

I think this is one of the most significant information for me. And I'm glad reading your article. Thank you for sharing very valuable information. And Here is my blog you can Visit Here.
Posts: 1
Joined: Fri Jan 15, 2021 1:33 am

David Eli

Postby davieli00 » Tue Jan 19, 2021 3:47 am

This post is very nicely written, and it also contains many good facts. I appreciated your way of writing the post. You have made it easy for me to understand. Really good site, You can also check my BlOG here.
Posts: 1
Joined: Tue Jan 19, 2021 3:45 am

Kevin Lost

Postby kevilo7890 » Wed Jan 20, 2021 4:02 am

You provided great knowledge of information. You made it easy for me to understand. It's awesome and helpful, also this post is very nicely written and it also contains many good facts. It's my Blog You can Visit Here.
Posts: 1
Joined: Wed Jan 20, 2021 4:00 am

Return to Games and Graphics

Who is online

Users browsing this forum: No registered users and 2 guests