WebArtz - The Web Design Forum
Welcome to WebArtz, Guest!

WebArtz is a nice place for discussions related to web designing and coding. We help our members to code their own website templates with HTML and CSS. We give them advice on various issues.

To know more about WebArtz Forum, visit the About Us page.

At the moment, you are viewing the forum as a guest. As a guest you can't make post and participate in discussions. You need to register and become a member of the forum. Click the register link below and become a part of this forum.

Thank You


You are not connected. Please login or register

View previous topic View next topic Go down  Message [Page 1 of 1]

1 Anyone here know C++? on Fri Sep 30, 2011 11:04 pm

Bla125


Registered Member
Registered Member
I'm making a text based game right now for my first game and need some help with a problem I have run into. It asks the player to type a number to pick a choice from the list above according to the situation presented and that all works. BUT, it shows the number that they typed in in the answer that they gave when it's not supposed to. Anyone able to help me with this? Smile

Spoiler:
int main()
{
int choice;

cout << "This is the introduction \n";
cout << "other parts of the introduction \n\n";

cout << "Instructions \n";
cout << "instructions continued \n\n";

cout << "Present situation to player \n";

cout << "Present choices to player \n";
cout << "1 \n";
cout << "2 \n";
cout << "3 \n";

cout << "Players choice? ";
cin >> choice;
cout << "\nPlayers choice \n" << choice;

if (choice == 1)
{
cout << "Shows the outcome of the players choice 1 \n"; //It shows the number 1 before "shows" in this statement.
}

else if (choice == 2)
{
cout << "Shows the outcome of the players choice 2 \n";
}

else if (choice == 3)
{
cout << "Shows the outcome of the players choice 3 \n";
}

else
{
return (0);
}

getchar();
getchar();
return 0;

2 Re: Anyone here know C++? on Sat Oct 01, 2011 12:06 am

Bla125


Registered Member
Registered Member
Nevermind! I got it! Very Happy

3 Re: Anyone here know C++? on Sat Oct 01, 2011 12:19 am

ankillien

avatar
Administrator
Administrator
Thats great! Btw, whats the game about?

4 Re: Anyone here know C++? on Sat Oct 01, 2011 3:04 am

Fatal Dawn


Registered Member
Registered Member
Some games you can customize if you know about coding and programming. In Little Fighter 2, fans rip apart the data files to create new chars, backgrounds, etc.

5 Re: Anyone here know C++? on Sat Oct 01, 2011 4:51 am

Bla125


Registered Member
Registered Member
I haven't made a storyline or anything yet, I'm just focusing on getting the code down first. Then I'm gonna go back and put in the story and what not. I honestly have no clue of what it's going to be about though.

And it's just gonna be a text based game you aren't going to be able to control character or anything. Kind of like Zork.

Sponsored content


View previous topic View next topic Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum