![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#21 |
|
Newbie
Join Date: Aug 2007
Posts: 24
Rep Power: 0
![]() |
I FIXED IT!
The problem was the word yes had to be in quotes in the if ready statement... I feel really stupid now... Last edited by PaCkEtPiRaTe; Aug 11th, 2007 at 10:41 PM. |
|
|
|
|
|
#22 |
|
hi: for(;;) goto hi;
|
Let's see what's wrong (using your newest brilliant quote discovery) so you won't leave this topic and end up half-satisfied
#include <iostream>
#include <string.h> // use <string>, this is c++
//Days of Legend. Programmed by Darin Beaudreau.
//Copyright© 2007-2012. All rights reserved.
//This code may not be redistributed.
using namespace std; // not recommended but that's the least of your problems
int main()
{
while(1)
{
string playername; // don't make new variables in a while loop, easy problem creation
string playerrace;
string playerclass;
int Yes = 1; // what the fuck is this
int No = 2; // and this
int status; // <-- never used
string ready; // <-- needs to be string if you want "yes" instead of 1
int menuchoice;
//Opening
cout << "\aHello there, what is your name? ";
getline (cin, playername);
cout << endl;
cout << "Hello, " << playername << "!\n";
cout << "\aWhat race will you play? ";
getline (cin, playerrace);
cout << "\aAnd what class shall you play, brave adventurer? ";
getline (cin, playerclass);
cout << "\aYou have chosen to be a " << playerrace << " " << playerclass << "!\n";
cout << "Welcome, " << playername << " to Days of Legend!\n";
cout << "\aIn a world filled with evil, will you take up your\n";
cout << "sword and defend the innocent? ";
cin >> ready;
if (ready == "Yes" || ready == "yes")
{ // added OR for a hint
cout << "Then welcome to Narghoz, the first town in your\n";
// too many newlines make me sad
cout << "no doubt epic adventure!\n\n";
cout << "What would you like to do, " << playername << "?\n";
cout << "1.) Check Status\n";
cout << "2.) Quit\n";
cout << "Make your choice! ";
cin >> menuchoice;
}
if (ready == "No" || ready == "no") // "else if"
{
cout << "Then come back when you have some hair on your chest!\n";
return 0;
}
// "else" if they screw up
}
system ("PAUSE"); // <-- make portable unless this is windows only
return 0; // <-- does not exist in your code
}
__________________
How do you play Religious Roulette? Stand around in a circle and blaspheme till someone gets struck by lightning. Last edited by peaceofpi; Aug 12th, 2007 at 2:47 AM. |
|
|
|
|
|
#23 |
|
Newbie
Join Date: Aug 2007
Posts: 24
Rep Power: 0
![]() |
I recoded it using voids and such to make it look better and so the code is more efficient... what does everyone think?
#include <iostream>
#include <string.h>
//Days of Legend. Programmed by Darin Beaudreau.
//Copyright© 2007-2012. All rights reserved.
//This code may not be redistributed.
using namespace std;
//GLOBAL VARIABLES
string playername;
string playerrace;
string playerclass;
//string status;
int check = 1;
int choice;
int ready;
int ex = 1;
int playerlevel = 1;
int playermoney = 100;
void welcome()
{
cout << "Days of Legend: The Video Game\n\n";
cout << "Copyright© 2007-2012 Crimson Games. All rights reserved.\n";
cout << "--------------------------------------------------------------------------------\n";
}
void create()
{
system("CLS");
welcome();
cout << "Welcome to Days of Legend, brave adventurer!\n";
cout << "What name will you go by?\n";
cout << "> ";
getline (cin,playername);
system("CLS");
welcome();
cout << "What race are you, " << playername << "?\n";
cout << "> ";
getline (cin,playerrace);
system("CLS");
welcome();
cout << "And what class are you, " << playername << "?\n";
cout << "> ";
getline (cin,playerclass);
system("CLS");
welcome();
cout << "Enjoy the game!\n";
system("PAUSE");
check = 0;
}
void mainmenu()
{
system("CLS");
welcome();
cout << "What would you prefer to do?\n1.) Check Status\n2.) Exit Game\n\n";
cout << "> ";
cin >> choice;
if (choice == 1)
{
system("CLS");
welcome();
cout << "Name: " << playername << "\n";
cout << "Race: " << playerrace << "\n";
cout << "Class: " << playerclass << "\n";
cout << "Level: " << playerlevel << "\n";
cout << "Gold: " << playermoney << "\n";
system("PAUSE");
mainmenu();
}
if (choice == 2)
{
system("CLS");
welcome();
cout << "Thank you for playing Days of Legend, good bye.\n";
system("PAUSE");
ex = 2;
}
}
int main()
{
while (ex == 1)
{
system("CLS");
welcome();
if (check == 1)
{
create();
}
else
{
mainmenu();
}
}
} |
|
|
|
|
|
#24 |
|
Expert Programmer
|
By "voids" you mean functions. Functions do not make your code more efficient, only better organized. (In fact, functions make your code the slightest bit less efficient.)
|
|
|
|
|
|
#25 | |
|
hi: for(;;) goto hi;
|
You are aware that each welcome(); says this, right?
Quote:
more stuff: * none of the system() calls are portable * in mainmenu() you're calling the function from inside itself, that's a hint that you need to redo it * making EVERYTHING a function makes you too reliant on them, you'll get lost in your code when debugging * you really need a source code formatter, even the CODE tags aren't helping you. try cbeauty.
__________________
How do you play Religious Roulette? Stand around in a circle and blaspheme till someone gets struck by lightning. |
|
|
|
|
|
|
#26 |
|
Newbie
Join Date: Aug 2007
Posts: 24
Rep Power: 0
![]() |
Yes I'm aware that it calls welcome(); each time. That's how I intended it... Also... functions make it a lot easier for me to understand my code.
|
|
|
|
|
|
#27 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Copyright 2012? You must be in one hellacious time zone.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#28 | |
|
Caffeinated Neural Net
![]() Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 1,010
Rep Power: 5
![]() |
Quote:
![]()
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot. - Vaarsuvius, Order of the Stick |
|
|
|
|
|
|
#29 |
|
Newbie
Join Date: Aug 2007
Posts: 24
Rep Power: 0
![]() |
That's not what the copyright means lol... It's a fake copyright to prevent distribution of the code... Though I suppose posting it here would defeat the purpose o_O
|
|
|
|
|
|
#30 | |
|
Caffeinated Neural Net
![]() Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 1,010
Rep Power: 5
![]() |
Quote:
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot. - Vaarsuvius, Order of the Stick |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| What is wrong with this code? | c0ldshadow | Visual Basic .NET | 5 | Dec 5th, 2005 5:37 PM |
| How to post a question | nnxion | C++ | 10 | Jun 3rd, 2005 11:53 AM |
| How to post a question | nnxion | C++ | 0 | Jun 3rd, 2005 8:55 AM |
| How to post a question | nnxion | C | 0 | Jun 3rd, 2005 8:55 AM |
| Any ideas what i've done wrong? (Newb C Programmer) Code included | Ramlag | C++ | 10 | Mar 22nd, 2005 1:57 PM |