/*include <stdio.h>
#include <stdlib.h>
int main()
{
printf("Hello world!\n");
return 0;
}*/
#include <stdio.h>
#include <windows.h>
#define UP 0
#define DOWN 1
#define LEET 2
#define RIGHT 3
#define SUBMIT 4
enum
{
black,
blue,
green,
cyan,
red,
purple,
brown,
lightgray,
darkgray,
lightblue,
lightgreen,
lightcyan,
lightred,
lightpurple,
yellow,
white
};
int keyControl();
void inif();
void titleDraw();
int menuDraw();
int maplistDraw();
void infoDraw();
void drawMap();
void wasd(int, int);
int main()
{
inif();
while(1)
{
titleDraw();
int menuCode = menuDraw();
if(menuCode == 0)
{
int n = maplistDraw();
if(n == 0)
{
drawMap();
}
else if(n == 1)
{
//어려움
}
}
else if(menuCode == 1)
{
infoDraw();
}
else if(menuCode == 2)
{
return 0;
}
system("cls");
setColor(white, black);
}
return 0;
}
void infoDraw()
{
system("cls");
printf("\n\n");
printf(" [ 조작법 ]\n\n");
printf(" 이동 : W, A, S, D\n");
printf(" 선택 : 스페이스 바\n\n\n");
printf(" 개발자: 랑이 1004\n\n");
printf(" 스페이스 바를 누르면 메인화면으로 이동합니다.");
while(1)
{
if(keyControl() == SUBMIT)
{
break;
}
}
}
int keyControl()
{
char temp = getch();
if(temp == 'w' || temp == 'W')
{
return UP;
}
else if(temp == 'a' || temp == 'A')
{
return LEET;
}
else if(temp == 's' || temp == 'S')
{
return DOWN;
}
else if(temp == 'd' || temp == 'D')
{
return RIGHT;
}
else if(temp == ' ')
{
return SUBMIT;
}
}
void wasd(int x, int y)
{
HANDLE consoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
COORD Pos;
Pos.X = x;
Pos.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), Pos);
}
void inif()
{
system("mode con cols=56 lines=35 | title 굉장나 엄청해한 게임");
HANDLE concoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO ConsoleCursor;
ConsoleCursor.bVisible = 0;
ConsoleCursor.dwSize = 1;
SetConsoleCursorInfo(concoleHandle, &ConsoleCursor);
}
void setColor(int forground, int background)
{
HANDLE consoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
int code = forground + background * 16;
SetConsoleTextAttribute(consoleHandle, code);
}
void titleDraw()
{
char game[500][500]={" $$$$$$ % % ^^^^^ &\n",
" $ % % ^ ^ &\n",
" $ %%% % ^ ^ &\n",
" $ % % ^ ^ &\n",
" % % ^^^^^ &\n",
" \n",
" ####### \n",
" # # \n",
" # # \n",
" ####### \n" };
printf("\n\n");
printf(" [무려 1부 판매]\n");
printf("\n\n");
printf(" [굉장나고 엄청해한 게임]\n");
for(int i=0;i<strlen(game);i++)
{
for(int j=0;game[i][j]!=NULL;j++)
{
if(game[i][j]=='#')
{
setColor(white, white);
}
else if(game[i][j]=='$')
{
setColor(red, red);
}
else if(game[i][j]=='%')
{
setColor(brown, brown);
}
else if(game[i][j]=='^')
{
setColor(lightgreen, lightgreen);
}
else if(game[i][j]=='&')
{
setColor(blue, blue);
}
else
{
setColor(white, black);
}
printf("%c",game[i][j]);
}
}
}
int menuDraw()
{
int x = 20;
int y = 18;
wasd(x-2, y);
printf("> 게 임 시 작 ");
wasd(x, y+1);
printf("게 임 정 보 ");
wasd(x, y+2);
printf(" 종 료 ");
while(1)
{
int n = keyControl();
switch(n)
{
case UP:
{
if(y > 18)
{
wasd(x-2, y);
printf(" ");
wasd(x-2, --y);
printf(">");
}
break;
}
case DOWN:
{
if(y < 20)
{
wasd(x-2, y);
printf(" ");
wasd(x-2, ++y);
printf(">");
}
break;
}
case SUBMIT:
{
return y-18;
}
}
}
}
int maplistDraw()
{
int x = 24;
int y = 6;
system("cls");
printf("\n\n");
printf(" [맵선택]\n\n ");
wasd(x-2, y);
printf("> 쉬움");
wasd(x, y+1);
printf("어려움");
wasd(x, y+2);
printf("뒤로");
while(1)
{
int n = keyControl();
switch(n)
{
case UP:
{
if(y>6)
{
wasd(x-2, y);
printf(" ");
wasd(x-2, --y);
printf(">");
}
break;
}
case DOWN:
{
if(y<8)
{
wasd(x-2, y);
printf(" ");
wasd(x-2, ++y);
printf(">");
}
break;
}
case SUBMIT:
{
return y-6;
}
}
}
}
char map[25][56] =
{
{"11111111111111111111111111111111111111111111111111111111"},
{"10000000000000000000000000000000000000000000000000000001"},
{"10000000000000000000000000000000000000000000000000000001"},
{"10000000000000000000000000000000000000000000000000000001"},
{"10000000000000000000000000000000000000000000000000000001"},
{"10000010000000000000000000000000000000000000000000000001"},
{"10000010000000000000000000000000000000000000000000000001"},
{"10000010000000000000000000000000000000000000000000000001"},
{"10000010000000000000000000000000000000000000000000000001"},
{"10000010000000000000000000000000000000000000000000000001"},
{"10000010000000000000000000000000000000000000000000000001"},
{"10000010000000000000000000000000000000000000000000000001"},
{"10000010000000000000000000000000000000000000000000000001"},
{"10000010000000000000000000000000000000000000000000000001"},
{"10000010000000000000000000000000000000000000000000000001"},
{"10000010000000000000000000000000000000000000000000000001"},
{"10000010000000000000000000000000000000000000000000000001"},
{"10000010000000000000000000000000000000000000000000000001"},
{"10000010000000000000000000000000000000000000000000000001"},
{"10000010000000000000000000000000000000000000000000000001"},
{"10000010000000000000000000000000000000000000000000000001"},
{"100s001000000000000000000000000000000000000000000000q001"},
{"10000010000000000000000000000000000000000000000000000001"},
{"10000010000000000000000000000000000000000000000000000001"},
{"11111111111111111111111111111111111111111111111111111111"},
};
void drawMap()
{
system("cls");
int h, w;
for(h=0; h<25; h++)
{
for(w=0; w<56; w++)
{
char temp = map[h][w];
if(temp == '0')
{
setColor(black, black);
printf(" ");
}
else if(temp == '1')
{
setColor(white, white);
printf("#");
}
else if(temp == 's')
{
setColor(lightcyan, black);
printf("A");
}
else if(temp == 'q')
{
setColor(yellow, black);
printf("@");
}
}
printf("\n");
}
setColor(white, black);
Sleep(3000);
}