#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <windows.h>
void gotoxy(int x, int y)
{
COORD Pos = { x, y };
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), Pos);
}
void textcolor(int color_number) {
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color_number);
}
void removeCursor() { //콘솔에서 깜박이는 커서 삭제하는 함수
CONSOLE_CURSOR_INFO curInfo;
GetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &curInfo);
curInfo.bVisible = 0;
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &curInfo);
}
int Random(); //컴퓨터의 랜덤 값 출력
void game1(); // 가위바위보 게임 시작 함수
//void game2(); // 묵찌바 게임 시작 함수
void HOF(name, score); //명예의 전당 함수
void help(); //도움말 함수
int main()
{
removeCursor();
int number = 0;
system("mode con cols=150 lines=50");
textcolor(10);
gotoxy(17, 4);
printf(" ●●●●●●● ● ●●●●●●●●● ● ●●●●●●●●● "); gotoxy(17, 5);
printf(" ● ● ● ● ●●●●●● ● ● "); gotoxy(17, 6);
printf(" ● ● ● ● ● ● ●●●●●●●●● "); gotoxy(17, 7);
printf(" ●●●●● ●●● ●●●●●●●●● ● ● ● "); gotoxy(17, 8);
printf(" ● ● ●●●●●● ●●● ●●●●●●●●● "); gotoxy(17, 9);
printf(" ●●●●●●●●●●●● ● ● ●●●●●●●●●●● "); gotoxy(17, 11);
printf(" ●●●●●● ● ● ● ● ●●●●●●●● "); gotoxy(17, 12);
printf(" ● ● ● ● ●●●●●● ● ● "); gotoxy(17, 13);
printf(" ● ● ● ● ● ●●●●●●●● "); gotoxy(17, 14);
printf(" ● ● ● ● ● ● "); gotoxy(17, 15);
printf(" ●●●●●● ● ● ● ●●●●●●●● "); gotoxy(18, 19);
printf(" ● ● ● "); gotoxy(18, 20);
printf(" ●●● ● ●●●●●●●● ● ●●●●●●●●● ● "); gotoxy(18, 21);
printf(" ● ● ● ● ● ● ● "); gotoxy(18, 22);
printf(" ● ● ● ● ●●●● ● ●"); gotoxy(18, 23);
printf(" ● ● ● ● ● ●●●●●●●●● ● "); gotoxy(18, 24);
printf(" ● ● ● ● ● ● ●●● "); gotoxy(18, 25);
printf(" ● ● ● ● ●●●● ● ● "); gotoxy(18, 26);
printf(" ● ● ● ● ● ●●●●●●●●● ● "); gotoxy(18, 27);
printf(" ● ● ● ● ● ● "); gotoxy(18, 28);
printf(" ●●● ● ● ●"); gotoxy(18, 29);
printf(" ● ● ● "); gotoxy(18, 30);
printf("\n\n\n\n");
Sleep(500);
textcolor(8);
gotoxy(50, 35);
printf("[ 시작하려면 아무키나 누르세요 ]");
Sleep(500);
gotoxy(50, 45);
printf("[ 시작하려면 아무키나 누르세요 ]");
_getch();
while (1)
{
textcolor(12);
system("cls"); // 콘솔창 초기화
printf("\n\n [ 메인메뉴 ]\n\n");
printf("\n 1. 가위바위보\n");
printf("\n 2. 묵찌빠(제작중)\n");
printf("\n 3. 게임방법\n");
printf("\n 4. 명예의 전당\n");
printf("\n 5. QUIT\n");
printf("선택>");
scanf("%d", &number);
switch (number)
{
case 1:
game1(); // 가위바위보 게임의 주 함수 호출
break;
case 2:
//game2(); // 묵찌빠 게임의 주 함수 호출
break;
case 3:
help(); // 도움말 출력 함수 호출
break;
case 4:
HOF(); // 명예의 전당 점수표 확인
break;
case 5:
system("Cls");
printf("Play 해 주셔서 감사합니다. 다음에 또 놀러오세요!"); // 명예의 전당 점수표 확인
return 0;
break;
default:
gotoxy(75, 20);
printf("이 프로그램을 하고 있는 분께.. 여러분 글씨를 제대로 읽을 수 있다면 왜 누르셨나요?? \n제대로 눌러주세요!!");
_getch();// 그외 입력 무시
break;
}
}
}
int Random() // 반환하는 값은 정수형이다.
{
int RD = 0;
srand(time(NULL)); // 랜덤 값을 시간으로 설정한다.
RD = rand() % 3 + 1; // RD에 3으로 나눈 나머지 + 1 즉, 1~3까지의 값
return RD; // 정수형 RD를 반환 한다.
}
void game1()
{
int person;
int computer;
int score = 1;
int life = 3;
char name[6];
system("cls");
printf("가위바위보를 시작합니다.\n");
while (1)
{
printf("\n가위바위 보!");
scanf("%d", &person);
computer = Random();
if (person == 1)
{
if (computer == 1)
{
printf("도전자 : 가위 \n 컴퓨터 : 가위\n\n무승부!!!");
score += 30;
}
else if (computer == 2)
{
printf("도전자 : 가위 \n 컴퓨터 : 주먹\n\n졌따..");
life -= 1;
}
else if (computer == 3)
{
printf("도전자 : 가위 \n 컴퓨터 : 보\n\n이겼따..");
score += 100;
}
}
else if (person == 2)
{
if (computer == 1)
{
printf("도전자 : 주먹 \n 컴퓨터 : 가위\n\n이겼따!");
score += 100;
}
else if (computer == 2)
{
printf("도전자 : 주먹 \n 컴퓨터 : 주먹\n\n무승부!!..");
score += 30;
}
else if (computer == 3)
{
printf("도전자 : 주먹 \n 컴퓨터 : 보\n\n졋네용..");
life -= 1;
}
}
else if (person == 3)
{
if (computer == 1)
{
printf("도전자 : 보 \n 컴퓨터 : 가위\n\n졋네용..");
life -= 1;
}
else if (computer == 2)
{
printf("도전자 : 보 \n 컴퓨터 : 주먹\n\n이겼다!");
score += 100;
}
else if (computer == 3)
{
printf("도전자 : 보 \n 컴퓨터 : 보\n\n무승부..");
score += 30;
}
}
else
printf("제대로 입력해 시키야");
if (life == 3)
printf("재도전 횟수 3번 남았습니다.");
else if (life == 2)
printf("재도전 횟수 2번 남았습니다.");
else if (life == 1)
printf("재도전 횟수 1번 남았습니다.");
else
{
printf("이름을 입력해주세요\n입력>");
scanf("%s", name);
printf("받은 점수는 %d점입니다.", score);
printf("5초뒤에 메인화면으로 넘어갑니다");
Sleep(5000);
HOF(name, score);
return main();
}
}
}
/*void game2() {
int person;
int computer;
int turn;
int life = 3;
system("cls");
printf("게임을 시작합니다!!");
while (1)
{
printf("선공을 정합니다!");
scanf("%d", &person);
computer = Random();
if (person == 1) {
if (computer == 1)
{
printf("다시 해주세요!!");
}
else if (computer == 2)
{
printf("컴퓨터가 공격합니다.");
}
else if (computer == 3)
{
printf("오! 선공입니다.!");
}
}
if (person == 2) {
if (computer == 1)
{
printf("오! 선공입니다.!");
}
else if (computer == 2)
{
printf("다시 해주세요!!");
}
else if (computer == 3)
{
printf("컴퓨터가 공격합니다.");
}
}
if (person == 3) {
if (computer == 1)
{
printf("컴퓨터가 공격합니다.");
}
else if (computer == 2)
{
printf("오! 선공입니다.!");
}
else if (computer == 3)
{
printf("다시 해주세요!!");
}
}
}
*/
void HOF(name, score) {
system("cls");
printf("〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓 〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓\n");
printf(" 명예의 전당 \n\n");
printf("%s님은 %d의 점수로 명예의 전당에 오르신걸 다시 한번 인증합니다.", name, score);
Sleep(5000);
return main();
}
void help()
{
printf("이 게임은 컴퓨터와 가위바위보, 묵찌바 대결을 하여 점수를 얻는 게임입니다.\n");
printf("게임은 가위바위보, 묵찌바로 이루어져 있으며 3번 컴퓨터에게 패배시 종료되게 됩니다.\n");
printf("조작법은 1은 '가위' 2은 '주먹' 3은 '보자기'입니다. 즐겁게 게임하세요!!\n");
printf("명예의 전당 수록방법 700점이 넘을시 순위대로 이름과 같이 오르게 됩니다.");
_getch();
}