mirror of https://github.com/string1995/eee102.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
956 B
33 lines
956 B
#include "tools.h" |
|
#include <windows.h> |
|
#include <stdio.h> |
|
|
|
void SetWindowSize(int cols, int lines)//设置窗口大小 |
|
{ |
|
system("title 贪吃蛇");//设置窗口标题 |
|
char cmd[30]; |
|
sprintf(cmd, "mode con cols=%d lines=%d", cols * 2, lines);//一个图形■占两个字符,故宽度乘以2 |
|
system(cmd);//system(mode con cols=88 lines=88)设置窗口宽度和高度 |
|
} |
|
|
|
void SetCursorPosition(const int x, const int y)//设置光标位置 |
|
{ |
|
COORD position; |
|
position.X = x * 2; |
|
position.Y = y; |
|
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), position); |
|
} |
|
|
|
void SetColor(int colorID)//设置文本颜色 |
|
{ |
|
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), colorID); |
|
} |
|
|
|
void SetBackColor()//设置文本背景色 |
|
{ |
|
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), |
|
FOREGROUND_BLUE | |
|
BACKGROUND_BLUE | |
|
BACKGROUND_GREEN | |
|
BACKGROUND_RED ); |
|
}
|
|
|