Browse Source

Started RockPaperScissors

main
fdlt3859 2 years ago
parent
commit
8d8d21181b
  1. 77
      src/main/quizproject.c
  2. 4
      src/main/quizproject.h

77
src/main/quizproject.c

@ -1787,6 +1787,76 @@ void b_epic_game() {
B_write_review();
}
void v_play_rockpapersciss(){
int player_choice, computer_choice, player_score = 0, computer_score = 0;
srand(time(NULL));
while (1)
{
printf("Enter your choice:\n");
printf("1. Rock\n2. Paper\n3. Scissors\n");
printf("Your Choice:");
scanf("%d", &player_choice);
computer_choice = (rand() % 3) + 1;
if (player_choice == ROCK)
{
if (computer_choice == ROCK)
{
printf("Tie! Both picked Rock\n");
}
else if (computer_choice == PAPER)
{
printf("You lose! Computer picked Paper\n");
computer_score++;
}
else
{
printf("You win! Computer picked Scissors\n");
player_score++;
}
}
else if (player_choice == PAPER)
{
if (computer_choice == ROCK)
{
printf("You win! Computer picked Rock\n");
player_score++;
}
else if (computer_choice == PAPER)
{
printf("Tie! Both picked Paper\n");
}
else
{
printf("You lose! Computer picked Scissors\n");
computer_score++;
}
}
else if (player_choice == SCISSORS)
{
if (computer_choice == ROCK)
{
printf("You lose! Computer picked Rock\n");
computer_score++;
}
else if (computer_choice == PAPER)
{
printf("You win! Computer picked Paper\n");
player_score++;
}
else
{
printf("Tie! Both picked Scissors\n");
}
}
else
{
printf("Invalid choice!\n");
}
}
}
void feedbackForm(void){
@ -1881,7 +1951,8 @@ int main(int argc, char *argv[]) {
printf("5. Guess the Word!\n");
printf("6. Smart Brain\n");
printf("7. Epic Game\n");
printf("8. Exit\n");
printf("8. Rock,Paper,Scissors!\n");
printf("9. Exit\n");
printf("Enter your choice: ");
scanf("%d", &choice);
v_progress_bar(argc,argv);
@ -1916,6 +1987,10 @@ int main(int argc, char *argv[]) {
jump_to_menu = 1;
break;
case 8:
v_play_rockpapersciss();
jump_to_menu = 1;
break;
case 9:
printf("\nThank you for trying our C code!\n");
break;
default:

4
src/main/quizproject.h

@ -30,6 +30,7 @@ void v_guessingGame(void);
void v_guessTheWord(char word[], char guessed[]);
void progress_bar(int percentage);
void v_progress_bar(int argc, char *argv[]);
void v_play_rockpapersciss(void);
void million_instructions();
void million_exit(int million_a);
@ -82,5 +83,8 @@ void B_write_review(void);
#define round 15
#define MAX_LIVES 10
#define MAX_WORD_LENGTH 20
#define ROCK 1
#define PAPER 2
#define SCISSORS 3
#endif
Loading…
Cancel
Save