This is supposed to be a Rock-Paper-Scissors game. Everything's just going fine until I inserted graphics. What I was supposed to do is to display the figures I've poorly made whenever a choice is made. I can't really explain it so please take a look at my code, thanks (I'm hoping for a kind response.)
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<time.h>
#include<graphics.h>
void input()
{
int choice, b, c, i, Cscore=0, Pscore=0;
srand(time(NULL));
gotoxy (20,1);
textcolor ( GREEN );
cprintf("- - - - - - - - - - - - - - - - - - - - - - - ");
gotoxy (38,2);
printf("PLAYER\n\n\n");
gotoxy (33,3);
printf("Enter your input.\n\n\n");
gotoxy (23,4);
printf("Please input the number and press Enter:\n");
gotoxy (23,5);
textcolor (BLUE);
cprintf("****************************************");
gotoxy (23,6);
textcolor (YELLOW);
cprintf("1 - Rock 2 - Paper 3 - Scissors\n\n\n");
gotoxy (20,7);
textcolor (GREEN);
cprintf("- - - - - - - - - - - - - - - - - - - - - - - ");
for (i=0;i<5;i++)
{
gotoxy (33,8);
printf("Your input is: ");
scanf("%d", &choice);
system("CLS");
int computer=rand()%3+1;
if(choice==1)
{
int gd=DETECT,gm,points[]={135,350,135,300,125,270,125,240,175,230,185,250,175,300,175,350,135,350};
initgraph(&gd, &gm, "C:\\TC\\BGI");
fillpoly(9, points);
if(computer==1)
{
printf("\t\t\tComputer picked (1) Rock.\n");
printf("\n\t\t\tDraw.\n");
printf("\n\t\t\tPlayer Score: %d\n",Pscore);
printf("\n\t\t\tComputer Score: %d\n\n\n",Cscore);
int gd=DETECT,gm,points[]={535,350,535,300,525,270,525,240,575,230,585,250,575,300,575,350,535,350};
initgraph(&gd, &gm, "C:\\TC\\BGI");
fillpoly(9, points);
}
if(computer==2)
{
printf("\t\t\tComputer picked (2) Paper.\n");
printf("\n\t\t\tComputer Wins!\n");
Cscore= Cscore + 1;
printf("\n\t\t\tPlayer Score: %d\n",Pscore);
printf("\n\t\t\tComputer Score: %d\n\n\n",Cscore);
int gd=DETECT,gm,points[]={535,350,535,300,520,270,520,205,530,205,530,240,535,240,535,150,545,150,545,240,550,240,550,147,560,147,560,240,565,240,565,150,575,150,575,260,580,260,580,210,590,210,590,270,575,300,575,350,530,350};
initgraph(&gd, &gm, "C:\\TC\\BGI");
fillpoly(25, points);
}
if(computer==3)
{
printf("\t\t\tComputer picked (3) Scissors.\n");
printf("\n\t\t\tPlayer Wins!\n");
Pscore = Pscore + 1;
printf("\n\t\t\tPlayer Score: %d\n",Pscore);
printf("\n\t\t\tComputer Score: %d\n\n\n",Cscore);
int gd=DETECT,gm,points[]={535,350,535,300,520,270,520,240,530,240,530,235,540,235,540,145,553,145,553,230,560,230,560,148,573,148,573,235,590,260,575,300,575,350,530,350};
initgraph(&gd, &gm, "C:\\TC\\BGI");
fillpoly(18, points);
}
}
else if(choice==2)
{
int gd=DETECT,gm,points[]={135,350,135,300,120,270,120,205,130,205,130,240,135,240,135,150,145,150,145,240,150,240,150,147,160,147,160,240,165,240,165,150,175,150,175,260,180,260,180,210,190,210,190,270,175,300,175,350,130,350};
initgraph(&gd, &gm, "C:\\TC\\BGI");
fillpoly(25, points);
if(computer==2)
{
printf("\t\t\tComputer picked (2) Paper.\n");
printf("\n\t\t\tDraw.\n");
printf("\n\t\t\tPlayer Score: %d\n",Pscore);
printf("\n\t\t\tComputer Score: %d\n\n\n",Cscore);
}
if(computer==3)
{
printf("\t\t\tComputer picked (3) Scissors.\n");
printf("\n\t\t\tPlayer Wins!\n");
Pscore = Pscore + 1;
printf("\n\t\t\tPlayer Score: %d\n",Pscore);
printf("\n\t\t\tComputer Score: %d\n\n\n",Cscore);
}
if(computer==1)
{
printf("\t\t\tComputer picked (1) Rock.\n");
printf("\n\t\t\tComputer Wins!\n");
Cscore= Cscore + 1;
printf("\n\t\t\tPlayer Score: %d\n",Pscore);
printf("\n\t\t\tComputer Score: %d\n\n\n",Cscore);
}
}
else if(choice==3)
{
int gd=DETECT,gm,points[]={135,350,135,300,120,270,120,240,130,240,130,235,140,235,140,145,153,145,153,230,160,230,160,148,173,148,173,235,190,260,175,300,175,350,130,350};
initgraph(&gd, &gm, "C:\\TC\\BGI");
fillpoly(18, points);
if(computer==3)
{
printf("\t\t\tComputer picked (3) Scissors.\n");
printf("\n\t\t\tDraw.\n");
printf("\n\t\t\tPlayer Score: %d\n",Pscore);
printf("\n\t\t\tComputer Score: %d\n\n\n",Cscore);
}
if(computer==2)
{
printf("\t\t\tComputer picked (2) Paper.\n");
printf("\n\t\t\tComputer Wins!\n");
Cscore= Cscore + 1;
printf("\n\t\t\tPlayer Score: %d\n",Pscore);
printf("\n\t\t\tScore is %d\n\n\n",Cscore);
}
if(computer==1)
{
printf("\t\t\t\tComputer picked (1) Rock.\n");
printf("\n\t\t\tPlayer Wins!\n");
Pscore = Pscore + 1;
printf("\n\t\t\tPlayer Score: %d\n",Pscore);
printf("\n\t\t\tComputer Score: %d\n\n\n",Cscore);
}
}
else{
printf("\t\t\tWrong Answer.\n\n\n");
}
}
if(Cscore > Pscore)
{
printf("\t\t\tComputer wins %d to %d.\n",Cscore,Pscore);
}
else if(Cscore < Pscore )
{
printf("\t\t\tPlayer wins %d to %d.\n",Pscore,Cscore);
}
else if(Cscore == Pscore )
{
printf("\t\t\tNo winner, it is a draw!\n");
}
getch();
}
main(void)
{
clrscr();
char x,y,flag = 'p';
gotoxy(12,1);
printf("This is a game called Jack-en-poy or Rock, Paper, Scissors\n");
gotoxy(20,2);
printf("You are going to play against the computer.\n");
gotoxy(25,3);
printf("Press any key to continue. . .");
getch();
system("CLS");
do{
system("CLS");
input();
system("CLS");
printf("Press any key to exit:\n\nTo play again, press P\n\n");
flag = getch();
} while (flag == 'p');
system("CLS");
printf("Program Terminating. . .");
getch();
return(0);
}