Thread: A question about text games

  1. #1
    'AlHamdulillah
    Join Date
    Feb 2003
    Posts
    790

    Question A question about text games

    Heya,

    I have a question about text games. Say, I give a player 4 options to choose from for directions to travel, then I display some tet with info about the terrain, as well as enemies.
    How would(can) I make it so, that say, the game records which town/part of the map the player is, and responds with the appropriate text, and gives choices of places to go, without having to do the same thing for each of the every towns.

    I was thinking of a loop, but dont have an idea of what type.

  2. #2
    Registered User
    Join Date
    Aug 2001
    Posts
    403
    I think you mean a game like :

    --
    You are in a cave, there is a demon to your left and a sound ahead of you in the darkness.

    >>(N,S,E,W)
    --

    Do you know about functions, sorry if this is a dumb question to ask you but I wasn't clear on your question if you do know about them.


    I wrote something like this several years ago in C, I remember having code like:
    Code:
    struct roomData
    {
          int roomX, roomY;
          char *desc;
           ITEM *item;
    }
    
    ...
    
    roomData map[WIDTH][HEIGHT];
    ...
    
    void PrintRoom(roomData data, roomData[WIDTH][HEIGHT] map)
    {
        stuff to print string and allow them to move to the next room
    }
    If I didnt answer your question I apologize, I wasn't entirely sure what you were asking.

  3. #3
    'AlHamdulillah
    Join Date
    Feb 2003
    Posts
    790
    sorry, about not being clearer.

    say

    the user enters a small room with a sarcophagus, yet decides to leave, how could I set it up so the person can enter and leave several times without me setting up alot of code.

    EDIT:

    I was thinking, could I do this with functions? say make functions with all the data I want for each place?

    such as
    Code:
    void dungeon001(){
    
    // data
    }
    
    void townsquare001{
    
    //data
    }
    
    and have them call eachother?

  4. #4
    'AlHamdulillah
    Join Date
    Feb 2003
    Posts
    790
    also, I am kinda unpracticed with C++ mainly, I have learned alot, and am doing some win32, but havent practiced that much at interlocking everything.

  5. #5
    Registered User
    Join Date
    Aug 2001
    Posts
    403
    I'd make a struct for a room and then have an array of those structures. Instead of keeping up with 100s of functions I'd probably read in the data from a text file or simply use one large function to initialize the entire map, then have functions that take the map as a parameter that would allow you to move around the map.

  6. #6
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    We have discussed text games and text game maps ALOT on cprogramming, a quick search of the boards will aid you greatly in your task.

  7. #7
    'AlHamdulillah
    Join Date
    Feb 2003
    Posts
    790
    Thanks RoD, will do

  8. #8
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    To help narrow your search abit, i think it was techwins who guided me to the use of a text game map a few months back.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Text adventure engine idea. thoughts?
    By suzakugaiden in forum Game Programming
    Replies: 16
    Last Post: 01-15-2006, 05:13 AM
  2. Replies: 15
    Last Post: 10-31-2005, 08:29 AM
  3. just another text input question...
    By GGrrl in forum C++ Programming
    Replies: 2
    Last Post: 03-23-2003, 06:25 PM
  4. Replies: 2
    Last Post: 11-08-2001, 08:42 PM
  5. quick question about C Dos text menu pgm i was doing
    By Shadow in forum C Programming
    Replies: 2
    Last Post: 09-16-2001, 10:26 AM