Number Trian은 2015년도에 공부하다가 쉬면서 조금씩 만들었던 게임이다.
플레이어가 역장이라는 설정이 있어서 화물 5개의 합계를 입력해 화물을 운송하는 방식의 간단한 덧셈 게임이다.
CUI로 개발했지만 최대한 철로 위 기차 화물을 운송한다는 느낌을 주려고 했다.
플레이어가 담당한 기차 10대 화물을 모두 운송하고 나면 결산이 나오며 하루 업무가 끝나게 된다.
Number Trian is a game that I started developing in 2015. I worked on it gradually while taking breaks.
The game features a setting where the player is a train conductor and involves a simple addition game where the player inputs the sum of five cargoes to transport them.
Although it was developed as a command-line interface (CUI) game, I aimed to give the feeling of transporting cargoes on a railroad as much as possible.
Once the player transports all 10 train cargoes they are responsible for, a settlement occurs, and the day's work is completed.
#include <stdio.h>
#include <Windows.h>
#include <conio.h>
#include <stdlib.h>
#include <time.h>
#define COL GetStdHandle(STD_OUTPUT_HANDLE)
#define BLACK SetConsoleTextAttribute(COL, 0x0000);
#define DARK_BLUE SetConsoleTextAttribute(COL, 0x0001);
#define GREEN SetConsoleTextAttribute(COL, 0x0002);
#define BLUE_GREEN SetConsoleTextAttribute(COL, 0x0003);
#define BLOOD SetConsoleTextAttribute(COL, 0x0004);
#define PURPLE SetConsoleTextAttribute(COL, 0x0005);
#define GOLD SetConsoleTextAttribute(COL, 0x0006);
#define ORIGINAL SetConsoleTextAttribute(COL, 0x0007);
#define GRAY SetConsoleTextAttribute(COL, 0x0008);
#define BLUE SetConsoleTextAttribute(COL, 0x0009);
#define HIGH_GREEN SetConsoleTextAttribute(COL, 0x000a);
#define SKY_BLUE SetConsoleTextAttribute(COL, 0x000b);
#define RED SetConsoleTextAttribute(COL, 0x000c);
#define PLUM SetConsoleTextAttribute(COL, 0x000d);
#define YELLO SetConsoleTextAttribute(COL, 0x000e);
#define randomize() srand((unsigned)time(NULL))
int main()
{
int i;
int a, b, c;
int number[6], result, result2;
int code1, code2, code3;
int count=1, point=0, choice=0;
system("mode con:lines=18 cols=70");
system("title 숫자 기차");
printf("\n\n\n\n\n\n\n\n");
printf(" PRESS ANY KEY TO START");
getch();
system("cls");
fflush(stdin);
srand(time(NULL));
while(choice==0)
{
system("cls");
printf("\n");
printf(" ┌┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ \n"); Sleep(100);
printf(" ┌─┴┤ │ │ │ │ │ │ │ │ │ │ │@@@@│ \n"); Sleep(100);
printf(" ┌─┘┌┐│ │ T │ │ R │ │ A │ │ I │ │ N │ │@@@@│ \n"); Sleep(100);
printf(" │ │││ │ │ │ │ │ │ │ │ │ ├─┤@@@@│ \n"); Sleep(100);
printf(" └──└┘┘ └──┘ └──┘ └──┘ └──┘ └──┘ └──┘ \n"); Sleep(100);
printf(" ○ ○ ○ ○ ○ ○ ○ ○ \n"); Sleep(100);
printf(" 〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓 \n"); Sleep(100);
printf("\n");
printf(" ①GAME START ②GAME OVER ③GAME MENUAL\n"); Sleep(100);
printf(" CH : ");
scanf("%d", &choice);
switch(choice)
{
case 1:
printf("\n");
printf(" ."); Sleep(1000);
printf("."); Sleep(1000);
printf("."); Sleep(1000);
printf("GAME START!"); Sleep(1000);
break;
case 2:
printf("\n ");
return 0;
break;
case 3:
printf("\n");
printf(" 게임을 시작하면 숫자화물 5개가 나옵니다\n");
printf(" 그 숫자들의 총합을 입력하시면 정답인지 오답인지 가려냅니다\n");
printf("\n");
printf(" 즐거운 게임 되세요!");
getchar();
getchar();
choice=0;
break;
default :
choice=0;
break;
}
}
while(1)
{
system("cls");
number[1]=rand()%(9+0-0)+0;
number[2]=rand()%(9+0-0)+0;
number[3]=rand()%(9+0-0)+0;
number[4]=rand()%(9+0-0)+0;
number[5]=rand()%(9+0-0)+0;
code1=rand()%(999999+000000-000000)+000000;
code2=rand()%(999999+000000-000000)+000000;
code3=rand()%(999999+000000-000000)+000000;
result=number[1]+number[2]+number[3]+number[4]+number[5];
//0123456789
printf("\n");
printf(" ┌┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ \n");
printf(" ┌─┴┤ │ │ │ │ │ │ │ │ │ │ │@@@@│ \n");
printf(" ┌─┘┌┐│ │ ");
if(number[1]==0)
{
printf("0");
}
if(number[1]==1)
{
printf("1");
}
if(number[1]==2)
{
printf("2");
}
if(number[1]==3)
{
printf("3");
}
if(number[1]==4)
{
printf("4");
}
if(number[1]==5)
{
printf("5");
}
if(number[1]==6)
{
printf("6");
}
if(number[1]==7)
{
printf("7");
}
if(number[1]==8)
{
printf("8");
}
if(number[1]==9)
{
printf("9");
}
printf(" │ │ ");
if(number[2]==0)
{
printf("0");
}
if(number[2]==1)
{
printf("1");
}
if(number[2]==2)
{
printf("2");
}
if(number[2]==3)
{
printf("3");
}
if(number[2]==4)
{
printf("4");
}
if(number[2]==5)
{
printf("5");
}
if(number[2]==6)
{
printf("6");
}
if(number[2]==7)
{
printf("7");
}
if(number[2]==8)
{
printf("8");
}
if(number[2]==9)
{
printf("9");
}
printf(" │ │ ");
if(number[3]==0)
{
printf("0");
}
if(number[3]==1)
{
printf("1");
}
if(number[3]==2)
{
printf("2");
}
if(number[3]==3)
{
printf("3");
}
if(number[3]==4)
{
printf("4");
}
if(number[3]==5)
{
printf("5");
}
if(number[3]==6)
{
printf("6");
}
if(number[3]==7)
{
printf("7");
}
if(number[3]==8)
{
printf("8");
}
if(number[3]==9)
{
printf("9");
}
printf(" │ │ ");
if(number[4]==0)
{
printf("0");
}
if(number[4]==1)
{
printf("1");
}
if(number[4]==2)
{
printf("2");
}
if(number[4]==3)
{
printf("3");
}
if(number[4]==4)
{
printf("4");
}
if(number[4]==5)
{
printf("5");
}
if(number[4]==6)
{
printf("6");
}
if(number[4]==7)
{
printf("7");
}
if(number[4]==8)
{
printf("8");
}
if(number[4]==9)
{
printf("9");
}
printf(" │ │ ");
if(number[5]==0)
{
printf("0");
}
if(number[5]==1)
{
printf("1");
}
if(number[5]==2)
{
printf("2");
}
if(number[5]==3)
{
printf("3");
}
if(number[5]==4)
{
printf("4");
}
if(number[5]==5)
{
printf("5");
}
if(number[5]==6)
{
printf("6");
}
if(number[5]==7)
{
printf("7");
}
if(number[5]==8)
{
printf("8");
}
if(number[5]==9)
{
printf("9");
}
printf(" │ │@@@@│");
printf("\n");
printf(" │%.2d │││ │ │ │ │ │ │ │ │ │ ├─┤@@@@│ \n", count);
printf(" └──└┘┘ └──┘ └──┘ └──┘ └──┘ └──┘ └──┘ \n");
printf(" ○ ○ ○ ○ ○ ○ ○ ○ \n");
printf(" 〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓 \n");
printf("\n");
printf(" 숫자 화물 합계 : ");
scanf("%d", &result2);
if(result==result2)
{
point++;
printf("\n");
printf(" ┌────────────────────────────────┐\n"); Sleep(100);
printf(" │※화물이 제대로 전송되었습니다 │\n"); Sleep(100);
printf(" │ │\n"); Sleep(100);
printf(" │기차번호 %.6d 문서번호 %.6d 보안코드 %.6d │\n", code1, code2, code3); Sleep(100);
printf(" │화물번호 %d %d %d %d %d 화물총합 %.2d 제시한 총합 %.2d │\n", number[1], number[2], number[3], number[4], number[5], result, result2); Sleep(100);
printf(" └────────────────────────────────┘\n"); Sleep(100);
}
else
{
printf("\n");
printf(" ┌────────────────────────────────┐\n"); Sleep(100);
printf(" │※화물이 제대로 전송되지 못했습니다 │\n"); Sleep(100);
printf(" │ │\n"); Sleep(100);
printf(" │기차번호 %.6d 문서번호 %.6d 보안코드 %.6d │\n", code1, code2, code3); Sleep(100);
printf(" │화물번호 %d %d %d %d %d 화물총합 %.2d 제시한 총합 %.2d │\n", number[1], number[2], number[3], number[4], number[5], result, result2); Sleep(100);
printf(" └────────────────────────────────┘\n"); Sleep(100);
}
getchar();
getchar();
if(count==10)
{
break;
}
count++;
}
code1=rand()%(999999+000000-000000)+000000;
code2=rand()%(999999+000000-000000)+000000;
code3=rand()%(999999+000000-000000)+000000;
system("cls");
printf("\n");
printf(" ┌┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ \n"); Sleep(100);
printf(" ┌─┴┤ │ │ │ │ │ │ │ │ │ │ │@@@@│ \n"); Sleep(100);
printf(" ┌─┘┌┐│ │ T │ │ R │ │ A │ │ I │ │ N │ │@@@@│ \n"); Sleep(100);
printf(" │ │││ │ │ │ │ │ │ │ │ │ ├─┤@@@@│ \n"); Sleep(100);
printf(" └──└┘┘ └──┘ └──┘ └──┘ └──┘ └──┘ └──┘ \n"); Sleep(100);
printf(" ○ ○ ○ ○ ○ ○ ○ ○ \n"); Sleep(100);
printf(" 〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓 \n"); Sleep(100);
printf("\n");
printf(" ┌──┐\n");
printf(" ┌──────────────┤결산├─────────────┐ \n"); Sleep(100);
printf(" │ └──┘ │ \n", point); Sleep(100);
printf(" │ 게임번호 %.6d 점수번호 %.6d 보안코드 %.6d │ \n", code1, code2, code3); Sleep(100);
printf(" │ │ \n"); Sleep(100);
printf(" │ 담당한 기차 : 10 맞춘개수 : %.2d │ \n", point); Sleep(100);
printf(" │ │ \n"); Sleep(100);
printf(" └───────────────────────────────┘ \n"); Sleep(100);
getchar();
return 0;
}