Thread: I have tried many things...

  1. #1
    Registered User
    Join Date
    Aug 2002
    Posts
    67

    Unhappy I have tried many things...

    But I can't get a good code to make a text adventure. I try to use a case statment for when the player enters a command but if I enter anything over one character it doesn't work. I don't know of anyway to make a if then statment that is over 4 ifs long. I have reached my limit. WOuld anyone like to suggest a good code? Please provide how it works also

  2. #2
    Registered User
    Join Date
    Jul 2002
    Posts
    66
    But I can't get a good code to make a text adventure. I try to use a case statment for when the player enters a command but if I enter anything over one character it doesn't work. I don't know of anyway to make a if then statment that is over 4 ifs long. I have reached my limit. WOuld anyone like to suggest a good code? Please provide how it works also
    Code:
    if (blah){
    }
    else if (blah){
    }
    else if (blah){
    }
    else if (blah){
    }
    else if (blah){
    }
    else if (blah){
    }
    else if (blah){
    }
    ...on into infinity
    Cheers!

  3. #3
    Registered User
    Join Date
    Aug 2002
    Posts
    67
    Oh cool thanks alot

    Peace out

  4. #4
    Registered User
    Join Date
    Aug 2002
    Posts
    67
    How do I make text in a if then? Like if I wanted to ask gender and the var was called gender

  5. #5
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >How do I make text in a if then?
    If the variable is a C+ string then all you have to do is use the equality operator (==), otherwise you need to use strcmp from <cstring>:
    Code:
    #include <cstring>
    .
    .
    .
    if ( strcmp ( var, "female" ) {
      // Handle a female
    }
    else if ( strcmp ( var, "male" ) {
      // Handle a male
    }
    else {
      // Question the user's sanity.
    }
    -Prelude
    My best code is written with the delete key.

  6. #6
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,490
    if you want to make a simple text adventure fast you might want to look for some of the text adventure game toolkits out there, like tads. (sp)

  7. #7
    Registered User
    Join Date
    Aug 2002
    Posts
    67
    I am using this as a way to get better with c++ not make a adward winning game

  8. #8
    Registered User datainjector's Avatar
    Join Date
    Mar 2002
    Posts
    356
    First of all u cant make an award winning text game can u???
    "I wish i could wish my wishs away"

    "By indirections find directions out" -- William Shakespears

    "Do what thou wilt shall be the whole of the law" -- Crowley "THE BEAST 666"

    Mizra -> love = Death...
    RDB(Rocks yooo)..

    http://www.cbeginnersunited.com

    Are you ready for the Trix ???

  9. #9
    Registered User harryP's Avatar
    Join Date
    Sep 2002
    Posts
    124
    Sadly, no. That's not to say you can't make an excellent text-based game, but it just won't win any awards because in today's world it's all graphics. You could make the best game in the world, but if it's text-based, it won't win a thing.

    Brendan
    Draco dormiens nunquam titallandus.
    Console Graphics Library: http://www.geocities.com/steve_alberto/cgl.html

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Suggestions for things to study
    By Mastadex in forum Windows Programming
    Replies: 5
    Last Post: 08-18-2008, 09:23 AM
  2. Plants that eat things
    By StinkyRyan in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 07-05-2004, 03:41 PM
  3. How are things looking
    By cyberCLoWn in forum C++ Programming
    Replies: 8
    Last Post: 01-15-2004, 02:53 PM
  4. Selecting things on the canvas
    By Barjor in forum Windows Programming
    Replies: 0
    Last Post: 08-30-2001, 02:10 PM
  5. Help with these three things...
    By face_master in forum C++ Programming
    Replies: 2
    Last Post: 08-26-2001, 07:05 AM