Text based game

This is a discussion on Text based game within the Game Programming forums, part of the General Programming Boards category; Hi people. I am going to finally start designing my text based game after that calculator project for my ICT ...

  1. #1
    Sanity is for the weak! beene's Avatar
    Join Date
    Jul 2006
    Posts
    321

    Text based game

    Hi people.
    I am going to finally start designing my text based game after that calculator project for my ICT coursework that some of you helped me complete.

    Anyway... back to the designing...

    I was thinking, I don't have a clue where to start, that's where you guys come in.
    So, I was wondering if you guru's out there could give me any pointers on how you made your first text based games, I know I could use some

    All help will be appreciated, even criticism.

  2. #2
    Registered User
    Join Date
    Jun 2007
    Location
    Usa, Pa
    Posts
    39

    Wink

    http://www.rdxgames.net/projects/wrathlands/index.html


    There's video tutorials on this site for a full built text based game made in C++, step by step and highly detailed explanations for a lot of the code in the project.

  3. #3
    Registered User manofsteel972's Avatar
    Join Date
    Mar 2004
    Posts
    317
    I have never seen that tutorial before. I had some spare time and decided to watch some of the videos for the tutorial. First off, they use void main() in the video tutorial. They seem to hardcode all the text and, there is no discussion on why they chose to design the project the way they did. Why would they choose to make each location a function? To me, it doesn't seem like a very good tutorial to learn from. Please do not mistake me for a guru. I have just done a lot of research.

    For some design tips I would reccomend the following.

    1. Start with something simple. The simpler you keep it the better and then build on that.

    2. Try to find areas where you end up duplicating the same things. These are places where you want to create functions. For example for each area you goto, you need to display a description of the area and give choices for navigating to a new area. Since you do this over and over for each area, it may be a good place for a function to display that information. It would accept a string for the description and maybe an array of choices you can go.
    3. Try to make it easy to navigate, make changes and expand. You could create a data structure that contains a variable to hold the name/description of the area and an array of choices you can goto. You can create an array of these and then depending on the choices you make you can navigate to other areas by changing the index into the array. You could also create a linked list of the areas each node would then have a lists of nodes to adjacent locations. Depending on the choice you make you can then follow that pointer to navigate to the new area. With a linked list, you can then expand your world later by adding new areas. You just add a new node to your list. You can save the nodes to a file and reload them. You could create a text file where you store all the descriptions for each area. This way you can edit the file instead of searching through your code to find the string. If something is above your skill level, there are usually alternative ways to do the same thing.
    Last edited by manofsteel972; 07-06-2007 at 04:40 AM.
    "Knowledge is proud that she knows so much; Wisdom is humble that she knows no more."
    -- Cowper

    Operating Systems=Slackware Linux 9.1,Windows 98/Xp
    Compilers=gcc 3.2.3, Visual C++ 6.0, DevC++(Mingw)

    You may teach a person from now until doom's day, but that person will only know what he learns himself.

    Now I know what doesn't work.

    A problem is understood by solving it, not by pondering it.

    For a bit of humor check out xkcd web comic http://xkcd.com/235/

  4. #4
    Registered User
    Join Date
    Jan 2006
    Location
    Sweden
    Posts
    92
    I'm writing a kind of text based game right now. However, its not fully text based (got a graphical combat) and its a MMORPG, and the client will (is being) be written in flash.

    The design can be used for every game, so far (not very far actually). I'd like to recommend you to think everything through carefully. Don't get caught up on how to write code that fetches a dialog tree from somewhere, instead sit down with pen and paper and figure out how every system in your game should communicate. I did that for quite a long time while thinking about what libraries to use and similar problems.

    When I had my idea clear I wrote a simple class that would handle the application itself, it contained 3 functions; init, mainloop, close - and it provided me with a simple base to stand on.

    The next thing I wanted was to communicate with the player - and in a server that has to be done by network, so the network system was written. Then a simple callback class that handled the data from the socket and sent it to the proper player got created.

    Now that I could get data from the player, I wanted to get it into a meanful message that I could actually do something with so I asked myself - how should I parse those messages?

    IGameState was the abstract class that solved all my problems. The player has different game states which are represented by different versions of this class - this also makes the game quite flexible. To get the messages from the player to the game state I added a listener system, each game state registers to a player which messages it want to handle and the player forwards those messages to the game state.

    When the game loops the player calls the latest game state, each player can have many game states - in a kind of stack - the game state at the top is the one which gets updated, but all other game states receives the messages they are listening for and keeps the player data alive also.

    All those players had to be placed somewhere so I wrote a game class, it handles the connection of new players and looping through all players at update.

    Well, this is the structure of the game I'm working on. When you are creating the structure of a big program, the most important thing is not to be able to code every line - but to make everything work together.

    Check this article, it is pretty nice: http://www.gamedev.net/reference/art...rticle1764.asp
    I thought it would be a good idea to write one, but the work on my game was to tempting I simply could not resist working on it and the tech document never saw the world.

    Hope you found something useful in this rather long post, I also want to say that I'm not a guru at all and this is my first pretty big game. But I'm feeling positive that all systems will work together and that it can be released some day, if I only have the time to spare.

    Good luck

    Regards
    Daniel

  5. #5
    Sanity is for the weak! beene's Avatar
    Join Date
    Jul 2006
    Posts
    321
    Hi, thanks for your replies, I liked that article that you posted Wazaa, and it got me thinking, don't ask me how, will I need a Script engine for my game? Because after I read that article I searched through the boards and found a few threads on Script engines. If I do need one, then can someone explain to me what they are and advise me how to write one?

    Thanks in advance.
    Last edited by beene; 07-07-2007 at 01:36 PM.

  6. #6
    Sanity is for the weak! beene's Avatar
    Join Date
    Jul 2006
    Posts
    321
    Right, I was thinking last night before I went to bed, aside from the Script engine, and came up with this question, could you actually make a text engine? I mean i've never heard of a text engine before, i've heard of game engines and sound engines and stuff, but never heard of anybody saying anything about a text engine. And if so can you please help me by advising me on the core components and stuff, and what knowledge I would need to make a simple one?

    Thanks
    Last edited by beene; 07-08-2007 at 08:57 AM.

  7. #7
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    They seem to hardcode all the text and, there is no discussion on why they chose to design the project the way they did.
    They didn't design it

  8. #8
    Registered User manofsteel972's Avatar
    Join Date
    Mar 2004
    Posts
    317
    An engine is just the part of the code where a majority of the actual work is done. It is designed to be reusable and so generalizes and abstracts as much as possible. It is usually streamlined to be as efficent as possible at processing specific kinds of data. For example, a particle engine would be structured in such a way to process large numbers of particles as efficiently as possible. A game engine is designed to bring together all the components that make up a game in such a way to make it easy to create games that hopefully perform as efficently as possible and usually on as many platforms as possible. Yes there are text engines, but they are usually refering to word processing and font programs. There are text engines that would allow you to create a custom text. For example, if you designed some lettering for a game maybe an alien language that had special symbols. But all that really boils down to is semantics.

    For clarity, I would say that you would be developing a text based game engine. For a text game, one motivation for creating an engine would be that you want to make several text based games. Another is that it is a good excercise in code reuse since you will probably come up with a few things that can be used in other projects that may not even be games.

    So with all that in mind, a script engine would be the section of code that is designed to process scripts that you would write. A script is basically a document that is used as the data to manipulate your game. With a script you can add new things that were not in the game before. Say you want to add a tree, add a new dungeon, or add a new enemy monster, you can just write or edit a script to add it in.

    Do you NEED a script engine? Well that is where you need to determine what your requirements are. What type of game do you want to make? Is it a MMORPG where you have tons of people online simultaineously, or is it just a single player Rogue type adventure game?

    Keeping it simple is usually best when you are just starting out. A very simple start would be a King's Quest type game, or something like a choose your own adventure book where all you are doing is navigating a story with the goal being to make it through the adventure alive. You can find items along the way that can be used to solve puzzles, and open locked areas.

    A good game in my opinion, is largely about the story. Yeah it is great if you have some cool weapons and armor and if you can learn a new special battle move. That only takes you so far. Some of the best games I have ever played, have had a good solid story and plot. Some of the worst games I have ever played were just hack and slash repetitive and boring.
    "Knowledge is proud that she knows so much; Wisdom is humble that she knows no more."
    -- Cowper

    Operating Systems=Slackware Linux 9.1,Windows 98/Xp
    Compilers=gcc 3.2.3, Visual C++ 6.0, DevC++(Mingw)

    You may teach a person from now until doom's day, but that person will only know what he learns himself.

    Now I know what doesn't work.

    A problem is understood by solving it, not by pondering it.

    For a bit of humor check out xkcd web comic http://xkcd.com/235/

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Text based game
    By wipeout4wh in forum C Programming
    Replies: 12
    Last Post: 03-26-2009, 05:39 PM
  2. Text based game
    By beene in forum Game Programming
    Replies: 10
    Last Post: 05-12-2008, 08:52 PM
  3. New Project, text game, design stage.
    By Shamino in forum Game Programming
    Replies: 9
    Last Post: 05-23-2007, 07:39 AM
  4. Saving a text game
    By Unregistered in forum C++ Programming
    Replies: 4
    Last Post: 03-27-2002, 01:33 PM
  5. Text Based Game
    By drdroid in forum C++ Programming
    Replies: 2
    Last Post: 02-18-2002, 06:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21