오델로 (돌 뒤집기)
보미나
질문 제목 : 오델로 - 상대방 돌 뒤집기오델로에서, 상대방의 돌을 뒤집어서 내 돌로 만들때요질문 내용 :
키보드로 조작하는 오델로를 만드는 중이에요~
지금 키보드로 움지이고 돌이 두어 지는 데까지 했는데요
제일난관이 돌 뒤집는거ㅠㅠㅠㅠㅠㅠㅠㅠ
배열로 해서 가능한 경우를 모두 따지는건 알겟는데요ㅠㅠ
코드를짜봣는데
자꾸돌이 안뒤집어져요ㅠㅠ..
뒤집어져야 하는곳에 두어도 돌이 안뒤집어지고....ㅠㅠㅠㅠㅠㅠ
이코드에서 어떻게 코드를 더추가해서 짜야
돌이 뒤집어질까요ㅠㅠ?
-----------------코드
#include stdio.h
#include stdlib.h
#include conio.h
#include windows.h
void move_arrow_key(char key, int *x1, int *y1, int x_b, int y_b);
void gotoxy(int x, int y);
void draw_check01(int c, int r);
void game_control(void);
void display_stone(int matrix[][40][40]);
int main(void)
{
game_control();
return 0;
}
void move_arrow_key(char key, int *x1, int *y1, int x_b, int y_b)
{
switch(key)
{
case 72:
*y1=*y1-2;
if (*y11) *y1=1;
break;
case 75:
*x1=*x1-4;
if (*x11) *x1=1;
break;
case 77:
*x1=*x1+4;
if (*x1x_b) *x1=x_b;
break;
case 80:
if (*y1=*y1+2);
if (*y1y_b) *y1=y_b;
break;
default:
return;
}
}
void gotoxy(int x, int y)
{
coord pos = {x - 1, y - 1};
setconsolecursorposition(getstdhandle(std_output_handle), pos);
}
void draw_check01(int c, int r)
{
int i, j;
unsigned char a=0xa6;
unsigned char b[12];
for(i=1; i12; i++)
b[i]=0xa0+i;
printf(%c%c, a, b[3]);
for(i=0;ic-1;i++)
{
printf(%c%c, a, b[1]);
printf(%c%c, a,b[8]);
}
printf(%c%c, a, b[1]);
printf(%c%c,a,b[4]);
printf(\n);
for(i=0;ir-1;i++)
{
printf(%c%c, a,b[2]);
for(j=0;jc;j++)
{
printf( );
printf(%c%c, a,b[2]);
}
printf(\n);
printf(%c%c, a,b[7]);
for(j=0;jc-1;j++)
{
printf(%c%c,a,b[1]);
printf(%c%c,a,b[11]);
}
printf(%c%c,a,b[1]);
printf(%c%c,a,b[9]);
printf(\n);
}
printf(%c%c, a,b[2]);
for(j=0;jc;j++)
{
printf( );
printf(%c%c,a,b[2]);
}
printf(\n);
printf(%c%c, a,b[6]);
for(i=0;ic-1;i++)
{
printf(%c%c,a,b[1]);
printf(%c%c,a,b[10]);
}
printf(%c%c,a,b[1]);
printf(%c%c, a,b[10]);
gotoxy(15,8);
printf(○);
gotoxy(19,8);
printf(●);
gotoxy(19,10);
printf(○);
gotoxy(15,10);
printf(●);
}
void game_control(void)
{
int x=1, y=1, other=0;
int matrix[2][40][40]={0};
char key;
char *stone[2]={○,●};
do
{
gotoxy(1,1);
draw_check01(8,8);
gotoxy(x+2, y+1);
printf(%s, stone[other]);
display_stone(matrix);
gotoxy(1, 20);
printf(\n\n\n방향키로 움직이고 );
printf(스페이스 키를 누르시오.);
gotoxy(1,21);
printf(돌을 놓았으면 상대방 차례입니다. );
key=getch();
if (key==27)
exit(0);
else if(key==32)
{
matrix[other][x][y]=1;
other=1-other;
}
else if (key=72)
move_arrow_key(key, &x, &y, 29, 15);
}while(1);
}
void display_stone(int matrix[][40][40])
{
int i, x, y;
char *stone[2]={○,●};
for(i=0;i2;i++)
for(x=1;x40;x++)
for(y=1;y40;y++)
{
if (matrix[i][x][y]==1)
{
gotoxy(x+2, y+1);
printf(%s, stone[i]);
}
}
}
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2700562 | 함수포인터에서요 (7) | 소심한여자 | 2025-07-06 |
2700530 | 전처리문 질문입니다. (1) | 아놀드 | 2025-07-05 |
2700510 | c언어를 어케하면 잘할수 있을까요.. | 연연두 | 2025-07-05 |
2700484 | 두 개가 차이가 뭔지 알려주세요...(소수 찾는 프로그램) (2) | 날위해 | 2025-07-05 |
2700426 | 인터넷 창 띄우는 질문이요 (1) | 정훈 | 2025-07-04 |
2700400 | 원넓이를 계산이요 ㅜㅜ | 천칭자리 | 2025-07-04 |
2700368 | if에 관해서 질문이요... | Orange | 2025-07-04 |
2700339 | 이거 결과값이 왜이런건지.. (4) | 그댸와나 | 2025-07-04 |
2700313 | 파일 읽어서 저장하는데 빈파일일 경우 문재가 발생하네요.. (2) | 크나 | 2025-07-03 |
2700287 | 구조체 동적할당 연습을 하는데 오류가 뜹니다...(해결) (3) | 아련나래 | 2025-07-03 |
2700264 | 문자와 숫자 동시에 입력??? | 글고운 | 2025-07-03 |
2700236 | txt파일로만 쓰고 읽게 하려면 어떻게 해야 하나요..?? (8) | 미국녀 | 2025-07-03 |
2700211 | 전위 연산자 (2) | 어른처럼 | 2025-07-02 |
2700183 | C에서 파일이름을 받고, 그 파일의 사이즈를 출력해줘야하는데 내용이 출력이 안되네요 ;ㅅ; | 피스케스 | 2025-07-02 |
2700150 | 꼭좀 도와주세요ㅠㅠㅠ | 호습다 | 2025-07-02 |
2700095 | 연산문제...질문... | 오빤테앵겨 | 2025-07-01 |
2700070 | while문 , 3의배수 출력하는 프로그램좀 짜주세욤. | 횃불 | 2025-07-01 |
2700041 | 초보인데요 ㅎ 배열안에 배열을 집어넣을수 있나요?? | 헛장사 | 2025-07-01 |
2700012 | 배열// (1) | 전갈자리 | 2025-07-01 |
2699895 | 무한루프에 빠집니다.!! 해결좀부탁드려요 (10) | 선아 | 2025-06-30 |