메뉴를 방향키로 구현햇을때 메인으로 돌아가는 키눌렷을시 다시 방향키 움직일려면 어떻게 해야할지 모르겟음
곰돌곰돌
질문 제목 : 메뉴를 방향키로 구현햇을때 메인으로 돌아가는 키눌렷을시 다시 방향키 움직일려면 어떻게 해야할지 모르겟음메뉴를 방향키로 구현햇을때 메인으로 돌아가는 키눌렷을시 다시 방향키 움직일려면 어떻게 해야할지 모르겟음질문 내용 : 메뉴를 방향키로 구현해서 엔터키도 되고 방향키도 움직이는데 해당 메뉴끝나고 다시 메뉴로 돌아올려고
짜낫던 함수호출하니까 버튼은보이는데 눌리자마자 엔터키 친거처럼되서 다시 들가버리네요...
머가 잘못됫는지 모르겟어요 첨 짜바서 조언 많이 부탁드립니다. 소스첨가할게요
소스 첨가 햇습니다 보고 부탁드릴게요 ㅠㅠ하잇로우 게임과 슬롯머신 블랙잭 기반으로 마카오 배경만들어볼려하는 것입니다. 이래저래 요령껏 구현해바서많이 부실할테니 잘부탁드립니다. 수다님 감사합니다 이렇게 줄일수가 있군요 생각을 못햇네 ㅠ ㅎㅎ소스도 좀 봐주세요 ㅠㅠ 매뉴에서 1키 입력해서 넘어가면 메뉴방향키가안움직이고처음선택된걸로 바로 다시 들어가버리네요 ....부탁드릴게요 ㅠ
#include windows.h
#include stdio.h
#include stdlib.h
#include time.h
#include conio.h
#include mmsystem.h
#pragma comment(lib,winmm.lib)
void makao();
void slot_print();
void cursorview(char show); //커서 보이고 숨기는 함수
void screen1(); //스크린1표시함수
void screen2();//스크린2표시함수
void gotoxy(int x, int y); //좌표 설정 함수
void setcolor(int color);//색상 지정함수
void print_slot(); //슬롯머신메뉴그리기
void printhr(); //하잇로우그리기
void printblackj(); //블랙잭그리기
int blackjack_game(int bet);//블랙잭게임
int hrow_game(int bet); //하잇로우게임
int slot_game(int bet); //슬롯머신게임
int choice_menu(int bet);
void mainscreen();
void gamemain(int bet);
enum {hidden, show};
enum {
black,/* 0 : 까망 */
dark_blue,/* 1 : 어두운 파랑 */
dark_green,/* 2 : 어두운 초록 */
dark_sky_blue,/* 3 : 어두운 하늘 */
dark_red,/* 4 : 어두운 빨강 */
dark_violet,/* 5 : 어두운 보라 */
dark_yellow,/* 6 : 어두운 노랑 */
gray,/* 7 : 회색 */
dark_gray,/* 8 : 어두운 회색 */
blue,/* 9 : 파랑 */
green,/* 10 : 초록 */
sky_blue,/* 11 : 하늘 */
red,/* 12 : 빨강 */
violet,/* 13 : 보라 */
yellow,/* 14 : 노랑 */
white/* 15 : 하양 */
};
char name[10];
int bet = 0;
int x = 25;
int y = 15;
char ch;
int mode;
int m_num;
int mod;
int slot1,slot2,slot3,slot4,slot5,slot6,slot7,slot8,slot9,slot10,slot11,slot12;
void cursorview(char show)
{
handle hconsole;
console_cursor_info consolecursor;
hconsole = getstdhandle(std_output_handle);
consolecursor.bvisible = show;
consolecursor.dwsize = 1;
setconsolecursorinfo(hconsole , &consolecursor);
}
void gotoxy(int x, int y) /*커서이동 함수 부분*/
{
coord xy = {x, y};
setconsolecursorposition(getstdhandle(std_output_handle), xy);
}
void setcolor(int color)
{
setconsoletextattribute(getstdhandle(std_output_handle), color);
}
void makao()
{
gotoxy(10,5);printf(■■■■■□□■□□□■■■■□□□■□□□□□■■■■■□□\n);
gotoxy(10,6);printf(■□□□■□□■□□□□□□□■□□■□□□□■□□□□□■□\n);
gotoxy(10,7);printf(■□□□■□□■□□□□□□□■□□■□□□□■□□□□□■□\n);
gotoxy(10,8);printf(■□□□■□□■□□□□□□□■□□■□□□□■□□□□□■□\n);
gotoxy(10,9);printf(■□□□■□□■■□□■■■■■□□■■□□□□■■■■■□□\n);
gotoxy(10,10);printf(■□□□■□□■□□□□□□□■□□■□□□□□□□■□□□□\n);
gotoxy(10,11);printf(■□□□■□□■□□□□□□■□□□■□□□□□□□■□□□□\n);
gotoxy(10,12);printf(■□□□■□□■□□□□□■□□□□■□□□□□□□■□□□□\n);
gotoxy(10,13);printf(■■■■■□□■□□□■■□□□□□■□□□■■■■■■■■■\n);
}
void screen1()
{
setcolor(red);
makao();
sleep(150);
system(cls);
setcolor(yellow);
makao();
sleep(150);
system(cls);
setcolor(green);
makao();
sleep(150);
system(cls);
setcolor(blue);
makao();
sleep(150);
system(cls);
setcolor(violet);
makao();
sleep(150);
system(cls);
setcolor(white);
}
/*별(스타) 이펙트 부분
별이떨어지는(유성)의 이펙트를 화면 우측상단에 출력해준다.*/
void screen2()
{
//st0
setcolor(white);
gotoxy(45,1);
printf(/);
sleep(50);
gotoxy(44,2);
printf(/);
sleep(50);
gotoxy(43,3);
printf(/);
sleep(50);
gotoxy(42,4);
printf(/);
sleep(50);
gotoxy(41,5);
printf(/);
sleep(50);
gotoxy(40,6);
setcolor(sky_blue);
printf(☆);
//st1
setcolor(white);
gotoxy(53,1);
printf(/);
sleep(50);
gotoxy(52,2);
printf(/);
sleep(50);
gotoxy(51,3);
printf(/);
sleep(50);
gotoxy(50,4);
printf(/);
sleep(50);
gotoxy(49,5);
setcolor(yellow);
printf(☆);
//st3
setcolor(white);
gotoxy(60,1);
printf(/);
sleep(50);
gotoxy(59,2);
printf(/);
sleep(50);
gotoxy(58,3);
printf(/);
sleep(50);
gotoxy(57,4);
printf(/);
sleep(50);
gotoxy(56,5);
setcolor(red);
printf(☆\n\n);
setcolor(white);
gotoxy(x,y);print_slot();}
void print_slot() //슬롯머신 선택햇을경우
{
mode = 1;
setcolor(yellow);
gotoxy(30,10);
printf(┌───────┐);
gotoxy(30,11);
printf(│);
setcolor(white);
printf( 슬롯머신 │);
setcolor(yellow);
gotoxy(30,12);
printf(│ ┌────┘);
gotoxy(30,13);
printf(└──┘ );
setcolor(dark_yellow);
gotoxy(30,14);
printf( ┌────┐);
gotoxy(30,15);
printf(┌──┘ │);
gotoxy(30,16);
printf(│ 하잇로우 │);
setcolor(dark_yellow);
gotoxy(30,17);
printf(├───────┤);
gotoxy(30,18);
printf(│ 블 랙 잭 │ );
gotoxy(30,19);
printf(└───────┘);
setcolor(dark_yellow);
sleep(30);
}
void printhr() //하잇로우 선택햇을경우
{
mode = 2;
setcolor(dark_yellow);
gotoxy(30,10);
printf(┌───────┐);
gotoxy(30,11);
printf(│ 슬롯머신 │);
gotoxy(30,12);
printf(│ ┌────┘);
gotoxy(30,13);
printf(└──┘ );
setcolor(yellow);
gotoxy(30,14);
printf( ┌────┐);
gotoxy(30,15);
printf(┌──┘ │);
gotoxy(30,16);
printf(│ );
setcolor(white);
printf( 하잇로우 │);
setcolor(yellow);
gotoxy(30,17);
printf(└───────┘);
setcolor(dark_yellow);
gotoxy(30,19);
printf(┌───────┐);
gotoxy(30,20);
printf(│ 블 랙 잭 │);
gotoxy(30,21);
printf(└───────┘);
setcolor(dark_yellow);
sleep(30);
} void printblackj() //블랙잭 선택경우
{
mode =3;
setcolor(dark_yellow);
gotoxy(30,10);
printf(┌───────┐);
gotoxy(30,11);
printf(│ 슬롯머신 │);
gotoxy(30,12);
printf(│ ┌────┤);
gotoxy(30,13);
printf(├──┘ │ );
gotoxy(30,14);
printf(│하잇로우 │);
gotoxy(30,15);
printf(└───────┘);
setcolor(yellow);
gotoxy(30,17);
printf(┌───────┐);
gotoxy(30,18);
printf(│);
setcolor(white);
printf(블 랙 잭 │);
setcolor(yellow);
gotoxy(30,19);
printf(└───────┘);
setcolor(yellow);
sleep(30);
}
void slot_print()
{
setcolor(yellow);
gotoxy(30,5);printf(┌━━━━━━━━┐\n);
setcolor(white);
gotoxy(30,6);printf(┃ %d ┃ %d ┃ %d \n,slot1,slot2,slot3);
setcolor(yellow);
gotoxy(30,7);printf(┃ ┃ ┃ ┃\n);
gotoxy(30,8);printf(└━━━━━━━━┘\n);
sleep(100);
setcolor(violet);
gotoxy(30,5);printf(┌━━━━━━━━┐\n);
setcolor(white);
gotoxy(30,6);printf(┃ %d ┃ %d ┃ %d \n,slot4,slot5,slot6);
setcolor(violet);brlet);
gotoxy(30,7);printf(┃ ┃ ┃ ┃\n);
gotoxy(30,8);printf(└━━━━━━━━┘\n);
sleep(100);
setcolor(yellow);
gotoxy(30,5);printf(┌━━━━━━━━┐\n);
setcolor(white);
gotoxy(30,6);printf(┃ %d ┃ %d ┃ %d \n,slot7,slot8,slot9);
setcolor(yellow);
gotoxy(30,7);printf(┃ ┃ ┃ ┃\n);
gotoxy(30,8);printf(└━━━━━━━━┘\n);
sleep(100);
setcolor(violet);
gotoxy(30,5);printf(┌━━━━━━━━┐\n);
setcolor(white);
gotoxy(30,6);printf(┃ %d ┃ %d ┃ %d \n,slot10,slot11,slot12);
setcolor(violet);
gotoxy(30,7);printf(┃ ┃ ┃ ┃\n);
gotoxy(30,8);printf(└━━━━━━━━┘\n);
sleep(100);
}
int slot_game(int bet)
{
int slotbet;
reslot:
srand(time(0));
slot1 = rand()%9;
slot2 = rand()%9;
slot3 = rand()%9;
slot4 = rand()%9;
slot5 = rand()%9;
slot6 = rand()%9;
slot7 = rand()%9;
slot8 = rand()%9;
slot9 = rand()%9;
slot10 = rand()%9;
slot11 = rand()%9;
slot12 = rand()%9;
sleep(300);
setcolor(white);
printf(안녕하세요?\n 슬롯머신 게임 입니다\n);
rebet:
printf(게임을 즐기실려면 배팅 입력후 엔터키를 눌려주세요\n);
printf(배팅입력-);
scanf(%d,&slotbet);
if(slotbet 100000000)
{
printf(1억이하로 해주세요\n);
goto rebet;
}
else if(slotbet == 0){
printf(널값 주지마세요\n);
goto rebet;
}
playsound(text(i:\c응용\과제\훔\a.wav), null,snd_filename | snd_async | snd_nodefault);
setcolor(white);
gotoxy(25,10);printf(숫자 7 3개 다 맞을경우 1억 *2 + 배팅액\n);
gotoxy(25,11);printf(숫자 3개 다 맞을경우 300만 *2 + 배팅액\n);
gotoxy(25,12);printf(숫자2개만 맞을경우 50만 * 2 + 배팅액\n);
gotoxy(25,13);printf(숫자 1개만 맞을경우 20만 *2 + 배팅액\n);
gotoxy(25,14);printf(신중하게 해주세요\n);
setcolor(white);
gotoxy(30,5);printf(┌━━━━━━━━┐\n);
gotoxy(30,6);printf(┃ 7 ┃ 7 ┃ 7 ┃\n);
gotoxy(30,7);printf(┃ ┃ ┃ ┃\n);
gotoxy(30,8);printf(└━━━━━━━━┘\n);
sleep(100);
ch = getch();
if (ch == 13)
{
slot_print();
}if(slot7 == slot8 && slot8 == slot9 && slot7 == slot9)
{
bet = 3000000 * 2 + slotbet ;
gotoxy(15,16);
setcolor(gray);
printf(축하 합니다. %d 만원을 따셧습니다\n,bet);}
else if(slot7 == slot8 || slot8 == slot9 || slot7 == slot9)
{
bet = 500000 *2 + slotbet;
gotoxy(15,16);
setcolor(dark_red);
printf(축하 합니다. %d 만원을 따셧습니다\n,bet);
}
else if(slot7 ==7 && slot8==7 && slot9 == 7){
bet = 100000000 * 7 + slotbet ;
gotoxy(15,16);
setcolor(red);
printf( 축하 합니다 럭키세븐 입니다.\n%d 만원을 따셧습니다\n,bet);
}
else
bet = 200000 * 2 + slotbet;
gotoxy(15,16);
setcolor(white);
printf(축하 합니다. %d 만원을 따셧습니다\n,bet);gotoxy(15,20);
setcolor(white);
printf(다시하실려면 0번을 메뉴로 가실려면 1번을 입력해주세요- );
scanf(%d,&mod);
if (mod == 0)
{
system(cls);
goto reslot;
}
else if(mod == 1)
{
system(cls);
print_slot();
}
return bet;
}
int hrow_game(int bet)
{
int i,j;
int highbet;
printf(안녕하세요?\n하잇로우 게임 입니다.\n);
printf(하잇로우 게임의 룰을 간략하게 설명해드리겟습니돠~\n);
printf(① 7의 숫자에 대해 다음 나올카드가 하잇 일지 로우일지 골라 주시면 되겠습니다.\n);
printf(②맞출시 배팅 * 승리금액을 받게 됩니다. 재미난 게임이 되십시오\n);
system(cls);
printf(배팅 거실 금액을 입력 하세요\n);
scanf(%d,&highbet);
srand(time(0));
for(i=0;i5;)//카드문양 넣는곳
i= i+2;
for(j=0;j5;j++)//카드 숫자 넣는곳
{
//card[j]//return bet;
}}
int blackjack_game(int bet)
{
printf(안녕하세요?\n블랙잭 게임 입니다.\n);
reblack:
printf(다시하실려면 0번을 메뉴로 가실려면 1번을 입력해주세요\n- );
scanf(%d,&mod);
if (mod == 0)
{
system(cls);
goto reblack;
}
else if(mod == 1)
{
gamemain(bet);
}
return bet;
return bet;
}
int choice_menu(int bet){
while(1)//while에서 1이 므로 무한루프가 되게 됩니다.
{
if(kbhit())//만약 키입력을 받을 때의 경우입니다.
{
/*엔터키 입력을 받을때*/
if(mode == 1 && getasynckeystate(vk_return))
{
system(cls);
slot_game(bet);
}
else if(mode == 2 && getasynckeystate(vk_return))//하잇로우가 선택
{
system(cls);
hrow_game(bet);
}
 sp; else if(mode == 3 && getasynckeystate(vk_return))//블랙잭이 선택
{
system(cls);
blackjack_game(bet);
}
if(mode== 1 && getasynckeystate(vk_down))
{
printhr();
system(cls);
printhr();
}
if(mode== 1 && getasynckeystate(vk_up))
{
printblackj();
system(cls);
printblackj();
}
if(mode== 2 && getasynckeystate(vk_down))
{
printblackj();
system(cls);
printblackj();
}
if(mode== 2 && getasynckeystate(vk_up))
{
print_slot();
system(cls);
print_slot();
}
if(mode==3 && getasynckeystate(vk_up))
{
printhr();
system(cls);
printhr();
}
if(mode==3 && getasynckeystate(vk_down))
{
print_slot();
system(cls);
print_slot();
}
}
}
}
void mainscreen()
{
screen2();
}
void gamemain(int bet)
{
mainscreen();
choice_menu(bet);}
int main(void)
{
cursorview(hidden);
screen1();
system(cls);
mainscreen();
gamemain(bet);
return 0;
}