-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic.cpp
More file actions
39 lines (34 loc) · 818 Bytes
/
Copy pathbasic.cpp
File metadata and controls
39 lines (34 loc) · 818 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//basic.cpp文件
//光标移动到指定坐标处
void gotoxy(int x,int y)
{
HANDLE h;//句柄,对象的索引
COORD c;//结构体,坐标值
c.X=x;
c.Y=y;
h=GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(h,c);
}
//隐藏光标
void hide_cursor()
{
HANDLE h_GAME = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO cursor_info;
GetConsoleCursorInfo(h_GAME,&cursor_info);
cursor_info.bVisible=false; //不显示光标
SetConsoleCursorInfo(h_GAME,&cursor_info);
}
//显示光标
void show_cursor()
{
HANDLE h_GAME = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO cursor_info;
GetConsoleCursorInfo(h_GAME,&cursor_info);
cursor_info.bVisible=true; //显示光标
SetConsoleCursorInfo(h_GAME,&cursor_info);
}
//设置文本颜色
void color(int a)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),a);
}