【游戏开发】天龙八部小demo

//stdfax.h

#ifndef STDFAX_H
#define STDFAX_H

//输入输出函数包含的头文件
#include <stdio.h>

//system函数包含的头文件
#include <stdlib.h>

//设置光标位置包含的头文件
#include <windows.h>

//时间函数包含的头文件
#include <time.h>

//设置输入,输出的位置,也就是当前光标位置
void setxy(int x, int y);

//欢迎函数
int welcome();

#endif
//setxy.cpp

#include "stdfax.h"

void setxy(int x, int y)
{
	COORD coord = { x, y };
	SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
//welcome.cpp

#include "stdfax.h"

int welcome()
{
	//设置窗口标题
	SetConsoleTitle(L"《新天龙八部》1.0");

	//设置窗口大小100×50
	system("mode con cols=100 lines=50");

	//设置白底红字
	system("color f4");

	//设置光标到窗口中央
	setxy(25, 20);

	//输出欢迎语居中显示
	printf("欢迎来到《天龙八部》游戏世界!");

	//设置系统时间
	time_t t;
	struct tm * lt;
	time(&t);
	lt = localtime(&t);
	printf("今天是%d/%d/%d %d:%d:%d\n", lt->tm_year + 1900, lt->tm_mon + 1, lt->tm_mday, lt->tm_hour, lt->tm_min, lt->tm_sec);

	//请按任意键继续
	getchar();

	//清屏
	system("cls");

	//设置光标
	setxy(40, 10);

	//输出健康游戏忠告
	printf("健康游戏忠告\n\n\n");

	//设置光标
	setxy(32, 12);

	printf("抵制不良游戏,拒绝盗版游戏\n");

	//设置光标
	setxy(32, 13);

	printf("注意自我保护,谨防受骗上当\n");

	//设置光标
	setxy(32, 14);

	printf("适度游戏益脑,沉迷游戏伤身\n");

	//设置光标
	setxy(32, 15);

	printf("合理安排时间,享受健康生活\n");

	//按任意键结束
	system("pause");
	return 0;
}
//main.cpp

//进入游戏提示:欢迎来到《天龙八部》游戏世界
#include "stdfax.h"

int main()
{
	welcome();

	return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_23996157/article/details/90109265