Help again...

This is a discussion on Help again... within the C++ Programming forums, part of the General Programming Boards category; I made my first game! It works!! It is fun!!! Because it is all those things (in my oppinion=) I ...

  1. #1
    Registered User
    Join Date
    May 2007
    Posts
    21

    Exclamation Help again...

    I made my first game! It works!! It is fun!!! Because it is all those things (in my oppinion=) I want it to be a downloadable game that everyone can play. How do I do that? If you want to play it as it is now you will have to copy, paste, build, compile, etc etc. Not only that but I also want to add a new thing to it but I don't know how. I want to make it to where they can sign up on another program. and in this one they login and this way i can show them how many games they have one, lost, and total played. If i were to do this I would have to be able to have more than one login account. If you can help me with either of my problems I would be very happy and grateful.

    Here is the code
    NOTE: it is a noob's code... so don't laugh...... plz(por favor)lol
    Code:
    #include <iostream>
    #include <time.h>
    using namespace std;
    
    void rules();
    void play();
    int playagain;
    
    int main()
    {
    	int x;
    
    	cout<<"Welcome to Devon's wonderful \"Guess a Number\" game!\n";
    	cout<<"If you need to read the rules enter a \"1\", if you want to\nhead straight into the action enter a \"2\".\n";
    	cin>>x;
    	switch(x)
    	{
    		case 1:
    			rules();
    			break;
    		case 2:
    			play();
    			break;
    		default:
    			cout<<"Sorry, invalid input";
    			break;
    	}
    }
    void rules()
    {
    	cout<<"The rules are simple: \n";
    	cout<<"1. Guess any number\n";
    	cout<<"2. If it is correct, you win!\n";
    	cout<<"3. But if it is wrong... you get 9 more tries (10 in all).\n";
    	cout<<"Now that you understand the rules, press any key to continue to the game.\n\n\n";
    	system("PAUSE");
    	play();
    }
    void play()
    {
    	do
    	{
    	srand ( time(NULL) );
    	int guess, guesscount, number = 0;
    	int guesscount2 = 10;
    	number = rand() % 99 + 1;
    
    	for(guesscount = 0; guesscount < 10; guesscount++)
    	{
    	cout<<"Enter a number (1-100): ";
    	while ( ! (cin>>guess)) 
    { 
    	guesscount=guesscount+1;
    cin.clear(); 
    cin.ignore (80, '\n');
    	if(guesscount == 10)
    	{
    		break;
    	}
    cout << "Sorry, entry was not a number. Try again: ";
    }
    	if(guess < number && guesscount < 10)
    	{
    		cout<<"Sorry your number is too LOW.\n";
    	}
    	if(guess > number && guesscount < 10)
    	{
    		cout<<"Sorry your number is too HIGH.\n";
    	}
    	if(guess == number && guesscount < 10)
    	{
    		guesscount++;
    		cout<<"Congratulations, you got it right in only "<<guesscount<<" tries!\n";
    		break;
    	}
    	guesscount2=guesscount2 - 1;
    	if(guesscount == 10)
    	{
    		cout<<"Sorry you are out of tries\n";
    		break;
    	}
    	}
    	cout<<"Sorry, you lose.";
    	cout<<"Wanna play again? (\"1\" for yes, and a \"2\" to leave) ";
    	cin>>playagain;
    	system("cls");
    	}
    	while(playagain == 1);
    	system("PAUSE");
    }

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    If you want a web-based type of program, in general you'd probably be better off using a more web-appropriate language.

    Otherwise, you could compile it yourself, release only the .exe for people to download and play. You could store the results of every round to a file. If you want the results accessible to you, the game could upload the results to a database.

    Since you wish players to login, that sounds like you want a web-based project, although it could be done here, I suppose, even though it looks like overkill.

  3. #3
    Registered User
    Join Date
    May 2007
    Posts
    21
    How would I go about doing any of that? I don't know how to save as .exe, or make it web based...

    (I am noob)
    thanks in advanced

  4. #4
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    The stuff on web-based languages is outside the scope of these forums.

    I assumed you are programming on Windows, which should be a safe bet due to how you're using system(). When you compile a project, there should be an .exe file generated where you saved your project. That is your program in binary form that the computer can understand and execute. Unless your program has various dependencies (ie. dlls, or required files), you can release that by itself and it should work for many Windows users.

  5. #5
    Registered User
    Join Date
    May 2007
    Posts
    21
    How would I post it? I can't "Attach" it.
    Oh and I did find it in the debug section of the project folder.

  6. #6
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Well on here it's kind of pointless since most of us can compile anyway. I was referring if you wanted to release the program to people elsewhere, like on a website you might own.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21