-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGraphicsIndex.cpp
63 lines (56 loc) · 1.92 KB
/
GraphicsIndex.cpp
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*******************************************************
文件名:GraphicsIndex.cpp
功能:存放可视化相关方式
版本:2.0(22.07.17)
作者:石皮幼鸟
版本说明:无
版本日志:
1.0(22.05.28) 完成创建窗口和矩形绘制方式
1.1(22.05.28) 完成了判定鼠标点击区域的方式
1.2(22.05.29) 无
1.3(22.05.31) 更名为GraphicsIndex.cpp
2.0(22.07.17) 无
*******************************************************/
#include "index.h"
/*******************************************************
方式名:void creatWindow()
功能:游戏开启时创建一个窗口
参数:无
返回:无
*******************************************************/
void creatWindow() {
initgraph(1280, 720);
setbkcolor(WHITE);
cleardevice();
settextcolor(BLACK);
settextstyle(150, 0, "微软雅黑");
outtextxy(525, 200, "扫雷");
settextstyle(80, 0, "微软雅黑");
outtextxy(455, 400, "石皮幼鸟制作");
Sleep(3000);
cleardevice();
}
/*******************************************************
方式名:void creatRect(int x, int y, int height, int width, COLORREF color)
功能:在背景中创建一个矩形
参数:x,y为矩形起点(左上角)绝对坐标(底层图形坐标会移动到这里),height和width为高和宽,color为线条颜色
返回:无
*******************************************************/
void creatRect(int x, int y, int height, int width, COLORREF color) {
moveto(x, y);
setlinecolor(color);
linerel(width, 0);
linerel(0, height);
linerel(-width, 0);
linerel(0, -height);
}
/*******************************************************
方式名:bool cursorCheck(int x, int y, int xMin, int xMax, int yMin, int yMax)
功能:对鼠标点击区域(矩形)进行判定
参数:x,y为光标绝对坐标,xMin/Max以及yMin/Max分别为x,y的最小/最大绝对坐标
返回:不在该区域返回0,反之返回1
*******************************************************/
bool cursorCheck(int x, int y, int xMin, int xMax, int yMin, int yMax) {
if (xMin <= x && x <= xMax && y <= yMax && y >= yMin) return 1;
else return 0;
}