Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 11th, 2007, 10:18 PM   #21
PaCkEtPiRaTe
Newbie
 
Join Date: Aug 2007
Posts: 24
Rep Power: 0 PaCkEtPiRaTe is on a distinguished road
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.
PaCkEtPiRaTe is offline   Reply With Quote
Old Aug 12th, 2007, 2:33 AM   #22
peaceofpi
hi: for(;;) goto hi;
 
peaceofpi's Avatar
 
Join Date: Jun 2006
Posts: 87
Rep Power: 3 peaceofpi is on a distinguished road
Send a message via AIM to peaceofpi Send a message via MSN to peaceofpi
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.
peaceofpi is offline   Reply With Quote
Old Aug 12th, 2007, 8:18 PM   #23
PaCkEtPiRaTe
Newbie
 
Join Date: Aug 2007
Posts: 24
Rep Power: 0 PaCkEtPiRaTe is on a distinguished road
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();
}
}
}
PaCkEtPiRaTe is offline   Reply With Quote
Old Aug 12th, 2007, 8:45 PM   #24
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 843
Rep Power: 3 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
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.)
titaniumdecoy is offline   Reply With Quote
Old Aug 13th, 2007, 12:18 AM   #25
peaceofpi
hi: for(;;) goto hi;
 
peaceofpi's Avatar
 
Join Date: Jun 2006
Posts: 87
Rep Power: 3 peaceofpi is on a distinguished road
Send a message via AIM to peaceofpi Send a message via MSN to peaceofpi
You are aware that each welcome(); says this, right?

Quote:
Days of Legend: The Video Game


Copyright© 2007-2012 Crimson Games. All rights reserved.
--------------------------------------------------------------------------------
That'll get more annoying each time you call it.

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.
peaceofpi is offline   Reply With Quote
Old Aug 13th, 2007, 12:39 AM   #26
PaCkEtPiRaTe
Newbie
 
Join Date: Aug 2007
Posts: 24
Rep Power: 0 PaCkEtPiRaTe is on a distinguished road
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.
PaCkEtPiRaTe is offline   Reply With Quote
Old Aug 13th, 2007, 7:08 AM   #27
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Old Aug 13th, 2007, 7:25 AM   #28
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 1,010
Rep Power: 5 lectricpharaoh will become famous soon enough
Quote:
Originally Posted by DaWei
Copyright 2012? You must be in one hellacious time zone.
Heh. I noticed that too, but decided not to point it out unless he finished his game before 2012. Let's see if he gets it done in the next five years.
__________________
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
lectricpharaoh is offline   Reply With Quote
Old Aug 13th, 2007, 11:26 AM   #29
PaCkEtPiRaTe
Newbie
 
Join Date: Aug 2007
Posts: 24
Rep Power: 0 PaCkEtPiRaTe is on a distinguished road
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
PaCkEtPiRaTe is offline   Reply With Quote
Old Aug 13th, 2007, 9:41 PM   #30
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 1,010
Rep Power: 5 lectricpharaoh will become famous soon enough
Quote:
Originally Posted by PaCkEtPiRaTe
That's not what the copyright means lol... It's a fake copyright to prevent distribution of the code...
Call me psychic, but somehow I don't think that's going to be an issue.
__________________
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
lectricpharaoh is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:05 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC