|
#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눌러라");
clk=getch();
if(clk=='e'||save1==48||save2==48||save3==48) {
clrscr();
printf("game over\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);
}
}
달리기게임 소스인데요.
몇가지 수정하고 싶은데 에러가 나고 잘안되네여
우선 도착지의 "E"를 다른 단어로 바꾸고 싶구여
그리고 키보드를 누르고 있으면 그냥 다다다 가버리는데
이걸 눌렀다 떼야 가는걸로 수정하고 싶어요
좀 도와주세요.
|