메뉴구현 관련 질문입니다.
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;
}
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2698012 | 2~9가아닌수 | 아놀드 | 2025-06-13 |
2697980 | for에 gets함수를 넣으니까 왜 반복이 안되죠 ㅜ (2) | 펴라 | 2025-06-12 |
2697952 | 2차배열과 함수문의^^; | VanilLa | 2025-06-12 |
2697924 | 다차원 배열 질문있습니다 | 두동 | 2025-06-12 |
2697893 | 정올 :: 기초다지기 a9007 배열7 (문제가 이상함 -_-) | 흰두루 | 2025-06-12 |
2697862 | Unable......... 지정된 파일을 찾을 수 없습니다!! (1) | Creator | 2025-06-11 |
2697761 | 그러니까여제말은... (2) | 새론 | 2025-06-10 |
2697737 | 정올 문제좀 풀어보신분~ | 레오 | 2025-06-10 |
2697709 | rand함수 질문좀요! (6) | 가막새 | 2025-06-10 |
2697683 | C언어 변수뒤 표시가 이해안되는게 있습니다. | 소미 | 2025-06-10 |
2697660 | 껍데기딜 만들고 난후 어느핫키 누르면 코드검색이라도 뜨고 그다음 무반응 해결좀 (2) | 움찬 | 2025-06-09 |
2697634 | c언어로 감성사전 만들기! (1) | 도란도란 | 2025-06-09 |
2697605 | 이 함수좀... | agine | 2025-06-09 |
2697574 | 배열 기본적인질문 (3) | 민트향 | 2025-06-09 |
2697549 | 배열 초기화 (4) | 나리 | 2025-06-08 |
2697465 | 수다님...^^ (2) | 가론 | 2025-06-08 |
2697432 | 서버 만드는 함수에서 궁금한게있어요~ | 파랑 | 2025-06-07 |
2697401 | 열혈강의 문제오류 (1) | 꿈 | 2025-06-07 |
2697374 | 기초적인 C언어 프로그래밍 입니다. | 얼 | 2025-06-07 |
2697341 | 좌우대칭 문제인데 Q가 입력되면 종료가 되야하는데 되지않습니다 | 무지개 | 2025-06-07 |