#include "tools.h" #include #include 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); }