ANSWERS: 6
-
Baiscally the same way you would in most other languages. You would just attach an IF statement to each series of text. For instance attach each part of the text to a variable, like below (this is quasi code, NOT actual code): text0 = "You enter the chamber" text1 = "You enter reach a dead end" text2 = "you die, caught in a trap" text3 = "You enter into another chamber" Next thing you need to do is to creat the text, that gives you the options liket this: option1 = "Turn left" option2 = "Turn right" option3 = "Go Forward" Next, you would need to apply each option to the text. Or in other words, display the text (story line, followed by whatever options you can take. Like this: cout << text1 << endl; cout << option1 << endl; cout << option2 << endl; cout << option3 << endl; cin >> choice; Next, you have to decide, base on what the user chose, what will happen next. Like this: IF (choice==1) cout << text1; IF (choice==2) cout << text2; IF (choice==3) cout << text3; And that is about the jists of it all. This of course, has its flaws, but it does provide the basic ideas of how to go about making text based RPGs in C++. For instance, the way I described it, it would all be done in the Main function, but in practice you should give each storyline bit, its own function, and call the functions based on the choices the user made. That however, is just a mere simple alteration to the way I listed above. In any case though, I hope that you find this helpful.
-
Your question is a little broad, so here's a broad answer: Learn C++ well, define exactly what you want the program to do, then write the program. There's no way to give a detailed answer, but I'll try to offer some tips. Since C++ is an object-oriented language, and since a text-based RPG lends itself well to and OO paradigm, you should definitely take an object-oriented approach. Consider that you will be dealing with a player character, rooms, items (of various types) and non-player characters (both friendly and unfriendly). An class for each of those things would probably be a good idea. The item class should probably subclassed into weapon, key, and magic-item classes and any more you can think of (because all items will have a value, a name, and a weight but only weapons will have damage ratings). You may want to sublcass NPC into friendly and foe classes, but I'd be more inclined to use a single class with a friendliness value. This would give you the ability to have a single NPC decide its friendliness to the player at game time (based on a random-number selection adjusted for player charisma for example). The room class should contain links to other rooms in each possible direction, along with the descriptions, etc. The stickiest parts are probably going to be your input parser (the program has to figure out what you mean by "give shoddy mace to bugbear") and output formatter (because you'll probably have to deal with word-wrapping). C++ is probably not the easiest language to use for text processing, but there may well be libraries to help with these isssues.
-
this isnt really an answer but i get the text thing but where do you type all this crap? email me at [email protected]
-
Ok i will try and help you out since i am going to be doing the same thing. I am taking the following approach: 1) Create a text file with all the ideas you want to be in the game 2) At the bottom of the text file you want to put specific information about the game like Monsters, Money, Skills et cetera. 3) Start with a basic structure starting with maybe 1 monster with a certain amount of experience and damage it deals itself along with you. 4) (VERY)Slowly add more monsters effects skills equipment et cetera. 5) Post when it get kinda good. 6) Take ideas from others and add it to the game 7) Keep your source to yourself unless you wish to release. That is real simple cause i came up with it in like 2 minutes. This is exactly the way im going to be doing it. It may take a long time to do but in the end you find you will have learned more about putting code together then ever before.
-
Ok i will try and help you out since i am going to be doing the same thing. I am taking the following approach: 1) Create a text file with all the ideas you want to be in the game 2) At the bottom of the text file you want to put specific information about the game like Monsters, Money, Skills et cetera. 3) Start with a basic structure starting with maybe 1 monster with a certain amount of experience and damage it deals itself along with you. 4) (VERY)Slowly add more monsters effects skills equipment et cetera. 5) Post when it get kinda good. 6) Take ideas from others and add it to the game 7) Keep your source to yourself unless you wish to release. That is real simple cause i came up with it in like 2 minutes. This is exactly the way im going to be doing it. It may take a long time to do but in the end you find you will have learned more about putting code together then ever before.
-
I've attempted to write a few text RPG's when I was just learning C++... All of which eventually failed, except one, which gained a bit of popularity among one of the sites I'm a moderator at, but then I started tampering around with it, and ended up screwing up the battle engine. I'll give you some tips. 1: ALWAYS plan out the structure of the game BEFORE you even think about how you're going to code it. 2: Don't think up every detail (Monsters, items, etc) before you code it; I find it much easier to just think them up and program them as you go. 3: Since your using C++, use it well. Classes are your friends. 4: When you do program it, make sure not to hard-script ANYTHING other than your data. This is a leading non-structured programming failure. 5: Don't overcomplicate anything. Keep it niiice and simple. I hope this helped a bit! ~Octavarium_XI
Copyright 2023, Wired Ivy, LLC