質問編集履歴
3
文章とタイトルを編集しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,13 +1,373 @@
|
|
1
|
-
|
1
|
+
下記のコードの////コメントの内部のコードですが外部のクラス内の構造体のインスタンスを配列のポインタに入れる方法はどうすればいいのでしょうか?型名がありませんや不完全な型など様々エラーが発生してしまいどうすればいいかわかりません。Player::Player();コンストラクタの
|
2
|
+
|
2
|
-
|
3
|
+
for文のコードはどうすればいいのでしょうか?
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
|
8
|
+
|
3
|
-
|
9
|
+
![イメージ説明](e7a891452262e2470b6cab42f88b8e0a.png)
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
10
|
|
9
11
|
```cpp
|
10
12
|
|
13
|
+
#ifndef ___PLAYER_HPP_
|
14
|
+
|
15
|
+
#define ___PLAYER_HPP_
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
//自作ヘッダー類
|
20
|
+
|
21
|
+
#include "Sprite.hpp"
|
22
|
+
|
23
|
+
#include "Game.hpp"
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
//標準ヘッダー関係
|
28
|
+
|
29
|
+
#include "stdio.h"
|
30
|
+
|
31
|
+
#include <fstream>
|
32
|
+
|
33
|
+
#include <sstream>
|
34
|
+
|
35
|
+
#include <iostream>
|
36
|
+
|
37
|
+
#include <vector>
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
//OpenGL関係
|
42
|
+
|
43
|
+
#include "GLEW/include/GL/glew.h"
|
44
|
+
|
45
|
+
#include "gl/GL.h"
|
46
|
+
|
47
|
+
#include "GLFW/include/GLFW/glfw3.h"
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
//数学ライブラリ
|
52
|
+
|
53
|
+
#include "glm/ext.hpp"
|
54
|
+
|
55
|
+
#include <glm/ext/vector_int2.hpp>
|
56
|
+
|
57
|
+
//文字描画 ライブラリ
|
58
|
+
|
59
|
+
#include <ft2build.h>
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
//#include FT_FREETYPE_H
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
//class Game;
|
76
|
+
|
77
|
+
class Player
|
78
|
+
|
79
|
+
{
|
80
|
+
|
81
|
+
public:
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
Player(Game* g);
|
86
|
+
|
87
|
+
~Player();
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
void Update();
|
92
|
+
|
93
|
+
void Draw();
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
private:
|
98
|
+
|
99
|
+
Game* mOwner;
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
//////////////////////////////////
|
104
|
+
|
105
|
+
struct BulletData* mBullet[10];
|
106
|
+
|
107
|
+
///////////////////////////////////////////////
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
bool mIsAttack = false;
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
//プレイヤー
|
120
|
+
|
121
|
+
enum eKeyInput key; //プレイヤーのキー入力
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
Sprite* mSprite[4][2];
|
126
|
+
|
127
|
+
glm::ivec2 mPosition; //座標
|
128
|
+
|
129
|
+
glm::ivec2 mVector; //向き
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
int mAnim = 0; //アニメーション管理
|
138
|
+
|
139
|
+
};
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
#endif
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
```
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
```cpp
|
152
|
+
|
153
|
+
#include "Player.hpp"
|
154
|
+
|
155
|
+
#include "Game.hpp"
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
Player::Player(Game* g)
|
160
|
+
|
161
|
+
{
|
162
|
+
|
163
|
+
mOwner = g;
|
164
|
+
|
165
|
+
////////////////////////////////////////////////////////////////////////////
|
166
|
+
|
167
|
+
for (int i = 0; i < 10; i++)
|
168
|
+
|
169
|
+
{
|
170
|
+
|
171
|
+
mBullet[i] = mOwner->BulletData{ false,glm::ivec2(0,0),glm::ivec2(0,0) };
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
// mBullet[i] = struct BulletData_{ false, glm::ivec2(0, 0), glm::ivec2(0, 0) };
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
}
|
180
|
+
|
181
|
+
/////////////////////////////////////////////////////////////////////////////
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
//up
|
188
|
+
|
189
|
+
mSprite[0][0] = new Sprite(mOwner, "Assets/Player.png", glm::ivec2(0, 0), glm::ivec2(CELL, CELL));
|
190
|
+
|
191
|
+
mSprite[0][1] = new Sprite(mOwner, "Assets/Player.png", glm::ivec2(CELL * 1, 0), glm::ivec2(CELL, CELL));
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
//left
|
196
|
+
|
197
|
+
mSprite[1][0] = new Sprite(mOwner, "Assets/Player.png", glm::ivec2(CELL * 2, 0), glm::ivec2(CELL, CELL));
|
198
|
+
|
199
|
+
mSprite[1][1] = new Sprite(mOwner, "Assets/Player.png", glm::ivec2(CELL * 3, 0), glm::ivec2(CELL, CELL));
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
//down
|
204
|
+
|
205
|
+
mSprite[2][0] = new Sprite(mOwner, "Assets/Player.png", glm::ivec2(CELL * 4, 0), glm::ivec2(CELL, CELL));
|
206
|
+
|
207
|
+
mSprite[2][1] = new Sprite(mOwner, "Assets/Player.png", glm::ivec2(CELL * 5, 0), glm::ivec2(CELL, CELL));
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
//right
|
212
|
+
|
213
|
+
mSprite[3][0] = new Sprite(mOwner, "Assets/Player.png", glm::ivec2(CELL * 6, 0), glm::ivec2(CELL, CELL));
|
214
|
+
|
215
|
+
mSprite[3][1] = new Sprite(mOwner, "Assets/Player.png", glm::ivec2(CELL * 7, 0), glm::ivec2(CELL, CELL));
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
}
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
void Player::Update()
|
234
|
+
|
235
|
+
{
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
}
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
void Player::Draw()
|
244
|
+
|
245
|
+
{
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
}
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
Player::~Player()
|
264
|
+
|
265
|
+
{
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
}
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
```
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
```cpp
|
278
|
+
|
279
|
+
#ifndef ___GMAE_H_
|
280
|
+
|
281
|
+
#define ___GMAE_H_
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
#define CELL 48
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
//画面サイズを指定
|
290
|
+
|
291
|
+
#define WIDTH (16 * 70)
|
292
|
+
|
293
|
+
#define HEIGHT (9 * 70)
|
294
|
+
|
295
|
+
#define PI (3.14159265359f) //円周率
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
#define STAGE_HEIGHT 16
|
302
|
+
|
303
|
+
#define STAGE_WIDTH 23
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
//自作ヘッダー 関係
|
310
|
+
|
311
|
+
#include "Camera.hpp"
|
312
|
+
|
313
|
+
#include "Font.hpp"
|
314
|
+
|
315
|
+
#include "Sprite.hpp"
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
//標準ヘッダー関係
|
322
|
+
|
323
|
+
#include "stdio.h"
|
324
|
+
|
325
|
+
#include <fstream>
|
326
|
+
|
327
|
+
#include <sstream>
|
328
|
+
|
329
|
+
#include <iostream>
|
330
|
+
|
331
|
+
#include <vector>
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
//OpenGL関係
|
336
|
+
|
337
|
+
#include "GLEW/include/GL/glew.h"
|
338
|
+
|
339
|
+
#include "gl/GL.h"
|
340
|
+
|
341
|
+
#include "GLFW/include/GLFW/glfw3.h"
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
//数学ライブラリ
|
346
|
+
|
347
|
+
#include "glm/ext.hpp"
|
348
|
+
|
349
|
+
#include <glm/ext/vector_int2.hpp>
|
350
|
+
|
351
|
+
//文字描画 ライブラリ
|
352
|
+
|
353
|
+
#include <ft2build.h>
|
354
|
+
|
355
|
+
//#include FT_FREETYPE_H
|
356
|
+
|
357
|
+
|
358
|
+
|
359
|
+
|
360
|
+
|
361
|
+
|
362
|
+
|
363
|
+
//前方宣言
|
364
|
+
|
365
|
+
class Mesh;
|
366
|
+
|
367
|
+
class Sprite;
|
368
|
+
|
369
|
+
class Font;
|
370
|
+
|
11
371
|
|
12
372
|
|
13
373
|
class Game
|
@@ -90,9 +450,9 @@
|
|
90
450
|
|
91
451
|
//----------------------------------------------------------------描画オブジェクト
|
92
452
|
|
93
|
-
|
94
|
-
|
95
|
-
|
453
|
+
//////////////////////////////////////////
|
454
|
+
|
455
|
+
struct BulletData
|
96
456
|
|
97
457
|
{
|
98
458
|
|
@@ -108,224 +468,102 @@
|
|
108
468
|
|
109
469
|
};
|
110
470
|
|
471
|
+
////////////////////////////////////////
|
472
|
+
|
473
|
+
|
474
|
+
|
475
|
+
Sprite* gBullet[4];
|
476
|
+
|
477
|
+
|
478
|
+
|
479
|
+
enum class eKeyInput
|
480
|
+
|
481
|
+
{
|
482
|
+
|
483
|
+
Up,
|
484
|
+
|
485
|
+
Down,
|
486
|
+
|
487
|
+
Left,
|
488
|
+
|
489
|
+
Right,
|
490
|
+
|
491
|
+
Invalid,
|
492
|
+
|
493
|
+
};
|
494
|
+
|
495
|
+
|
496
|
+
|
497
|
+
|
498
|
+
|
499
|
+
//マップ
|
500
|
+
|
501
|
+
Sprite* Map[100];
|
502
|
+
|
503
|
+
|
504
|
+
|
505
|
+
|
506
|
+
|
507
|
+
|
508
|
+
|
509
|
+
int stage[STAGE_HEIGHT][STAGE_WIDTH] =
|
510
|
+
|
511
|
+
{
|
512
|
+
|
513
|
+
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
|
514
|
+
|
515
|
+
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
|
516
|
+
|
517
|
+
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
|
518
|
+
|
519
|
+
{0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
|
520
|
+
|
521
|
+
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
|
522
|
+
|
523
|
+
{0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0},
|
524
|
+
|
525
|
+
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0},
|
526
|
+
|
527
|
+
{0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0},
|
528
|
+
|
529
|
+
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
|
530
|
+
|
531
|
+
{0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0},
|
532
|
+
|
533
|
+
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
|
534
|
+
|
535
|
+
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
|
536
|
+
|
537
|
+
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
|
538
|
+
|
539
|
+
|
540
|
+
|
541
|
+
|
542
|
+
|
543
|
+
|
544
|
+
|
545
|
+
};
|
546
|
+
|
547
|
+
|
548
|
+
|
549
|
+
|
550
|
+
|
551
|
+
|
552
|
+
|
553
|
+
|
554
|
+
|
555
|
+
|
556
|
+
|
557
|
+
Font* font;
|
558
|
+
|
559
|
+
|
560
|
+
|
561
|
+
|
562
|
+
|
563
|
+
...関係ないので省略
|
564
|
+
|
565
|
+
|
566
|
+
|
111
567
|
};
|
112
568
|
|
113
569
|
```
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
```cpp
|
118
|
-
|
119
|
-
#ifndef ___PLAYER_HPP_
|
120
|
-
|
121
|
-
#define ___PLAYER_HPP_
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
//自作ヘッダー類
|
126
|
-
|
127
|
-
#include "Sprite.hpp"
|
128
|
-
|
129
|
-
#include "Game.hpp"
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
//標準ヘッダー関係
|
134
|
-
|
135
|
-
#include "stdio.h"
|
136
|
-
|
137
|
-
#include <fstream>
|
138
|
-
|
139
|
-
#include <sstream>
|
140
|
-
|
141
|
-
#include <iostream>
|
142
|
-
|
143
|
-
#include <vector>
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
//OpenGL関係
|
148
|
-
|
149
|
-
#include "GLEW/include/GL/glew.h"
|
150
|
-
|
151
|
-
#include "gl/GL.h"
|
152
|
-
|
153
|
-
#include "GLFW/include/GLFW/glfw3.h"
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
//数学ライブラリ
|
158
|
-
|
159
|
-
#include "glm/ext.hpp"
|
160
|
-
|
161
|
-
#include <glm/ext/vector_int2.hpp>
|
162
|
-
|
163
|
-
//文字描画 ライブラリ
|
164
|
-
|
165
|
-
#include <ft2build.h>
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
//#include FT_FREETYPE_H
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
class Game;
|
182
|
-
|
183
|
-
class Player
|
184
|
-
|
185
|
-
{
|
186
|
-
|
187
|
-
public:
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
Player(Game* g);
|
192
|
-
|
193
|
-
~Player();
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
void Update();
|
198
|
-
|
199
|
-
void Draw();
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
private:
|
204
|
-
|
205
|
-
Game* mOwner;
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
//struct BulletData_* mBullet[10];
|
210
|
-
|
211
|
-
mOwner->BulletData* mBullet[10];
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
bool mIsAttack = false;
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
//プレイヤー
|
226
|
-
|
227
|
-
enum eKeyInput key; //プレイヤーのキー入力
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
Sprite* mSprite[4][2];
|
232
|
-
|
233
|
-
glm::ivec2 mPosition; //座標
|
234
|
-
|
235
|
-
glm::ivec2 mVector; //向き
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
int mAnim = 0; //アニメーション管理
|
244
|
-
|
245
|
-
};
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
#endif
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
```
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
```cpp
|
258
|
-
|
259
|
-
#include "Player.hpp"
|
260
|
-
|
261
|
-
#include "Game.hpp"
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
Player::Player(Game* g)
|
268
|
-
|
269
|
-
{
|
270
|
-
|
271
|
-
mOwner = g;
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
for (int i = 0; i < 10; i++)
|
276
|
-
|
277
|
-
{
|
278
|
-
|
279
|
-
////
|
280
|
-
|
281
|
-
}
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
//up
|
290
|
-
|
291
|
-
mSprite[0][0] = new Sprite(mOwner, "Assets/Player.png", glm::ivec2(0, 0), glm::ivec2(CELL, CELL));
|
292
|
-
|
293
|
-
mSprite[0][1] = new Sprite(mOwner, "Assets/Player.png", glm::ivec2(CELL * 1, 0), glm::ivec2(CELL, CELL));
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
//left
|
298
|
-
|
299
|
-
mSprite[1][0] = new Sprite(mOwner, "Assets/Player.png", glm::ivec2(CELL * 2, 0), glm::ivec2(CELL, CELL));
|
300
|
-
|
301
|
-
mSprite[1][1] = new Sprite(mOwner, "Assets/Player.png", glm::ivec2(CELL * 3, 0), glm::ivec2(CELL, CELL));
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
//down
|
306
|
-
|
307
|
-
mSprite[2][0] = new Sprite(mOwner, "Assets/Player.png", glm::ivec2(CELL * 4, 0), glm::ivec2(CELL, CELL));
|
308
|
-
|
309
|
-
mSprite[2][1] = new Sprite(mOwner, "Assets/Player.png", glm::ivec2(CELL * 5, 0), glm::ivec2(CELL, CELL));
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
//right
|
314
|
-
|
315
|
-
mSprite[3][0] = new Sprite(mOwner, "Assets/Player.png", glm::ivec2(CELL * 6, 0), glm::ivec2(CELL, CELL));
|
316
|
-
|
317
|
-
mSprite[3][1] = new Sprite(mOwner, "Assets/Player.png", glm::ivec2(CELL * 7, 0), glm::ivec2(CELL, CELL));
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
}
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
```
|
2
質問内容を編集しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,14 +1,4 @@
|
|
1
|
-
///のコードですが依存性の注入で外部の構造体のインスタンスのアドレスを変数に入れる方法がわかりません。
|
1
|
+
Player::Player()コンストラクタ///のコードですが依存性の注入で外部のGame::BulletData構造体のインスタンスのアドレスを変数に入れる方法がわかりません。
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
エラーコード
|
6
|
-
|
7
|
-
![イメージ説明](e73b44cd3d0e71fa6dee944f1a498b9c.png)
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
2
|
|
13
3
|
|
14
4
|
|
@@ -20,6 +10,172 @@
|
|
20
10
|
|
21
11
|
|
22
12
|
|
13
|
+
class Game
|
14
|
+
|
15
|
+
{
|
16
|
+
|
17
|
+
public:
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
Game(); //コンストラクタ
|
22
|
+
|
23
|
+
bool Initialization(); //初期化
|
24
|
+
|
25
|
+
bool RunLoop(); //メインループ
|
26
|
+
|
27
|
+
void Update(); //計算
|
28
|
+
|
29
|
+
void GenerateOutput(); //描画
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
bool mIsRunLoop; //メインループ
|
34
|
+
|
35
|
+
void KeyInput(); //キー入力
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
//頂点属性
|
44
|
+
|
45
|
+
struct VertexAttribute {
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
GLfloat Position[3]; //頂点座標
|
50
|
+
|
51
|
+
GLfloat uv[2]; //UV座標
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
};
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
//----------------------------------------------------------------描画オブジェクト
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
//キューブ
|
68
|
+
|
69
|
+
std::vector<Game::VertexAttribute> vertex; //頂点
|
70
|
+
|
71
|
+
std::vector<unsigned int> vertex_index; //インデックス
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
//地面
|
76
|
+
|
77
|
+
std::vector<Game::VertexAttribute> Ground; //頂点
|
78
|
+
|
79
|
+
std::vector<unsigned int> Ground_index; //インデックス
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
//----------------------------------------------------------------描画オブジェクト
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
struct BulletData////////////////////////////////////////////////////////////////
|
96
|
+
|
97
|
+
{
|
98
|
+
|
99
|
+
bool frag;
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
glm::ivec2 pos; //弾の座標
|
104
|
+
|
105
|
+
glm::ivec2 vec; //弾の飛んでいく向き
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
};
|
110
|
+
|
111
|
+
};
|
112
|
+
|
113
|
+
```
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
```cpp
|
118
|
+
|
119
|
+
#ifndef ___PLAYER_HPP_
|
120
|
+
|
121
|
+
#define ___PLAYER_HPP_
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
//自作ヘッダー類
|
126
|
+
|
127
|
+
#include "Sprite.hpp"
|
128
|
+
|
129
|
+
#include "Game.hpp"
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
//標準ヘッダー関係
|
134
|
+
|
135
|
+
#include "stdio.h"
|
136
|
+
|
137
|
+
#include <fstream>
|
138
|
+
|
139
|
+
#include <sstream>
|
140
|
+
|
141
|
+
#include <iostream>
|
142
|
+
|
143
|
+
#include <vector>
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
//OpenGL関係
|
148
|
+
|
149
|
+
#include "GLEW/include/GL/glew.h"
|
150
|
+
|
151
|
+
#include "gl/GL.h"
|
152
|
+
|
153
|
+
#include "GLFW/include/GLFW/glfw3.h"
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
//数学ライブラリ
|
158
|
+
|
159
|
+
#include "glm/ext.hpp"
|
160
|
+
|
161
|
+
#include <glm/ext/vector_int2.hpp>
|
162
|
+
|
163
|
+
//文字描画 ライブラリ
|
164
|
+
|
165
|
+
#include <ft2build.h>
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
//#include FT_FREETYPE_H
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
|
178
|
+
|
23
179
|
|
24
180
|
|
25
181
|
class Game;
|
@@ -52,7 +208,7 @@
|
|
52
208
|
|
53
209
|
//struct BulletData_* mBullet[10];
|
54
210
|
|
55
|
-
|
211
|
+
mOwner->BulletData* mBullet[10];
|
56
212
|
|
57
213
|
|
58
214
|
|
@@ -92,12 +248,18 @@
|
|
92
248
|
|
93
249
|
#endif
|
94
250
|
|
251
|
+
|
252
|
+
|
95
253
|
```
|
96
254
|
|
97
255
|
|
98
256
|
|
99
257
|
```cpp
|
100
258
|
|
259
|
+
#include "Player.hpp"
|
260
|
+
|
261
|
+
#include "Game.hpp"
|
262
|
+
|
101
263
|
|
102
264
|
|
103
265
|
|
@@ -114,7 +276,7 @@
|
|
114
276
|
|
115
277
|
{
|
116
278
|
|
117
|
-
|
279
|
+
////
|
118
280
|
|
119
281
|
}
|
120
282
|
|
@@ -166,6 +328,4 @@
|
|
166
328
|
|
167
329
|
|
168
330
|
|
169
|
-
|
170
|
-
|
171
331
|
```
|
1
文章とタイトルを編集しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,6 +1,98 @@
|
|
1
1
|
///のコードですが依存性の注入で外部の構造体のインスタンスのアドレスを変数に入れる方法がわかりません。このコンパイルエラーはどうやって解決するのでしょうか?
|
2
2
|
|
3
3
|
|
4
|
+
|
5
|
+
エラーコード
|
6
|
+
|
7
|
+
![イメージ説明](e73b44cd3d0e71fa6dee944f1a498b9c.png)
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
```cpp
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
class Game;
|
26
|
+
|
27
|
+
class Player
|
28
|
+
|
29
|
+
{
|
30
|
+
|
31
|
+
public:
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
Player(Game* g);
|
36
|
+
|
37
|
+
~Player();
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
void Update();
|
42
|
+
|
43
|
+
void Draw();
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
private:
|
48
|
+
|
49
|
+
Game* mOwner;
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
//struct BulletData_* mBullet[10];
|
54
|
+
|
55
|
+
struct mOwner->BulletData_* mBullet[10];
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
bool mIsAttack = false;
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
//プレイヤー
|
70
|
+
|
71
|
+
enum eKeyInput key; //プレイヤーのキー入力
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
Sprite* mSprite[4][2];
|
76
|
+
|
77
|
+
glm::ivec2 mPosition; //座標
|
78
|
+
|
79
|
+
glm::ivec2 mVector; //向き
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
int mAnim = 0; //アニメーション管理
|
88
|
+
|
89
|
+
};
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
#endif
|
94
|
+
|
95
|
+
```
|
4
96
|
|
5
97
|
|
6
98
|
|