메뉴구현 관련 질문입니다.
CreamyGirl
질문 제목 : 메뉴구현 관련 질문입니다. 메뉴구현 관련 질문입니다. 질문 내용 :메뉴 구현을 햇는대 방향키 와따가따해도 그림자가 너무마니남내여 그리고 다시 메인으로 매뉴로 돌아가면
거기서 바로 첨선택된 메뉴가 그냥 실행되버리네요.... 방향키로 메뉴고를수가 없네요... 어찌하면될까여
소스첨부할게요 수다님감사 말씀해주신대로 줄엿습니다. 또 조언해주세요 ㅎㅎ 많은분들 ㅎㅎ
#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);
 sp; 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);
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(┃ ┃ ┃&?nbsp; ┃\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);
}
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;
}
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2694258 | 카운터.. 질문입니다. (4) | 하늘빛눈망울 | 2025-05-09 |
2694229 | 단순한 질문이요 (8) | 여름 | 2025-05-09 |
2694202 | 용돈을 가지고 할 수 있는 일을 여러가지로 출력하는 방법 좀 알려주세요! (2) | 미나 | 2025-05-09 |
2694145 | 화면깜빡임을 없애고 싶은데요... (1) | 어서와 | 2025-05-08 |
2694069 | unsigned 질문입니다. | 힘차 | 2025-05-07 |
2694012 | 전공 비전공자 개발자 (10) | 말글 | 2025-05-07 |
2693984 | 오버로딩이 무엇인가요? (2) | 헛매질 | 2025-05-07 |
2693956 | PlaySound재생이 안됩니다!(C에 음악넣기) | 지존 | 2025-05-06 |
2693928 | &와 *의 사용에 관한 명확한 이해 | 제나 | 2025-05-06 |
2693903 | 반복문 설명좀요 ㅠㅠ (2) | 란새 | 2025-05-06 |
2693869 | stdio.h 는 왜 쓰는건가요? (1) | 큰꽃들 | 2025-05-06 |
2693842 | 포인터 변수의 주소값끼리 더하는 것에 대해서 질문드립니다. (1) | 진솔 | 2025-05-05 |
2693811 | 소수 출력;;;; | 화이트캣 | 2025-05-05 |
2693788 | 이런 함수는 없나요? (3) | 앤드류 | 2025-05-05 |
2693758 | txt파일 불러와서 행렬로 저장 | 큰애 | 2025-05-05 |
2693727 | scanf 오류 문제!! (2) | 큰나래 | 2025-05-04 |
2693704 | 구조체 주소록 문제인데 도와주세요 (2) | 도1도캣 | 2025-05-04 |
2693676 | 열혈강의 c언어 질문입니다 | 하양이 | 2025-05-04 |
2693647 | 12.620000 을요 12.620 으로 어떻게 표현해요? (2) | 파도 | 2025-05-04 |
2693619 | 타이틀 코드.. | 단순드립 | 2025-05-03 |