Paper Scissors Rock v0.1

This is a discussion on Paper Scissors Rock v0.1 within the Game Programming forums, part of the General Programming Boards category; I finally have enough knowledge to put together simple games. I made this program last night. the random method is ...

  1. #1
    Registered User Kirdra's Avatar
    Join Date
    Aug 2002
    Posts
    105

    Paper Scissors Rock v0.1

    I finally have enough knowledge to put together simple games.

    I made this program last night. the random method is working nicely with the RPG I am working on. anyway here is the code hope I am doing the code tacs right :P

    Code:
    #include <conio.h>
    #include <iostream>
    #include <stdlib.h>
    #include <ctime>                   
    
    int User_Score, Comp_Score;         
    int User_Option, Comp_Option;       
    
    char name[15];                      
    int Q = 0;                          
    
    int RandInt(int a,int b)            
    {
       return a + rand() % (b - a + 1);
    }
    
    int main()
    
    {
        
    
    cout << "Paper/Scissor/Rock 0.1\n\n"; 
    cout << "Please enter name: ";                      
    
    cin >> name;                                 
    
    cout << "\n";                
                                                                                        
    do
    
    {
    
    srand(time(NULL));                  
    int x = RandInt(1,3);                
    system("pause");                    
    system("cls");                       
    
    cout << "Scoreboard:\t\t     Q-uit\n\n"<<name<<": "<<User_Score;
    cout << "\nComputer: "<<Comp_Score<<"\n\n"; 
    
    cout << "Please select one of the following:\n\n";
    
    cout << "1)Paper\n2)Scissors\n3)Rock\n\n";  
    
    cin >> User_Option; 
    cout << "\n";
    
    Comp_Option = x;   //Assigning Comp_Options value as x, the value of x
                       //changes between 1 and 3 every loop
                    
    //Here are all the possible out comes, relevant messages and variable updates
    
    if(User_Option == 1 && Comp_Option == 1)
    {
        cout << "This round is a draw.\n";
    }
    
    else if(User_Option == 1 && Comp_Option == 2)
    {
        cout << "You lose try again.\n";
        Comp_Score++;
    }
    
    else if(User_Option == 1 && Comp_Option == 3)
    {
        cout << "Congratulations you win.\n";
        User_Score++;
    }
    
    else if(User_Option == 2 && Comp_Option == 1)
    {
        cout << "Congratulations you win.\n";
        User_Score++;
    }
    
    else if(User_Option == 2 && Comp_Option == 2)
    {
        cout << "This round is a draw.\n";
    }
    
    else if(User_Option == 2 && Comp_Option == 3)
    {
        cout << "You lose try again.\n";
        Comp_Score++;
    }
    
    else if(User_Option == 3 && Comp_Option == 1)
    {
        cout << "You lose try again.\n";
        Comp_Score++;
    }
    
    else if(User_Option == 3 && Comp_Option == 2)
    {
        cout << "Congratulations you win.\n";
        User_Score++;
    }
    
    else if(User_Option == 3 && Comp_Option == 3)
    {
        cout << "This round is a draw.\n";
    }
    
    else if(User_Option == Q)
    {
    Q = 1;
    }
    
    else
    {
        cout << "Invaild input.\n";
    }
    
    }    //End Do
    
    while(Q != 1);    //The loop breaks
    
        system("cls");              //Take the ingame data off
        cout << "Goodbye\n\n";      
        system("pause");            //Pause so Goodbye msg is viewable
        return 0;                    
    }            //End Int main()
    Tell me what you think, it's my first "complete" game.

    sorry I could get the file up on the net I am having probs with my comp.
    Last edited by Kirdra; 09-14-2002 at 11:36 AM.

  2. #2
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    note the "edit" button on the bottom of your posts...you didn't need to post that twice (:
    Away.

  3. #3
    Registered User Kirdra's Avatar
    Join Date
    Aug 2002
    Posts
    105
    Sorry about that, I am still "learning" things on this board. hehe.

    btw. Feel free to use this and any code I post in your own programs. I am still learning C++, I bet there are lots of bugs or messy code in this program but I think the outcome is quite good.
    Last edited by Kirdra; 09-14-2002 at 11:42 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. rock paper Scissors
    By jackstify in forum C++ Programming
    Replies: 3
    Last Post: 12-14-2007, 09:16 PM
  2. need help with rock paper scissors program
    By Mshock in forum C Programming
    Replies: 3
    Last Post: 04-22-2006, 07:44 AM
  3. Another rock paper scissor question
    By mattflick in forum C Programming
    Replies: 11
    Last Post: 09-29-2005, 09:41 PM
  4. PRS Help
    By SpudNuts in forum C Programming
    Replies: 10
    Last Post: 08-07-2005, 01:14 PM

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