#define _CRT_SECURE_NO_WARNINGS
#include"UI.h"
//设置图片类
IMAGE BeginImage;
IMAGE GameImage;
//游戏欢迎界面
void UI_WelcomeView()
{
initgraph(700, 500);
setbkmode(TRANSPARENT);
putimage(0, 0, &BeginImage);
setcolor(BLACK);
settextstyle(45, 0, _T("楷体"));
outtextxy(150, 150, "Welcome to the Game");
settextstyle(18, 0, _T("仿宋"));
setcolor(RGB(20, 20, 120));
outtextxy(230, 460, "--按空格键开始游戏--");
Sleep(1000);
}
//游戏开始倒计时函数
void UI_StartView()
{
closegraph();
//存放num转化字符 并留一个‘/0’所以str[2]长度为2
char str[2] = { 0 };
//创建游戏窗口
initgraph(InterfaceX, InterfaceY);
//字体大小及风格
settextstyle(30, 0, _T("仿宋"));
//文字输出
outtextxy(110, 180, "俄罗斯方块开始倒计时");
//倒计时
for (int num = 3; num > 0; num--)
{
//整数
_itoa_s(num, str,10);
//sprintf(str, "%c", num);
outtextxy(240, 480, str);
//延时
Sleep(1e3); //1-1ms
}
}
//显示游戏主界面
void UI_GameView()
{
//清屏函数
cleardevice();
//必须要先清屏,不然会报错
//
//显示图片背景
setbkmode(TRANSPARENT);
putimage(0, 0, &GameImage);
//字体大小及风格
settextstyle(20, 0, _T("仿宋"));
/*
//游戏区域
rectangle(GameViewX_1, GameViewY_1, GameViewX_2, GameViewY_2);
//操作说明框
rectangle(GameOperaX_1, GameOperaY_1, GameOperaX_2, GameOperaY_2);
//分数 级别框
rectangle(GameScoreX_1, GameScoreY_1, GameScoreX_2, GameScoreY_2);
//显示下一个方块框
rectangle(GameRemindX_1, GameRemindY_1, GameRemindX_2, GameRemindY_2);
*/
//文本提示框
outtextxy(350,195,"下一个方块");
settextcolor(RED);
outtextxy(380,260,"分数");
outtextxy(393,285,'0');
outtextxy(380,315,"等级");
outtextxy(393,340,'0');
//操作说明
//颜色也可以用RGB红绿蓝RGB(225,225,225)和十六进制一样的
settextcolor(RGB(150,105,204));
outtextxy(337,410,"操作说明:");
outtextxy(337,440,"←:向左移动");
outtextxy(337,470,"↓:向下移动");
outtextxy(337,500,"→:向右移动");
outtextxy(337,530,"↑:向上移动");
outtextxy(337,560,"Space:方块旋转");
}
//加载图片
void UI_LoadImage()
{
loadimage(&BeginImage, "img/R-C (2).jpg",700,500,1);
loadimage(&GameImage, "img/back1.jpg",500,610,1);
}
评论