Thread: creating a text adventure; where to start

  1. #1
    Advanced Novice linucksrox's Avatar
    Join Date
    Apr 2004
    Location
    Michigan
    Posts
    198

    creating a text adventure; where to start

    I'm fairly new to programming, but I know probably enough to get started on making a pretty simplistic text based game. I just can't find any tutorials anywhere to help me out, and I'm not really sure where to start... i don't want to do graphics or anything like that (yet). I just want to make a dungeon game where you get to explore, collect stuff, maybe fight monsters or something, use items collected (like trigger events or unlock rooms), and just be able to go through a short story with a couple different endings. any ideas of where to start or any links to tutorials about text based games (no graphics) would be very helpful. thanks
    "What are all you parallelograms doing here?" - Peter Griffin (to Joe and his wheelchair buddies)

  2. #2
    Banned
    Join Date
    Jun 2005
    Posts
    594
    start by comming up with what you want in your
    game, then use conditional statments, to move
    your character through the story with the help
    of the user input. and depending on the path they take
    they will find one end of the story.


    for an advance version with monster and fighting you
    will prolly want to use some kind of class for the user, and
    monsters and what not.

    so in short


    Quote Originally Posted by Very Very Simple Explanation Bunny Rabbit
    explain the game to you user
    ask for user input on what/where they want to head off to
    if they dont something then fight a monster or find gold, whatever
    continue through a series of these until they reach a ending
    based on what they achieved.
    continue to ask for user input to make the decision on where
    the game heads to.

    you will prolly need some version of rand() to help
    you come up with random amount of gold or random
    point in the game the user is to experience something.

  3. #3
    Banned SniperSAS's Avatar
    Join Date
    Aug 2005
    Posts
    175
    So wait, you need tutorials on how to set up the program, but not actually code it? Because it probably wouldn't be too hard to figure it out on your own.

  4. #4
    Registered User LiNeAr's Avatar
    Join Date
    Aug 2005
    Posts
    31
    Well...First, I think you need an idea. Which you seem to have. But I would expand on the idea some more. Make sure it's something you really like to do, because if you don't like it, you might get bored, and move onto another project. So I would plan..plan..plan, then start coding stuff. As for the coding part, you are going to solely need to understand classes. You are going to use classes for all your items you pick up (swords,gems, etc.) Like ILoveVectors said, you will need to use the rand() function for the fighting part. You can use a system where the player always connects with the enemy, or go more advanced and make a hit and miss fighting scheme. But nobody here is going to give you too many ideas on the idea of the game, that is for you to figure out.
    IDE: Microsoft Visual C++ .net Standard 2003

  5. #5
    Advanced Novice linucksrox's Avatar
    Join Date
    Apr 2004
    Location
    Michigan
    Posts
    198
    i think supersniperSAS is right... i'm fairly confident I know what i need to as far as the programming side goes. i understand classes, constructors, destructors, and i even just finished a chapter on inheritance. but as far as my game goes, i know i need a story, and then... do i just have to design how the game works and stuff, and then code it?
    i guess more specifically, what should i use classes for? i know i'd have a class for the player, and then i think i would have a class for items, and each type of item would be its own inherited class, and then do i need a class for each room? i mean like a base class called lets say "room" and then an inherited class for each specific room? or is that not a good approach? i think if i could get that far i'd be able to take it from there, adding monsters, battles, trigger events, and crap like that.
    "What are all you parallelograms doing here?" - Peter Griffin (to Joe and his wheelchair buddies)

  6. #6
    ---
    Join Date
    May 2004
    Posts
    1,379
    >>what should i use classes for?

    That part is entirly up to you. There is no right or wrong answer. Use whatever your design requires.

  7. #7
    Advanced Novice linucksrox's Avatar
    Join Date
    Apr 2004
    Location
    Michigan
    Posts
    198
    ok... maybe i'm just thinking too hard or something. it seems like i know enough to put together a simple text based game, maybe it's just that i haven't coded anything in a few months, and even the stuff i was doing was mostly for school... but thanks for the help, i think i'm making a little progress now, i've got a test class working for a player so far. it just holds hp and lets you add, subtract, and view the hp. maybe if i get something working i'll post it in that section where you post your games and stuff. lol. thanks
    "What are all you parallelograms doing here?" - Peter Griffin (to Joe and his wheelchair buddies)

  8. #8
    Banned SniperSAS's Avatar
    Join Date
    Aug 2005
    Posts
    175
    I would use a structure for the items, though I think it would be good for you to figure it out, it will help you learn.

    Not that I'm trying to act like someone who knows what the hell they are doing.

  9. #9
    Deprecated Dae's Avatar
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    1,034
    If you wanted to waste some time: instead of making premade .txt files mapping out the levels.. make a random map generator. Takes width, height, and char used for borders, grass, paths, etc. Then use two for loops to go through them and randomly decide if you want an item there. Put an if statement in each for loop saying if the index you are on is equal to the width (or height) then make it a border. Then go through the 2d array in for loops and if the currect index [x][y] is a space (free to walk on) and so is the next one [x][y+1], and so is [x+1] and [x+1][y+1], then add a chest or some treasure in one of the four spots (chosen at random). For cities or specific places premade maps would be better. The idea I like about this is you can make say 20 city maps, and the base town. When you leave the base town you encounter a randomly generated map, and each map is treated like a part of a 2d array. out of [10][10], the base town would be [5][5] and if you left the base town to the east then youd end up at [5][6], you can now make that generated map into a text file labelled that, so if they go back to that zone its the way it was before, not random generated one. The great part about this is that you can either set the cities at say [4][7] and [8][2], etc. or you can make them appear randomly as the game goes along by saying that when you go to a new zone, it has a chance to be a city, as long as you arent near another town/city (which could be determined algorithmly).

    Most start out with switch statement menus, with a intro ascii title / text. A nice feature is for your story for the text, as you are say outputting it from a .txt file.. char by char lets say, and you cout it, add a small time delay after that, so every char when telling a story is delayed like Zelda and stuff. One thing I hate about that though is most make it too slow or make too much story to read.. its like damn hurry it up, if I'm that slow of a reader I'll read it after its done typing, then press the space bar.

    Already said.. menus contain like inventory, map, go exploring, go to *nearest town*, credits, etc. I would like to see a Story option in one of these text RPG menus where you can select the parts of the story all in a list.

    Maybe get started on the save game / load game features, where it saves hp/dex/str/int/mp/level/experience/etc. to the file, and how to load it, and possibly encrypt/decrypt as a feature.
    Last edited by Dae; 08-22-2005 at 02:02 AM.
    Warning: Have doubt in anything I post.

    GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101

  10. #10
    Banned SniperSAS's Avatar
    Join Date
    Aug 2005
    Posts
    175
    Quote Originally Posted by Dae
    Stuff

    That's not a text adventure, that's a rogue-like.

  11. #11
    Deprecated Dae's Avatar
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    1,034
    Quote Originally Posted by SniperSAS
    That's not a text adventure, that's a rogue-like.
    Whatever I was just using that game as an example because mostly everyone knows how those old games have a 'typing' type when printing the text out (1 char at a time), and many MUDs/text adventures do it, one in the 'post-your-game' topic used it also.
    Warning: Have doubt in anything I post.

    GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101

  12. #12
    Advanced Novice linucksrox's Avatar
    Join Date
    Apr 2004
    Location
    Michigan
    Posts
    198
    hey now, this is my first game ever, and i don't know if i want to try to get that complicated (at least in this first version). i'll probably make a small map and then expand on that. do the random map thing later. but i do get what you're saying about having the map randomly generated the first time you play the game, and then save the map in a file so next time you load that game the maps are still the same. that's a cool idea. but for now... i think that might be a little too much for me to try to accomplish my first time through.
    and a struct for items? i'll keep that in mind. it kinda makes sense, since items for the most part don't really change state or do anything (i didn't say ALL items) heh. for me, right now, my items won't change state so i'll keep the struct idea in mind. even though... classes are pretty much a struct, except the default for its members are private, and the default for structs are public. oh well i'm just rambling...
    on to more game design... speaking of which, wha'ts a good approach for a game design? i mean i started thinking of a story, then i started thinking about mapping, and started to try to figure out how i'd do that. should i just write a story first? or should i just figure out each system, like mapping, and player objects, inventory... then finish writing the story later? it seems like right now i'm just kinda jumping around and i'm not sure what to do first or what to wait for and do later. thanks
    "What are all you parallelograms doing here?" - Peter Griffin (to Joe and his wheelchair buddies)

  13. #13
    Deprecated Dae's Avatar
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    1,034
    I'd agree with what you said, start out on the story, then do some of the basics, then go back to the story after you've got the programming in place.

    The problem though is sometimes you'll say oh well in my story all I need is the string name, and float minDamage, float maxDamage. However when it comes down to programming it you'll immediately notice you can easily add such things as num class type (make an enum outside the weapon struct that has the choices: blunt, throwing, polearm, sword, axe, hammer, etc), float length, int durability. Which means you have to go back to the story and add that part. But I guess thats part of starting out on the basics, but more extreme cases involve redesigning your entire program.

    Create a class for monsters, then create an object of that class for each monster. Then later that can be expanded upon if you know how to either use STL vectors, or make your own array class so you can make an array of the monster class (monster[1].name = "Rat"). This brings to mind one of those 'redesigning your entire program' parts. If you made objects of your monster class (ie. MonsterClass monster1 and then set the variables name and such in that, so that the name and information is located in the actual program, then you will have one hell of a time when expanding on the basics. If you decided to switch to an array of the monster class (or vector), then you would have to retype the information for all the monsters. That is one hell of a job. The more logical thing would be to spend some time learning how to input/output the monster information from a file. That way loading information for monsters 1-50 (when you use an array) is as simple as using a for loop, its easier to change monsters info, add monsters, and any changes to your program design wont result in you have to reinput hundreds of lines of data.

    That may have sounded too 'non-basic' though <_<

    Honestly though the first step to doing it is doing it. You could sit down and program the basic menu, put in some text story, and ideas should come to you. (ie. input the story from a file).

    I would look at the source of The Text Adventures of You, http://cboard.cprogramming.com/showt...1&page=1&pp=15, has basics.. although its in C it barely is different from a C++ version.

    About the map... I would actually leave that off to start with. It would be a good feature, but you'll have to use some library, maybe Allegro, or something that you can use to navigate the map (keystrokes for up and down) and events if you find a chest.

    I'd start with menu: travel, explore, inventory, stats. travel: random chance to 'encounter' a monster: random chance which monster it will be (rat, possom, etc.), then a menu if you want to fight it, or check inventory for items, or run: depending on the level of the monster, you have a good chance to run away, a chance that the monster will attack or chase you and you must attack. On attack (or spell) your weapon does x damage (random between the min-max dam of your weapon) unless it misses, which is say a 5% chance (aka random 100, if 95-100 then your attack misses). You could later then expand on these basics and add armor penetration (say a 7% chance), defense, blocking, agility aspects that make the damage more random.

    A lot of while loops/switch statements will be necessary.

    Alright I'm done rambling.. thats just how I would start the a game if I made one.. I havent made one yet, but I plan to, just as soon as I can apply it to a 3D world (OpenGL)
    Warning: Have doubt in anything I post.

    GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101

  14. #14
    Advanced Novice linucksrox's Avatar
    Join Date
    Apr 2004
    Location
    Michigan
    Posts
    198
    i find it a little difficult to follow the code for Adventures of You because he uses only if statements and loops... kinda tedious to read. i plan on using functions (like a function that prints instead of retyping a loop to print out all the text like he did). and i don't think i want random monsters yet.
    all these ideas are great, but for now i want to stick to very simple stuff, just a simple text game, a set map (or maybe not even a map right now), short story, maybe a couple events or key items needed to do the next thing, and as far as movement goes, i just want to type in "north" or whatever, and then parse the input from there. i don't need realtime stuff right now. maybe the menu system is the way to go this time around. but i'd really rather have the ability to just type where you want to go, and type what you want to do, like "pick up key" or "use potion" or something like that. i'll figure something out
    "What are all you parallelograms doing here?" - Peter Griffin (to Joe and his wheelchair buddies)

  15. #15
    Banned SniperSAS's Avatar
    Join Date
    Aug 2005
    Posts
    175
    Perhaps this site can help you out a bit. I didn't look around the site too much, so if it sucks, my bad. However, if you checked it out you might find something helpful.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with my text adventure game.
    By Haggarduser in forum Game Programming
    Replies: 15
    Last Post: 10-26-2007, 01:53 AM
  2. Post your Best Text Adventure
    By Joe100 in forum Game Programming
    Replies: 3
    Last Post: 08-15-2003, 05:47 PM
  3. Text Adventure
    By ArtGeek in forum C++ Programming
    Replies: 4
    Last Post: 05-01-2002, 11:23 PM
  4. text adventure
    By BuRtAiNiAn FlY in forum C Programming
    Replies: 1
    Last Post: 09-05-2001, 09:39 PM