-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMouse_Window.cpp
More file actions
30 lines (26 loc) · 809 Bytes
/
Mouse_Window.cpp
File metadata and controls
30 lines (26 loc) · 809 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
#include "Mouse_Window.h"
int Mouse_Window::DrawSnake()
{
if (flag_mouse_time > 0) {
flag_mouse_time++;
if (flag_mouse_time > 3) { flag_mouse_time = 0; }
}
else if (flag_mouse_time == 0 && input->GetMouseMove()) {
if (point_sum.size() > 4) {
point_sum.erase(point_sum.begin(), point_sum.begin() + 1);//删除多余的元素
}
Point* temp = new Point(input->GetNowPoint()->x, input->GetNowPoint()->y);//创建新的鼠标点
point_sum.emplace_back(temp);//加入缓冲区
flag_mouse_time++;//开始计时
}
//绘制鼠标移动线路
for (int i = 1; i < point_sum.size(); i++) {
main_window->DrawLine(point_sum[i - 1]->x, point_sum[i - 1]->y, point_sum[i]->x, point_sum[i]->y);
}
return 0;
}
Mouse_Window::Mouse_Window(Input* input_,Main_Window* main_window_)
{
input = input_;
main_window = main_window_;
}