How do i make long "if, else if...

How do i make long "if, else if, else" expressions in C++ so i can make multiple split-off adventures within in my ASCII text game adventure?

Attached: pepeee.jpg (400x400, 29K)

Other urls found in this thread:

youtu.be/7uLzaKlZSQQ?t=348
twitter.com/NSFWRedditGif

Horizontally.

By installing Gentoo

1. Use a switch statement
2. Reconsider how you are structuring your program, because it sounds like you are doing something wrong.

Use a hash table, I recommend absl::flat_hash_map

I GOT MY HASH PIPE
YEAH FUCKIN WEEZER
WEEZER ROCKS MAN

This is how i have it set up.

I tried to make "stand" a string so i could have the person type in words but only int's seem to work with if expressions for some reason.

forgot pic

Attached: game.png (941x832, 117K)

This is how Halo 2 was designed.

Damn dude at least store your ascii art in text files instead of directly in the code

You should switch to assembly

>multiple split-off adventures
You should probably look into the state machine design pattern.

lol why?

if `stand` is a std::string you would want the if statement to read
if (stand == "stand") {

you can use function pointers to compartmentalize parts of your text adventure; it really helps but can be fairly complicated.
also store you ascii art in text files, it will be easier to write and faster than using endl so much (as if speed matters here)

it only ever worked when i typed in "stand" though, it did not work when i wrote anything else, it just produced the exact same outcome as typing in "stand".

just for semantics you should rename the stand variable to "player_choice" and you can reuse it later like so

std::string choose;
std::cin >> choose;
if (choose == "stand") {
//stand
}

std::cin >> choose;
if (choose == "sit") {
// sit
}

You mean store the drawings in .h files right?
I'm extremely new to coding and don't know about calling text files.

what does writing std:: before typing string or cin do that's different? does it make it more likely to work?

a simple way to read an entire text file to the console is like so
std::ifstream ascii_art ("local_art_file.txt");
if (ascii_art.is_open()) {
std::cout

when i try to make it std::cin >> choice == stand; it tells me that "stand" was not declared in this scope

when i can get stand to work it also works when i type anything else too (yesterday i got stand to equal stand and this happened but today its telling me stand is not declared in this scope).

i mean when i try to make choice equal stand it does not work and tells me its not declared in this scope but when i change choice to stand and make it equal stand it works (but still if i type anything else it also works)

you have to cin to a variable as one line
then on another line do
choice = stand;

see == stands for a comparison and returns true or false
and = stands for a declaration and returns nothing

you have to put quotes around stand, since your comparing a string variable to a string literal, like in my example;

if (choose == "stand") {
generally speaking a "literal" is data represented inside the code file, and varibles can change.
string literals are anyting with quotes around it; they'll usually be highlighted by your editor, which they are in your example image.

if your code looks like this
if (stand == stand) {
then of course this if statement will always evaluate to true, it's the same as asking "1 == 1".

I've written more about why this is the case, and how your running into a not declared error above.

OH SHI-- THNX

I understand you're asking about C++, but consider using a functionl language with proper tail calls for something like this. It really breaks up the work in a more helpful way. Lua meets this spec, and I'm sure others do (maybe Haskell?) but I can't think of any atm

as if someone this new is going to be writing tail calls

youtu.be/7uLzaKlZSQQ?t=348
You should be using switch statements. The CIA wants you to think they are the same as if then else but they are so much greater.