#include #include #include #include // sndPlaySound를 실행하기 위한 헤더파일 #pragma comment(lib, "winmm.lib") // sndPlaySound를 실행하기 위한 라이브러리 void SetCurrentCursorPos(int x, int y) // 커서 위치를 지정해주는 함수 { COORD pos={x, y}; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos); } void RemoveCursor() // 커서를 지워주는 함수 { CONSOLE_CURSOR_INFO curInfo; GetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &curInfo); curInfo.bVisible=0; SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &curInfo); } void Delete(int a, int b) // ☞을 지워주는 함수 { SetCurrentCursorPos(a, b); printf(" "); } void Menu(int a, int b) { system("cls"); RemoveCursor(); SetCurrentCursorPos(8, 2); printf("Game Start"); SetCurrentCursorPos(8, 4); printf("Choose song"); SetCurrentCursorPos(8, 6); printf("Exit Game"); SetCurrentCursorPos(a, b); printf("☞"); } void main() { int a=3, b=2; char c; Menu(a,b); for(;;) { if(_kbhit() != 0) { c = _getch(); if(c==72) { Delete(a, b); if(b==2) b=6; else b-=2; SetCurrentCursorPos(a, b); printf("☞"); } else if(c==80) { Delete(a, b); if(b==6) b=2; else b+=2; SetCurrentCursorPos(a, b); printf("☞"); } else if(c==13) { if(b == 2) { system("cls"); printf("Start Game\n"); printf("3초 뒤에 메인 메뉴로 돌아갑니다.\n"); Sleep(3000); Menu(a, b); }else if(b == 4) { system("cls"); printf("Press 'q' to exit"); sndPlaySound(TEXT("c:\\ttt.wav"),SND_ASYNC); do { c = _getch(); } while(c != 'q'); // q를 누르면 종료 sndPlaySound(NULL, SND_ASYNC); printf("종료\n"); Menu(a, b); }else if(b == 6) { system("cls"); printf("Good bye~~~\n"); Sleep(1000); exit(0); } } } } }