forked from Kiritouse/TouHouInc--
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOperation.cpp
103 lines (95 loc) · 2.54 KB
/
Operation.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#include "Operation.h"
#include "GameManager.h"
#include "Interface.h"
#include "DataManager.h"
#include <graphics.h>
#include <Windows.h>
#define START_BUTTON (m.x >= 140 && m.x <= 349 && m.y >= 400 && m.y <= 464)
#define PAUSE_BUTTON (m.x >= 0 && m.x <= 44 && m.y >= 676 && m.y <= 720)
#define SAVE_BUTTON (m.x>=120&&m.x<=376&&m.y>=400&&m.y<=450)
#define CONTINUE_BUTTON (m.x>=150&&m.x<=339&&m.y>=500&&m.y<=559)
static int PauseFlag = 0;
int GetInput() {
int inputState = CMD_NO_INPUT;
if (GetAsyncKeyState(VK_LEFT) & 0x8000) inputState |= CMD_LEFT;//更新为当前的状态
if (GetAsyncKeyState(VK_RIGHT) & 0x8000) inputState |= CMD_RIGHT;
if (GetAsyncKeyState(VK_UP) & 0x8000) inputState |= CMD_UP;
if (GetAsyncKeyState(VK_DOWN) & 0x8000) inputState |= CMD_DOWN;
if (GetAsyncKeyState('Z') && 0X8000) inputState |= CMD_FIRE;
if (GetAsyncKeyState('X') && 0X8000) inputState |= CMD_SKILL;
return inputState;
}
void MouseLisenter() {
HWND hwnd = GetHWnd(); //获取绘图窗口句柄
HWND hwnd_now = GetForegroundWindow(); //获取当前焦点窗口句柄
MOUSEMSG m;
HCURSOR hcur;
if (MouseHit() && gameState.startUI) {//如果说鼠标点击了,并且在游戏开始界面的UI
//判断是点击的是哪按键
m = GetMouseMsg();
if (START_BUTTON)
buttonState.enterButtonIsHit = 1;
else
buttonState.enterButtonIsHit = 0;
if (CONTINUE_BUTTON)
buttonState.continueButtonIsHit = 1;
else
buttonState.continueButtonIsHit = 0;
switch (m.uMsg)
{
case WM_LBUTTONDOWN://当按下了鼠标左键
if (START_BUTTON) {
gameState.startUI = 0;
gameState.gaming = 1;
}
if (CONTINUE_BUTTON) {//读取存档
if (isSave == 1)//代表有存档
loadData(OBJ_Player);
else std::cout << "没有存档,请开始新的游戏" << std::endl;
}
default:
break;
}
}
if (MouseHit() && gameState.gaming) {
m = GetMouseMsg();
switch (m.uMsg)
{
case WM_LBUTTONDOWN:
if (PAUSE_BUTTON) {
//std::cout << "asdasdsa" << std::endl;
if (PauseFlag) {//上一次的状态是暂停
gameState.pause = 0;
PauseFlag = 0;//情况暂停状态
}
else {//上一次的状态是游戏中
gameState.pause = 1;
frame.f_zawarudo = frame.f_total;//记录下当前暂停时的时间
PauseFlag = 1;//进入暂停状态
}
}
default:
break;
}
}
if (MouseHit() && gameState.gaming && gameState.pause) {
m = GetMouseMsg();
if (SAVE_BUTTON) {
buttonState.saveButtonIsHit = 1;
}
else
buttonState.saveButtonIsHit = 0;
switch (m.uMsg)
{
case WM_LBUTTONDOWN://当按下了鼠标左键
if (SAVE_BUTTON) {
writeData();
isSave = 1;
}
else
break;
default:
break;
}
}
}