【游戏开发】天龙八部小demo,游戏开发demo
//stdafx.h
#ifndef STDAFX_H
#define STDAFX_H
//输入输出函数包含的头文件
#include <stdio.h>
//system函数包含的头文件
#include <stdlib.h>
//设置光标位置包含的头文件
#include <windows.h>
//时间函数包含的头文件
#include <time.h>
//播放音乐函数的头文件
#pragma comment(lib,"Winmm.lib")
//播放音乐
void play_music();
//设置输入,输出的位置,也就是当前光标位置
void setxy(int x, int y);
//欢迎界面,进入游戏提示:欢迎来到《天龙八部》游戏世界
int welcome();
//选择服务器
int select_server();
#endif
//setxy.cpp
#include "stdafx.h"
void setxy(int x, int y)
{
COORD coord = { x, y };
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
//welcome.cpp
#include "stdafx.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;
}
//play_music.cpp
#include "stdafx.h"
void play_music()
{
PlaySound(TEXT("摩登兄弟 - 我行即我道.wav"), NULL, SND_FILENAME | SND_ASYNC | SND_LOOP);
}
//select_server.cpp
#include "stdafx.h"
int select_server()
{
//清屏
system("cls");
//设置光标
setxy(40,10);
//推荐服务器:西北电信一区
printf("推荐服务器:西北电信一区");
//设置光标
setxy(20,12);
//服务器列表
printf("·梨花针\t·楼兰古城\t·大漠孤烟\t·敦煌飞天\t·昆仑山");
//设置光标
setxy(20, 14);
printf("·火焰山\t·星宿海\t·夜明珠\t·镇北堡\t·兰山书院");
//设置光标
setxy(20, 16);
printf("·虚竹\n");
system("pause");
return 0;
}
//main.cpp
#include "stdafx.h"
int main()
{
play_music();
welcome();
select_server();
return 0;
}
评论暂时关闭