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");
}