I made my first game

Started by
6 comments, last by NoWhereMan 19 years, 6 months ago
I've finished my first game here it is but it always says you lose

//game of rock paper sissors

#include<iostream>
#include<cstdlib>
#include<ctime>


using namespace std;
int main()
{
const int rock=1;
const int paper=2;
const int sissors=3;

    srand(time(0));//seed the random generater
    int mychoice = 1;
        cout<<"enter rock1,paper2 or sissors3";
                cin>>mychoice;
    int choice = rand()%3,Oput; 
        if((mychoice == rock) && (choice == paper))
    {
    cout<<"\nyou lose";
    }
        if((mychoice == paper) && (choice == rock))
    {
    cout<<"\nyou win";
     }   
        if((mychoice == sissors) && (choice == rock))
    {
    cout<<"\nyou lose";
     }  
         if((mychoice == rock) && (choice == sissors))
    {
    cout<<"\nyou win";
     }   
        if((mychoice == paper) && (choice == sissors))
    {
    cout<<"\nyou lose";
     }   
        if((mychoice == sissors) && (choice == paper))
    {
    cout<<"\nyou win";
     }  
       if((mychoice == sissors) && (choice == paper))
    {
    cout<<"\ntie";
     }   
        if((mychoice == paper) && ( choice == paper))
    {
    cout<<"\ntie";
     }  
         if((mychoice == rock) &&(choice == rock))
    {
    cout<<"\ntie";
    }
    cin>>Oput;
    return 0;
}

-----------------------------------Panic and anxiety Disorder HQ
Advertisement
Nice. It works fine for me, maybe you're just unlucky
maybe you just suck at rock, paper, sissors

You should output your pick and the computer's pick so you can check its answer.
Congrats!
One thing:

int choice = rand()%3,Oput;

should read
int choice = rand()%3+1,Oput;


Thermo
I'm sure because I have the worst luck in the world:(
-----------------------------------Panic and anxiety Disorder HQ
Thanks Konfusius it works perfect now:).
-----------------------------------Panic and anxiety Disorder HQ
I am a winner!
Rate me up.
Quote:Original post by hothead
I'm sure because I have the worst luck in the world:(


#include <iostream>#include <cstdlib>using namespace std;int main(){  string vegas;  cout << "Ever gone to Vegas?" << endl << endl;  cout << "> Yes" << endl;  cout << "> No" << endl << endl;  cout << "> ";  cin >> vegas;    if (vegas == "Yes")    {            system("cls");      cout << "You poor person, but no really, how did you do?" << endl << endl;      system("PAUSE");        }    if (vegas == "No")    {            system("cls");      cout << "Don't plan on going!" << endl << endl;      system("PAUSE");    }  return 0;}
_______________________________________________________________________________________He's a real no where man, sitting in his no where land, making all his no where plans for nobody...

This topic is closed to new replies.

Advertisement