|
#include<stdio.h>
#include<conio.h>
void video(char [],char[],char[],int);
int run(char [],char [],char []);
main()
{
char one[50],two[50],three[50];
int i;
for(i=0;i<50;i++) { /*one,two,three배열을 공배로 채움*/
one[i]=' ';
two[i]=' ';
three[i]=' ';
}
one[0]='0'; /*one,two,three배열의 처음에는 1,2,3을 끝에는 E표식*/
two[0]='a';
three[0]='m';
one[49]='E';
two[49]='E';
three[49]='E';
video(one,two,three,50);
run(one,two,three);
}
void video(char one[],char two[],char three[],int b)
{
/*one,two,three배열을 보여줌*/
int i;
clrscr();
for(i=0;i<b;i++) printf("%c",one[i]);
printf("\n");
for(i=0;i<b;i++) printf("%c",two[i]);
printf("\n");
for(i=0;i<b;i++) printf("%c",three[i]);
printf("\n");
}
int run(char one[],char two[],char three[])
{ /*키입력받아 1,2,3을 달리게 한다.*/
int save1,save2,save3;
char clk,temp;
save1=0;
save2=0;
save3=0;
for(; ; ) {
printf("\n해당키보드를 두들겨라! 단 0.1초 이상 누르고 있기 없기~");
clk=getch();
if(clk=='e'||save1==48||save2==48||save3==48) {
clrscr();
printf("게임끝났다..\n");
if(save1==48) printf("0이 이겼다.");
if(save2==48) printf("A가 이겼다.");
if(save3==48) printf("M이 이겼다.");
return -1;
}
if(clk=='0') {
temp=one[save1];
one[save1]=one[save1+1];
one[save1+1]=temp;
save1++;
}
if(clk=='a') {
temp=two[save2];
two[save2]=two[save2+1];
two[save2+1]=temp;
save2++;
}
if(clk=='m') {
temp=three[save3];
three[save3]=three[save3+1];
three[save3+1]=temp;
save3++;
}
video(one,two,three,50);
}
}
위에 달리기 게임소스인데요
이걸 C++ 형으로 바꾸려고 하는데
어찌할 바 모르겠네여
좀 손좀 봐주세여 ㅠ,.ㅠ
|