第三天效果图如下
#include <stdio.h>
#include"day3.h"
int main()
{
Manager manager;
Control control;
intiGame(&manager,&control);//初始化游戏
printNextTetris(&manager);
do
{
printPrompting();
printPoolBorder();
printScore(&manager);//显示得分
}while(1);
return 0;
}
//初始化游戏
void intiGame(Manager* manager,Control*control)
{
Output=GetStdHandle(STD_OUTPUT_HANDLE);
//定义光标隐藏变量并初始化
CONSOLE_CURSOR_INFO info;
info.bVisible=FALSE;//FAlse为光标隐藏
info.dwSize=1;//光标高度为1-100 标准是100
//设置光标隐藏
SetConsoleCursorInfo(Output,&info);
SetConsoleTitle("俄罗斯方块");//控制台句柄
startGame(manager,control);//调用游戏
}
//游戏池
void printPoolBorder()
{
int y;
SetConsoleTextAttribute(Output,0xf0);
for(y=4;y<26;y++)
{
//两条纵线
gotoxyWithFullwidth(10,y-3);//鼠标定位
printf("%2s"," ");
gotoxyWithFullwidth(23,y-3);//鼠标定位
printf("%2s"," ");
}
gotoxyWithFullwidth(10,y-3);//一条横线
printf("%28s"," ");
}
//显示全角定位
void gotoxyWithFullwidth(short x,short y)
{
static COORD cd;
cd.X= x*2;//移动1个坐标乘以2,改变2个像素点的 距离
cd.Y=y;
SetConsoleCursorPosition(Output,cd);//移动光标到指定位置
}
//按键提示信息
void printPrompting()
{
//设置文字颜色,高亮
SetConsoleTextAttribute(Output,0x0B);
//设置文字位置
gotoxyWithFullwidth(26,10);