Post by doyleman on Jun 10, 2005 20:27:09 GMT -5
A few of you may know that I have started on C++, and yes, I still do it. Matter of fact, I almost have Rock Paper Scissors made on it
Now, that may look dumb or simple, but is it a pain to make.
//sample game
#include <iostream.h>
#include <conio>
#include <ctime.h>
int main ()
{
int a;
int b = rand()%3+1;
cout << "Rock(1), Paper(2), or Scissors(3)?" << endl;
cin >> a;
if (a == 1) // begin rock condition
{
if (b == 1)
{
cout << "Rock, Draw!" << endl;
getch ();
return 0;
}
if (b == 2)
{
cout << "Paper, You Lose!" << endl;
getch ();
return 0;
}
if (b == 3)
{
cout << "Scissors, You Win!" << endl;
}
getch ();
return 0;
} //end rock condition
if (a == 2) // begin paper condition
{
if (b == 1)
{
cout << "Rock, You Win!" << endl;
getch ();
return 0;
}
if (b == 2)
{
cout << "Paper, Draw!" << endl;
getch ();
return 0;
}
if (b == 3)
{
cout << "Scissors, You Lose!" << endl;
getch ();
return 0;
}
} //end paper condition
if (a == 3)// begin scissors condition
{
if (b == 1)
cout << "Rock, You lose!" << endl;
getch ();
return 0;
}
if (b == 2)
{
cout << "Paper, You Win!" << endl;
getch ();
return 0;
}
if (b == 3)
{
cout << "Scissors, Draw!" << endl;
getch ();
return 0;
}
}//end scissors condition
//end of project
Tell me if that looks easy, go ahead, tell me! Just kidding
Now, Ves, if you read this anytime, I'm having the same problem you have, and one more. the random number (b) always goes to 2 for some dumb reason, and when I enter in 3 (scissors), it does nothing. I was hoping you would know the problem
*BTW, I made the original source code in about 3 minutes, with only 2 errors on first check
EDIT:
I DID IT!!!!!! HAHAHA, I MADE ROCK PAPER SCISSORS!
sorry for the screaming, but am I happy as ever!
I looked at some stuff, asked around, and I was off by a hair on this source code. The real Scripting goes like so:
//sample game
#include <iostream.h>
#include <conio>
#include <ctime.h>
int main ()
{
int a;
srand(time(0));
int b = rand()%3+1;
cout << "Rock(1), Paper(2), or Scissors(3)?" << endl;
cin >> a;
if (a == 1) // begin rock condition
{
if (b == 1)
{
cout << "Rock, Draw!" << endl;
getch ();
return 0;
}
if (b == 2)
{
cout << "Paper, You Lose!" << endl;
getch ();
return 0;
}
if (b == 3)
{
cout << "Scissors, You Win!" << endl;
}
getch ();
return 0;
} //end rock condition
if (a == 2) // begin paper condition
{
if (b == 1)
{
cout << "Rock, You Win!" << endl;
getch ();
return 0;
}
if (b == 2)
{
cout << "Paper, Draw!" << endl;
getch ();
return 0;
}
if (b == 3)
{
cout << "Scissors, You Lose!" << endl;
getch ();
return 0;
}
} //end paper condition
if (a == 3)// begin scissors condition
{
if (b == 1)
{
cout << "Rock, You lose!" << endl;
getch ();
return 0;
}
if (b == 2)
{
cout << "Paper, You Win!" << endl;
getch ();
return 0;
}
if (b == 3)
{
cout << "Scissors, Draw!" << endl;
getch ();
return 0;
}
}
}//end scissors condition
//end of project
What is the difference you ask? one, I forgot a { at the beginning of the Scissors condition, and forgot 2 } because of that, and lastly, I forgot srand (time(0)), which makes it randomize each time it's open.
I feel so happy!!!!!!!!
now, its on to Tic Tac Toe!
Now, that may look dumb or simple, but is it a pain to make.
//sample game
#include <iostream.h>
#include <conio>
#include <ctime.h>
int main ()
{
int a;
int b = rand()%3+1;
cout << "Rock(1), Paper(2), or Scissors(3)?" << endl;
cin >> a;
if (a == 1) // begin rock condition
{
if (b == 1)
{
cout << "Rock, Draw!" << endl;
getch ();
return 0;
}
if (b == 2)
{
cout << "Paper, You Lose!" << endl;
getch ();
return 0;
}
if (b == 3)
{
cout << "Scissors, You Win!" << endl;
}
getch ();
return 0;
} //end rock condition
if (a == 2) // begin paper condition
{
if (b == 1)
{
cout << "Rock, You Win!" << endl;
getch ();
return 0;
}
if (b == 2)
{
cout << "Paper, Draw!" << endl;
getch ();
return 0;
}
if (b == 3)
{
cout << "Scissors, You Lose!" << endl;
getch ();
return 0;
}
} //end paper condition
if (a == 3)// begin scissors condition
{
if (b == 1)
cout << "Rock, You lose!" << endl;
getch ();
return 0;
}
if (b == 2)
{
cout << "Paper, You Win!" << endl;
getch ();
return 0;
}
if (b == 3)
{
cout << "Scissors, Draw!" << endl;
getch ();
return 0;
}
}//end scissors condition
//end of project
Tell me if that looks easy, go ahead, tell me! Just kidding
Now, Ves, if you read this anytime, I'm having the same problem you have, and one more. the random number (b) always goes to 2 for some dumb reason, and when I enter in 3 (scissors), it does nothing. I was hoping you would know the problem
*BTW, I made the original source code in about 3 minutes, with only 2 errors on first check
EDIT:
I DID IT!!!!!! HAHAHA, I MADE ROCK PAPER SCISSORS!
sorry for the screaming, but am I happy as ever!
I looked at some stuff, asked around, and I was off by a hair on this source code. The real Scripting goes like so:
//sample game
#include <iostream.h>
#include <conio>
#include <ctime.h>
int main ()
{
int a;
srand(time(0));
int b = rand()%3+1;
cout << "Rock(1), Paper(2), or Scissors(3)?" << endl;
cin >> a;
if (a == 1) // begin rock condition
{
if (b == 1)
{
cout << "Rock, Draw!" << endl;
getch ();
return 0;
}
if (b == 2)
{
cout << "Paper, You Lose!" << endl;
getch ();
return 0;
}
if (b == 3)
{
cout << "Scissors, You Win!" << endl;
}
getch ();
return 0;
} //end rock condition
if (a == 2) // begin paper condition
{
if (b == 1)
{
cout << "Rock, You Win!" << endl;
getch ();
return 0;
}
if (b == 2)
{
cout << "Paper, Draw!" << endl;
getch ();
return 0;
}
if (b == 3)
{
cout << "Scissors, You Lose!" << endl;
getch ();
return 0;
}
} //end paper condition
if (a == 3)// begin scissors condition
{
if (b == 1)
{
cout << "Rock, You lose!" << endl;
getch ();
return 0;
}
if (b == 2)
{
cout << "Paper, You Win!" << endl;
getch ();
return 0;
}
if (b == 3)
{
cout << "Scissors, Draw!" << endl;
getch ();
return 0;
}
}
}//end scissors condition
//end of project
What is the difference you ask? one, I forgot a { at the beginning of the Scissors condition, and forgot 2 } because of that, and lastly, I forgot srand (time(0)), which makes it randomize each time it's open.
I feel so happy!!!!!!!!
now, its on to Tic Tac Toe!