#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <graphics.h>
int one = 0;
int two = 0;
int three = 0;
int S = 0;
int B = 0;
int score = 0;
int total = 0;
void MOVE(int x, int imsiy, char* msg)
{
int q = 1;
while(q){
int yy = getmaxy();
outtextxy(x, imsiy, msg);
imsiy--;
if(imsiy == 12){
while(imsiy!=yy){
imsiy++;
outtextxy(x, imsiy, msg);
if(imsiy == yy-10){
imsi y=yy;
getch();
}
if(imsiy %2){
cleardevice();
}
}
q = 0;
}
if(imsiy %4){
cleardevice();
}
}
}
void TITLE()
{
int x = 0, y = 0;
int i = 2;
char msg[80];
char choose[80];
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
/* initialize graphics and local variables */
initgraph(&gdriver;, &gmode;, "");
/* read result of initialization */
errorcode = graphresult();
if (errorcode!= grOk ) /* an error occurred */
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
}
setbkcolor(2);
setcolor(15);
y = getmaxy() / 2;
settextjustify(CENTER_TEXT, CENTER_TEXT);
settextstyle(TRIPLEX_FONT, HORIZ_DIR, i);
/* create a message string ;number is size */
sprintf(msg, "BASEBALL VOL 1.1", 9);
sprintf(choose, "^^;");
x = getmaxx() /2;
y = getmaxy() /2;
int imsiy = y;
/* output the message */
MOVE(x,imsiy,msg);
getch();
cleardevice();
outtextxy(x, y, msg);
outtextxy(x, y+20, choose);
/* advance to the end of the text */
x += textwidth(msg);
/* clean up */
getch();
closegraph();
return;
}
void getnumber()
{
randomize();
while(one == 0){
one = rand()%10;
}
two = rand()%10;
while(two == one || two == 0){
two = rand()%10;
}
while(three == one || thr ee == two || three == 0){
three = rand()%10;
}
}
void com(int a,int b,int c)
{
S = 0;
B = 0;
if(one == a){
++S;
}
else if(two == a){
++B;
}
else if(three == a){
++B;
}
if(one == b){
++B;
}
else if(two == b){
++S;
}
else if(three == b){
++B;
}
if(one == c){
++B;
}
else if(two == c){
++B;
}
else if(three == c){
++S;
}
return;
}
void putnumber()
{
cleardevice();
int a=0,b=0,c=0;
int q = 1;
int num = 0;
score = 0;
total = total;
getnumber();
//cprintf("%d%d%d\n",one,two,three);
while(q) {
++num;
printf("first = 0 == Return to main ^^;\n");
printf("%dth \n",num);
printf("first : ");
scanf("%d",&a;);
printf("second : ");
scanf("%d",&b;);
printf("third : ");
scanf("%d",&c;);
com (a,b,c);
printf("%dSTRIKE %dBALL\n",S,B);
score = 10 - num;
total = total + score;
if(S == 3 || a == 0 ) {
q = 0;
score = 0;
}
}
printf("\n");
}
void CHOOSE()
{
clrscr();
int number = 0;
int q = 0;
char cho[80];
char exits[80];
char dap[80];
char sscore[80];
char tscore[80];
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
/* initialize graphics an d local variables */
initgraph(&gdriver;, &gmode;, "");
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
}
int x = getmaxx()/2;
int y = getmaxy()/2;
settextjustify(CENTER_TEXT, CENTER_TEXT);
settextstyle(TRIPLEX_FONT, HORIZ_DIR, 2);
while(1) {
cleardevice();
sprintf(cho,"[1] : START [2] : DAP [3] : SCORE [4] : TOTAL SCORE [0] : QUIT",9);
outtextxy(x,y,cho);
scanf("%d",&number;);
switch(number){
case 1:
putnumber();
break;
case 2:
cleardevice();
sprintf(dap,"DAP = %d%d%d\n",one,two,three);
outtextxy(x,y,dap);
printf("\n");
getch();
break;
case 3:
cleardevice();
sprintf(sscore,"SCORE : %d\n",score);
outtextxy(x,y,sscore);
printf("\n");
getch();
break;
case 4:
cleardevice();
sprintf(tscore,"TOTAL SCORE : %d BUG ^^;",total);
outtextxy(x,y,tscore);
printf("\n");
getch();
break;
case 0:
cleardevice();
sprintf(exits,"MAKED BY KYUNG HA KIM\n BaseBall ver 1.1\n");
outtextxy(x,y,exits);
getch();
return;
default:
++q;
if(q==1){
printf("..reinput\n");
}
else if(q == 2){
printf("PU~~DASI\n");
}
else if(q >2){
printf("jook go jaap ni?\n");
}
continue;
}
}
closegraph();
re turn;
}
void main(void)
{
TITLE();
CHOOSE();
clrscr();
}
</graphics.h></stdlib.h></conio.h></stdio.h>