質問編集履歴

1

情報の不足

2020/03/31 05:33

投稿

gRivXOzYyYyDl1W
gRivXOzYyYyDl1W

スコア20

test CHANGED
File without changes
test CHANGED
@@ -159,3 +159,163 @@
159
159
  }
160
160
 
161
161
  ```
162
+
163
+ ```
164
+
165
+ /*
166
+
167
+ Square,Shapeクラスの定義
168
+
169
+ Square<-Shape<-Field_Objectの親子関係
170
+
171
+ */
172
+
173
+ Squareクラス
174
+
175
+ Square::Square(D3DPRIMITIVETYPE shape_style, D3DXVECTOR3 location, D3DXCOLOR RGB,float size):pVB(0),Shape(shape_style,location.x,location.y,0.f)
176
+
177
+ {
178
+
179
+ shape = shape_style;
180
+
181
+ if (pD3DDevice == 0) {
182
+
183
+ cout << "pD3DDeviceの確保ミス。Squareで発生。";
184
+
185
+ }
186
+
187
+ if (FAILED(pD3DDevice->CreateVertexBuffer(5 * sizeof(SHAPE_VERTEX),
188
+
189
+ D3DUSAGE_WRITEONLY,
190
+
191
+ SHAPE_VERTEX_FVF,
192
+
193
+ D3DPOOL_MANAGED, &pVB,NULL)) ) {
194
+
195
+ cout << "Squareの確保ミス";
196
+
197
+ }
198
+
199
+ SHAPE_VERTEX* vertex;
200
+
201
+ pVB->Lock(0, 0, (void**)&vertex, 0);
202
+
203
+ vertex[0].p= D3DXVECTOR3(location.x-(size/2), location.y + (size / 2), 0.f);
204
+
205
+ vertex[1].p = D3DXVECTOR3(location.x + (size / 2), location.y + (size / 2), 0.f);
206
+
207
+ vertex[2].p = D3DXVECTOR3(location.x + (size / 2), location.y - (size / 2), 0.f);
208
+
209
+ vertex[3].p = D3DXVECTOR3(location.x - (size / 2), location.y - (size / 2), 0.f);
210
+
211
+ vertex[4].p = vertex[0].p;
212
+
213
+ vertex[0].color = vertex[1].color = vertex[2].color = vertex[3].color = vertex[4].color = RGB;
214
+
215
+ pVB->Unlock();
216
+
217
+ pD3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
218
+
219
+ pD3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TEXTURE);
220
+
221
+ pD3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE); //掛け算
222
+
223
+
224
+
225
+ return;
226
+
227
+ };
228
+
229
+
230
+
231
+
232
+
233
+ void Square::Update() {
234
+
235
+ }
236
+
237
+
238
+
239
+
240
+
241
+ void Square::Draw() {
242
+
243
+ if (pVB == 0) {
244
+
245
+ cout << "ない。Squareで発生。";
246
+
247
+ }
248
+
249
+ pD3DDevice->SetStreamSource(0, pVB, 0, sizeof(SHAPE_VERTEX));
250
+
251
+ pD3DDevice->SetFVF(SHAPE_VERTEX_FVF);
252
+
253
+ pD3DDevice->DrawPrimitive(D3DPT_LINESTRIP, 0, 4);
254
+
255
+ }
256
+
257
+
258
+
259
+ --------------------------------------------------------------------
260
+
261
+ Shaepクラス
262
+
263
+ Shape::Shape(D3DPRIMITIVETYPE shape_style, float x, float y, float depth):Field_Object(x,y,depth){
264
+
265
+ shape = shape_style;
266
+
267
+ }
268
+
269
+
270
+
271
+ ```
272
+
273
+ ```
274
+
275
+ //Square,Shapeクラスの宣言
276
+
277
+ class Shape:public Field_Object{
278
+
279
+ public:
280
+
281
+ Shape(D3DPRIMITIVETYPE shape_style, float x, float y, float depth);
282
+
283
+ D3DPRIMITIVETYPE shape;
284
+
285
+ };
286
+
287
+ class Square:public Shape {
288
+
289
+ public:
290
+
291
+ Square(D3DPRIMITIVETYPE shape_style, D3DXVECTOR3 location,D3DXCOLOR RGB,float size);
292
+
293
+ HRESULT Create(D3DPRIMITIVETYPE shape_style, float x, float y, float depth, float size);
294
+
295
+ void Update() override;
296
+
297
+ void Draw() override;
298
+
299
+ private:
300
+
301
+ int Squares;
302
+
303
+ LPDIRECT3DVERTEXBUFFER9 pVB;
304
+
305
+
306
+
307
+ };
308
+
309
+
310
+
311
+
312
+
313
+ struct SHAPE_VERTEX {
314
+
315
+ D3DXVECTOR3 p; // 位置
316
+
317
+ DWORD color; // 色
318
+
319
+ };
320
+
321
+ ```