回答編集履歴
2
追記
test
CHANGED
@@ -1 +1,111 @@
|
|
1
1
|
あなたが作ったモジュール(KeyInput)をリンクしてないのでは?
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
[追記] KeyInput(改)
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
```C++
|
10
|
+
|
11
|
+
/*KeyInput.h*/
|
12
|
+
|
13
|
+
#pragma once
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
class KeyInput {
|
18
|
+
|
19
|
+
private:
|
20
|
+
|
21
|
+
int key_is_pressing_for[256];
|
22
|
+
|
23
|
+
const int* key_state_pointer;
|
24
|
+
|
25
|
+
char keys[256];
|
26
|
+
|
27
|
+
const char* key_pointer;
|
28
|
+
|
29
|
+
public:
|
30
|
+
|
31
|
+
void refresh_keys();
|
32
|
+
|
33
|
+
int get_key_state(int id) const;
|
34
|
+
|
35
|
+
const char* get_key_pointer() const;
|
36
|
+
|
37
|
+
const int* get_key_state_pointer() const;
|
38
|
+
|
39
|
+
KeyInput();
|
40
|
+
|
41
|
+
};
|
42
|
+
|
43
|
+
```
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
```C++
|
48
|
+
|
49
|
+
/* KeyInput.cpp */
|
50
|
+
|
51
|
+
#include <DxLib.h>
|
52
|
+
|
53
|
+
#include "KeyInput.h"
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
void KeyInput::refresh_keys() {
|
58
|
+
|
59
|
+
GetHitKeyStateAll(keys);
|
60
|
+
|
61
|
+
for ( int i = 0; i <= 256; i++) {
|
62
|
+
|
63
|
+
if (keys[i] != 0) {
|
64
|
+
|
65
|
+
key_is_pressing_for[i]++;
|
66
|
+
|
67
|
+
} else {
|
68
|
+
|
69
|
+
key_is_pressing_for[i] = 0;
|
70
|
+
|
71
|
+
}
|
72
|
+
|
73
|
+
}
|
74
|
+
|
75
|
+
}
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
int KeyInput::get_key_state(int id) const {
|
80
|
+
|
81
|
+
return key_is_pressing_for[id];
|
82
|
+
|
83
|
+
}
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
const char* KeyInput::get_key_pointer() const {
|
88
|
+
|
89
|
+
return key_pointer;
|
90
|
+
|
91
|
+
}
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
const int* KeyInput::get_key_state_pointer() const {
|
96
|
+
|
97
|
+
return key_is_pressing_for;
|
98
|
+
|
99
|
+
}
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
KeyInput::KeyInput() {
|
104
|
+
|
105
|
+
key_pointer = keys;
|
106
|
+
|
107
|
+
key_state_pointer = key_is_pressing_for;
|
108
|
+
|
109
|
+
}
|
110
|
+
|
111
|
+
```
|
1
微修正
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
あなたが作ったモジュールをリンクしてないのでは?
|
1
|
+
あなたが作ったモジュール(KeyInput)をリンクしてないのでは?
|