Thread: Simple Text Adventure: Need Help

  1. #16
    Registered User C_Coder's Avatar
    Join Date
    Oct 2001
    Posts
    522
    You would be better using structures as you can then store different types of data about the same location for example:
    Code:
    struct location{
         char description[255];
         struct location *north_ptr;
         struct location *east_ptr;
         struct location *south_ptr;
         struct location *west_ptr;
    }
    This structure contains a description of the location and pointers to the next location, so if the user selects north you load the location pointed to by north_ptr.

    I know you said you didnt know much about pointers but you really need them, take some time out and read up on them as you will benifit greatly in your attempts to create any programs.

    I am trying to write a text adventure too and I pull my hair out all the time, because going from location to location is the easy part it's making sense of user input and interacting with objects that is the hard part.
    All spelling mistakes, syntatical errors and stupid comments are intentional.

  2. #17
    Registered User
    Join Date
    Oct 2001
    Posts
    81
    I was trying something like that only wiht classes using the example from the earlier page, but i just couldn't figure out what half the tears were and how to make them work, i need to order a book or something, the ones i have are orld so i've been relying on online tutorials. thats why i was going for something simpler. i'll try it, but i would still like it if someone could tell me what i did wrong on that example so i'll know if i ever need to use something like that again.

  3. #18
    Ethereal Raccoon Procyon's Avatar
    Join Date
    Aug 2001
    Posts
    189
    I see two problems:

    1. You need to initialize x and y to zero.

    2. Setting the MAP array values to the return value of cout is a nonsensical operation. Use something like if MAP[x][y] == 2, where 2 is a label designating a certain tile. But this isn't a very good way to do this.

    And yeah, you really need to learn more of the basics before you can make a good text adventure. It's not an easy task, and if you do it before you've grasped the basics you'll probably just learn bad habits because you haven't learned the proper ways to do certain things.

  4. #19
    Registered User C_Coder's Avatar
    Join Date
    Oct 2001
    Posts
    522
    heres my go I did it in c using structures so it's a bit longer than the others but what the hell

    This only allows movement around rooms you still need to create a parser for the user input, thats when your brain will really hurt!
    Last edited by C_Coder; 10-28-2001 at 07:28 AM.
    All spelling mistakes, syntatical errors and stupid comments are intentional.

  5. #20
    Registered User
    Join Date
    Oct 2001
    Posts
    81
    any suggestions on books i should get that would show me wher eu guys learned this styff in c++?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. simple text analyzsis program
    By prominababy in forum C Programming
    Replies: 4
    Last Post: 04-16-2009, 10:15 AM
  2. Replies: 0
    Last Post: 11-19-2008, 01:16 AM
  3. Replies: 6
    Last Post: 01-29-2008, 04:40 AM
  4. Text Adventure
    By ArtGeek in forum C++ Programming
    Replies: 4
    Last Post: 05-01-2002, 11:23 PM
  5. simple text dialog ok cancel
    By Brian in forum Windows Programming
    Replies: 1
    Last Post: 02-12-2002, 02:20 AM