728x90
    
    
  
console rpg 만들기 첫 번째 글이다.

대~~~충 그린 예상 화면이다. 어려울 것 같지만... 최선을 다해보자.
오늘은 처음이니까 main 화면만 만들어봤다. 검은 화면에 흰 글씨로 한글자씩 소개글이 나온다.
void main()
{
	int i;
	FILE* input = NULL;
	wchar_t script[100];
	input = fopen("start.txt", "r");
	fgetwc(input, "%s", script);
	for (i = 0; i < 100; i++)
	{
		script[i] = fgetwc(input);
		if (script[i] == EOF)
			break;
	}
	
	fclose(input);
	gotoxy(0, 10);
	for (i = 0; i < 100; i++)
	{
		printf("%lc", script[i]);
		Sleep(50);
	}
}
start.txt에 소개글을 미리 적어줬다. 언제라도 변경 가능하다.
main에 이어서 깜빡이는 제목을 만들어줬다.
while (1)
{
    cls(BLACK, YELLOW2);
    for (i = 0; i < 5; i++)
    {
        gotoxy(rand() % 120, rand() % 15);
        printf("*");
    }
    flag = _kbhit();
    if (flag != NULL)
        break;
    RText = rand() % 15 + 1;
    textcolor(RText, BLACK);
    gotoxy(22, 5);
    printf("■■■■■  ■   ■■■■■          ■         ■■     ■■■  ■  ■\n");
    gotoxy(22, 6);
    printf("    ■      ■           ■        ■  ■    ■■■■■  ■      ■  ■\n");
    gotoxy(22, 7);
    printf("  ■  ■    ■           ■      ■      ■   ■    ■   ■      ■■■\n");
    gotoxy(22, 8);
    printf("■      ■  ■ ■■■■■■■  ■■■■■■■   ■■     ■■■  ■  ■\n");
    gotoxy(22, 9);
    printf("            ■       ■              ■          ■              ■  ■\n");
    gotoxy(22, 10);
    printf("                     ■              ■      ■■■■■\n");
    textcolor(WHITE, BLACK);
    gotoxy(40, 20);
    printf("시작하려면 아무키나 누르세요");
    Sleep(250);
}
띄어쓰기가 이상해서 제목이 이상하게 나오지만! 지구 수호대 라는 이름을 특수문자로 만들어준 모양이다. cls, textcolor, gotoxy는 교수님이 만들어준 틀을 그대로 사용했다. 배경색과 글자색을 변경하는 함수와 커서를 이동시켜주는 함수다.
까와이한 메인 화면 완성. 나중에 시간이 남으면 더 꾸며야겠당.
728x90
    
    
  '언어 > C' 카테고리의 다른 글
| [C] Console RPG 제작기 (2) (0) | 2023.05.28 | 
|---|---|
| [C] Debug Assertion Failed, format != nullptr (0) | 2023.05.28 | 
| [C] 재귀 함수와 for문으로 피보나치수열 찾기 (0) | 2023.04.19 | 
| [C] strlen, strcmp, strcpy, strcat (0) | 2023.04.06 | 
| [C] 하노이탑 쌓기 (0) | 2023.04.05 |