質問編集履歴

4

2019/10/01 23:49

投稿

srp479
srp479

スコア4

test CHANGED
File without changes
test CHANGED
@@ -12,7 +12,9 @@
12
12
 
13
13
  良ければ知恵をお貸しください
14
14
 
15
+ ```
16
+
15
- ```class GamePlay : IScene
17
+ class GamePlay : IScene
16
18
 
17
19
  {
18
20
 

3

2019/10/01 23:49

投稿

srp479
srp479

スコア4

test CHANGED
File without changes
test CHANGED
@@ -12,510 +12,488 @@
12
12
 
13
13
  良ければ知恵をお貸しください
14
14
 
15
- class GamePlay : IScene
16
-
17
- {
18
-
19
-
20
-
21
-
22
-
23
- private bool isEnd;//終了フラグ
24
-
25
-
26
-
27
- private InputState input;
28
-
29
- private CharacterControl characterControl;
30
-
31
- private Random rand = new Random();
32
-
33
- protected bool isDead = false;
34
-
35
- public void Update()
36
-
37
- {
38
-
39
-
40
-
41
- if (Enemy.Length == 1)
42
-
43
- {
44
-
45
- isEnd = true;
46
-
47
- }
48
-
49
- if(characterControl.IsPlayerDead())
50
-
51
- {
52
-
53
- isEnd = true;
54
-
55
- }
56
-
57
-
58
-
59
- if (rand.Next(60) == 0)
60
-
61
- {
62
-
63
- var position = new Vector2((Screen.Width + 32.0f), (float)rand.Next(45 - 40, Screen.Height - 50));
64
-
65
- characterControl.Add(new Enemy(position));
66
-
67
- }
68
-
69
-
70
-
71
- if (characterControl.IsPlayerDead())
72
-
73
- {
74
-
75
- Initialize();
76
-
77
- }
78
-
79
-
80
-
81
- characterControl.Update();
82
-
83
- }
84
-
85
- public GamePlay(InputState input)
86
-
87
- {
88
-
89
-
90
-
91
- this.input = input;
92
-
93
-
94
-
95
-
96
-
97
- }
98
-
99
-
100
-
101
- public void Draw(Renderer renderer)
102
-
103
- {
104
-
105
-
106
-
107
- characterControl.Draw(renderer);
108
-
109
-
110
-
111
-
112
-
113
- {
114
-
115
-
116
-
117
- }
118
-
119
- //renderer.End();
120
-
121
- }
122
-
123
- public void Shutdown()
124
-
125
- {
126
-
127
-
128
-
129
- }
130
-
131
- public void Initialize()
132
-
133
- {
134
-
135
- //シーン終了フラグを初期化
136
-
137
- this.isEnd = false;
138
-
139
- characterControl = new CharacterControl();
140
-
141
- characterControl.Initialize();
142
-
143
- characterControl.Add(new Player(input));
144
-
145
-
146
-
147
-
148
-
149
- }
150
-
151
- public bool IsEnd()
152
-
153
- {
154
-
155
- return this.isEnd;
156
-
157
- }
158
-
159
- public Scene Next()
160
-
161
- {
162
-
163
-
164
-
165
- return Scene.GameOver;
166
-
167
- }
168
-
169
-
170
-
171
-
172
-
173
- class CharacterControl
174
-
175
- {
176
-
177
- private LinkedList<Character> characters;
178
-
179
-
180
-
181
- public CharacterControl() { }
182
-
183
- public void Initialize()
184
-
185
- {
186
-
187
- if (characters != null)
188
-
189
- {
190
-
191
- characters.Clear();
192
-
193
- }
194
-
195
- characters = new LinkedList<Character>();
196
-
197
- }
198
-
199
- public bool Add(Character character)
200
-
201
- {
202
-
203
- characters.AddLast(character);
204
-
205
- return true;
206
-
207
- }
208
-
209
- public void Update()
210
-
211
- {
212
-
213
- foreach (Character c in characters)
214
-
215
- {
216
-
217
- c.Update();
218
-
219
- }
220
-
221
- New();
222
-
223
- Hit();
224
-
225
- Remove();
226
-
227
- }
228
-
229
- private void New()
230
-
231
- {
232
-
233
-
234
-
235
- var newCharacters = new List<Character>();
236
-
237
- foreach (Character c in characters)
238
-
239
- {
240
-
241
- Character newCharacter = c.New();
242
-
243
- if (newCharacter != null)
244
-
245
- {
246
-
247
- newCharacters.Add(newCharacter);
248
-
249
- }
250
-
251
- }
252
-
253
- foreach (Character c in newCharacters)
254
-
255
- {
256
-
257
- characters.AddLast(c);
258
-
259
- }
260
-
261
- }
262
-
263
- private void Hit()
264
-
265
- {
266
-
267
- foreach (Character c1 in characters)
268
-
269
- {
270
-
271
- foreach (Character c2 in characters)
272
-
273
- if (c1.Collision(c2))
274
-
275
- {
276
-
277
- c1.Hit(c2);
278
-
279
- c2.Hit(c1);
280
-
281
- }
282
-
283
- }
284
-
285
- }
286
-
287
- private void Remove()
288
-
289
- {
290
-
291
- LinkedListNode<Character> node = characters.First;
292
-
293
- while (node != null)
294
-
295
- {
296
-
297
- LinkedListNode<Character> next = node.Next;
298
-
299
- if (node.Value.IsDead())
300
-
301
- {
302
-
303
- characters.Remove(node);
304
-
305
- }
306
-
307
- node = next;
308
-
309
- }
310
-
311
- }
312
-
313
- public bool IsPlayerDead()
314
-
315
- {
316
-
317
- foreach (Character c in characters)
318
-
319
- {
320
-
321
- if (c is Player)
322
-
323
- {
324
-
325
- return false;
326
-
327
- }
328
-
329
- }
330
-
331
- return true;
332
-
333
- }
334
-
335
- public void Draw(Renderer renderer)
336
-
337
- {
338
-
339
- foreach (Character c in characters)
340
-
341
- {
342
-
343
- //renderer.Begin();
344
-
345
- c.Draw(renderer);
346
-
347
- //renderer.Begin();
348
-
349
- }
350
-
351
- }
352
-
353
-
354
-
355
-
356
-
357
- }
358
-
359
-
360
-
361
-
362
-
363
- class Enemy : Character
364
-
365
- {
366
-
367
-
368
-
369
-
370
-
371
-
372
-
373
- public Enemy(Vector2 position)
374
-
375
- : base("敵", new Vector2(350f, 50.0f), 32.0f)
376
-
377
- {
378
-
379
-
380
-
381
- }
382
-
383
- public override void Update()
384
-
385
- {
386
-
387
- position = position + new Vector2(-9.0f, 0.0f);
388
-
389
- if (position.X < (-9.0f - 55.0f))
390
-
391
- {
392
-
393
- isDead = true;
394
-
395
- }
396
-
397
-
398
-
399
-
400
-
401
- }
402
-
403
- public override void Hit(Character character)
404
-
405
- {
406
-
407
- if (character is Bullet || character is Player)
408
-
409
- {
410
-
411
- isDead = true;
412
-
413
- }
414
-
415
-
416
-
417
- }
418
-
419
- public override Character New()
420
-
421
- {
422
-
423
- return null;
424
-
425
- }
426
-
427
- }
428
-
429
-
430
-
431
-
432
-
433
- abstract class Character
434
-
435
- {
436
-
437
- protected string name;
438
-
439
- protected Vector2 position;
440
-
441
- protected float radius;
442
-
443
- protected bool isDead = false;
444
-
445
-
446
-
447
-
448
-
449
- public abstract void Update();
450
-
451
- public abstract void Hit(Character character);
452
-
453
-
454
-
455
- public abstract Character New();
456
-
457
-
458
-
459
- public Character(string name, Vector2 position, float radius)
460
-
461
- {
462
-
463
- this.name = name;
464
-
465
- this.position = position;
466
-
467
- this.radius = radius;
468
-
469
-
470
-
471
- }
472
-
473
- public void Draw(Renderer renderer)
474
-
475
- {
476
-
477
- //renderer.Begin();
478
-
479
-
480
-
481
- renderer.DrawTexture(name, position - new Vector2(radius, radius));
482
-
483
-
484
-
485
- //renderer.End();
486
-
487
- }
488
-
489
- public bool IsDead()
490
-
491
- {
492
-
493
- return isDead;
494
-
495
- }
496
-
497
- public bool Collision(Character character)
498
-
499
- {
500
-
501
- if (Vector2.Distance(this.position, character.position) <= (this.radius + character.radius))
502
-
503
- {
504
-
505
- return true;
506
-
507
- }
508
-
509
- return false;
510
-
511
- }
512
-
513
-
514
-
515
- }
516
-
517
-
518
-
519
-
520
-
521
- }
15
+ ```class GamePlay : IScene
16
+
17
+ {
18
+
19
+
20
+
21
+ private bool isEnd;//終了フラグ
22
+
23
+
24
+
25
+ private InputState input;
26
+
27
+ private CharacterControl characterControl;
28
+
29
+ private Random rand = new Random();
30
+
31
+ protected bool isDead = false;
32
+
33
+ public void Update()
34
+
35
+ {
36
+
37
+
38
+
39
+ if (Enemy.Length == 1)
40
+
41
+ {
42
+
43
+ isEnd = true;
44
+
45
+ }
46
+
47
+ if(characterControl.IsPlayerDead())
48
+
49
+ {
50
+
51
+ isEnd = true;
52
+
53
+ }
54
+
55
+
56
+
57
+ if (rand.Next(60) == 0)
58
+
59
+ {
60
+
61
+ var position = new Vector2((Screen.Width + 32.0f), (float)rand.Next(45 - 40, Screen.Height - 50));
62
+
63
+ characterControl.Add(new Enemy(position));
64
+
65
+ }
66
+
67
+
68
+
69
+ if (characterControl.IsPlayerDead())
70
+
71
+ {
72
+
73
+ Initialize();
74
+
75
+ }
76
+
77
+
78
+
79
+ characterControl.Update();
80
+
81
+ }
82
+
83
+ public GamePlay(InputState input)
84
+
85
+ {
86
+
87
+
88
+
89
+ this.input = input;
90
+
91
+
92
+
93
+ }
94
+
95
+
96
+
97
+ public void Draw(Renderer renderer)
98
+
99
+ {
100
+
101
+
102
+
103
+ characterControl.Draw(renderer);
104
+
105
+
106
+
107
+ {
108
+
109
+
110
+
111
+ }
112
+
113
+ //renderer.End();
114
+
115
+ }
116
+
117
+ public void Shutdown()
118
+
119
+ {
120
+
121
+
122
+
123
+ }
124
+
125
+ public void Initialize()
126
+
127
+ {
128
+
129
+ //シーン終了フラグを初期化
130
+
131
+ this.isEnd = false;
132
+
133
+ characterControl = new CharacterControl();
134
+
135
+ characterControl.Initialize();
136
+
137
+ characterControl.Add(new Player(input));
138
+
139
+
140
+
141
+ }
142
+
143
+ public bool IsEnd()
144
+
145
+ {
146
+
147
+ return this.isEnd;
148
+
149
+ }
150
+
151
+ public Scene Next()
152
+
153
+ {
154
+
155
+
156
+
157
+ return Scene.GameOver;
158
+
159
+ }
160
+
161
+
162
+
163
+ class CharacterControl
164
+
165
+ {
166
+
167
+ private LinkedList<Character> characters;
168
+
169
+
170
+
171
+ public CharacterControl() { }
172
+
173
+ public void Initialize()
174
+
175
+ {
176
+
177
+ if (characters != null)
178
+
179
+ {
180
+
181
+ characters.Clear();
182
+
183
+ }
184
+
185
+ characters = new LinkedList<Character>();
186
+
187
+ }
188
+
189
+ public bool Add(Character character)
190
+
191
+ {
192
+
193
+ characters.AddLast(character);
194
+
195
+ return true;
196
+
197
+ }
198
+
199
+ public void Update()
200
+
201
+ {
202
+
203
+ foreach (Character c in characters)
204
+
205
+ {
206
+
207
+ c.Update();
208
+
209
+ }
210
+
211
+ New();
212
+
213
+ Hit();
214
+
215
+ Remove();
216
+
217
+ }
218
+
219
+ private void New()
220
+
221
+ {
222
+
223
+
224
+
225
+ var newCharacters = new List<Character>();
226
+
227
+ foreach (Character c in characters)
228
+
229
+ {
230
+
231
+ Character newCharacter = c.New();
232
+
233
+ if (newCharacter != null)
234
+
235
+ {
236
+
237
+ newCharacters.Add(newCharacter);
238
+
239
+ }
240
+
241
+ }
242
+
243
+ foreach (Character c in newCharacters)
244
+
245
+ {
246
+
247
+ characters.AddLast(c);
248
+
249
+ }
250
+
251
+ }
252
+
253
+ private void Hit()
254
+
255
+ {
256
+
257
+ foreach (Character c1 in characters)
258
+
259
+ {
260
+
261
+ foreach (Character c2 in characters)
262
+
263
+ if (c1.Collision(c2))
264
+
265
+ {
266
+
267
+ c1.Hit(c2);
268
+
269
+ c2.Hit(c1);
270
+
271
+ }
272
+
273
+ }
274
+
275
+ }
276
+
277
+ private void Remove()
278
+
279
+ {
280
+
281
+ LinkedListNode<Character> node = characters.First;
282
+
283
+ while (node != null)
284
+
285
+ {
286
+
287
+ LinkedListNode<Character> next = node.Next;
288
+
289
+ if (node.Value.IsDead())
290
+
291
+ {
292
+
293
+ characters.Remove(node);
294
+
295
+ }
296
+
297
+ node = next;
298
+
299
+ }
300
+
301
+ }
302
+
303
+ public bool IsPlayerDead()
304
+
305
+ {
306
+
307
+ foreach (Character c in characters)
308
+
309
+ {
310
+
311
+ if (c is Player)
312
+
313
+ {
314
+
315
+ return false;
316
+
317
+ }
318
+
319
+ }
320
+
321
+ return true;
322
+
323
+ }
324
+
325
+ public void Draw(Renderer renderer)
326
+
327
+ {
328
+
329
+ foreach (Character c in characters)
330
+
331
+ {
332
+
333
+ //renderer.Begin();
334
+
335
+ c.Draw(renderer);
336
+
337
+ //renderer.Begin();
338
+
339
+ }
340
+
341
+ }
342
+
343
+
344
+
345
+ }
346
+
347
+
348
+
349
+ class Enemy : Character
350
+
351
+ {
352
+
353
+
354
+
355
+ public Enemy(Vector2 position)
356
+
357
+ : base("敵", new Vector2(350f, 50.0f), 32.0f)
358
+
359
+ {
360
+
361
+
362
+
363
+ }
364
+
365
+ public override void Update()
366
+
367
+ {
368
+
369
+ position = position + new Vector2(-9.0f, 0.0f);
370
+
371
+ if (position.X < (-9.0f - 55.0f))
372
+
373
+ {
374
+
375
+ isDead = true;
376
+
377
+ }
378
+
379
+
380
+
381
+ }
382
+
383
+ public override void Hit(Character character)
384
+
385
+ {
386
+
387
+ if (character is Bullet || character is Player)
388
+
389
+ {
390
+
391
+ isDead = true;
392
+
393
+ }
394
+
395
+
396
+
397
+ }
398
+
399
+ public override Character New()
400
+
401
+ {
402
+
403
+ return null;
404
+
405
+ }
406
+
407
+ }
408
+
409
+
410
+
411
+ abstract class Character
412
+
413
+ {
414
+
415
+ protected string name;
416
+
417
+ protected Vector2 position;
418
+
419
+ protected float radius;
420
+
421
+ protected bool isDead = false;
422
+
423
+
424
+
425
+ public abstract void Update();
426
+
427
+ public abstract void Hit(Character character);
428
+
429
+
430
+
431
+ public abstract Character New();
432
+
433
+
434
+
435
+ public Character(string name, Vector2 position, float radius)
436
+
437
+ {
438
+
439
+ this.name = name;
440
+
441
+ this.position = position;
442
+
443
+ this.radius = radius;
444
+
445
+
446
+
447
+ }
448
+
449
+ public void Draw(Renderer renderer)
450
+
451
+ {
452
+
453
+ //renderer.Begin();
454
+
455
+
456
+
457
+ renderer.DrawTexture(name, position - new Vector2(radius, radius));
458
+
459
+
460
+
461
+ //renderer.End();
462
+
463
+ }
464
+
465
+ public bool IsDead()
466
+
467
+ {
468
+
469
+ return isDead;
470
+
471
+ }
472
+
473
+ public bool Collision(Character character)
474
+
475
+ {
476
+
477
+ if (Vector2.Distance(this.position, character.position) <= (this.radius + character.radius))
478
+
479
+ {
480
+
481
+ return true;
482
+
483
+ }
484
+
485
+ return false;
486
+
487
+ }
488
+
489
+
490
+
491
+ }
492
+
493
+
494
+
495
+ }
496
+
497
+ コード
498
+
499
+ ```

2

コードはりました

2019/10/01 23:48

投稿

srp479
srp479

スコア4

test CHANGED
File without changes
test CHANGED
@@ -4,8 +4,6 @@
4
4
 
5
5
  敵は横に移動して画面端で折り返す
6
6
 
7
-
8
-
9
7
  この2つの処理をしたくて1日考えていたのですが
10
8
 
11
9
  今まで敵の処理はrandomを採用してきたので
@@ -13,3 +11,511 @@
13
11
  全くわかりません
14
12
 
15
13
  良ければ知恵をお貸しください
14
+
15
+ class GamePlay : IScene
16
+
17
+ {
18
+
19
+
20
+
21
+
22
+
23
+ private bool isEnd;//終了フラグ
24
+
25
+
26
+
27
+ private InputState input;
28
+
29
+ private CharacterControl characterControl;
30
+
31
+ private Random rand = new Random();
32
+
33
+ protected bool isDead = false;
34
+
35
+ public void Update()
36
+
37
+ {
38
+
39
+
40
+
41
+ if (Enemy.Length == 1)
42
+
43
+ {
44
+
45
+ isEnd = true;
46
+
47
+ }
48
+
49
+ if(characterControl.IsPlayerDead())
50
+
51
+ {
52
+
53
+ isEnd = true;
54
+
55
+ }
56
+
57
+
58
+
59
+ if (rand.Next(60) == 0)
60
+
61
+ {
62
+
63
+ var position = new Vector2((Screen.Width + 32.0f), (float)rand.Next(45 - 40, Screen.Height - 50));
64
+
65
+ characterControl.Add(new Enemy(position));
66
+
67
+ }
68
+
69
+
70
+
71
+ if (characterControl.IsPlayerDead())
72
+
73
+ {
74
+
75
+ Initialize();
76
+
77
+ }
78
+
79
+
80
+
81
+ characterControl.Update();
82
+
83
+ }
84
+
85
+ public GamePlay(InputState input)
86
+
87
+ {
88
+
89
+
90
+
91
+ this.input = input;
92
+
93
+
94
+
95
+
96
+
97
+ }
98
+
99
+
100
+
101
+ public void Draw(Renderer renderer)
102
+
103
+ {
104
+
105
+
106
+
107
+ characterControl.Draw(renderer);
108
+
109
+
110
+
111
+
112
+
113
+ {
114
+
115
+
116
+
117
+ }
118
+
119
+ //renderer.End();
120
+
121
+ }
122
+
123
+ public void Shutdown()
124
+
125
+ {
126
+
127
+
128
+
129
+ }
130
+
131
+ public void Initialize()
132
+
133
+ {
134
+
135
+ //シーン終了フラグを初期化
136
+
137
+ this.isEnd = false;
138
+
139
+ characterControl = new CharacterControl();
140
+
141
+ characterControl.Initialize();
142
+
143
+ characterControl.Add(new Player(input));
144
+
145
+
146
+
147
+
148
+
149
+ }
150
+
151
+ public bool IsEnd()
152
+
153
+ {
154
+
155
+ return this.isEnd;
156
+
157
+ }
158
+
159
+ public Scene Next()
160
+
161
+ {
162
+
163
+
164
+
165
+ return Scene.GameOver;
166
+
167
+ }
168
+
169
+
170
+
171
+
172
+
173
+ class CharacterControl
174
+
175
+ {
176
+
177
+ private LinkedList<Character> characters;
178
+
179
+
180
+
181
+ public CharacterControl() { }
182
+
183
+ public void Initialize()
184
+
185
+ {
186
+
187
+ if (characters != null)
188
+
189
+ {
190
+
191
+ characters.Clear();
192
+
193
+ }
194
+
195
+ characters = new LinkedList<Character>();
196
+
197
+ }
198
+
199
+ public bool Add(Character character)
200
+
201
+ {
202
+
203
+ characters.AddLast(character);
204
+
205
+ return true;
206
+
207
+ }
208
+
209
+ public void Update()
210
+
211
+ {
212
+
213
+ foreach (Character c in characters)
214
+
215
+ {
216
+
217
+ c.Update();
218
+
219
+ }
220
+
221
+ New();
222
+
223
+ Hit();
224
+
225
+ Remove();
226
+
227
+ }
228
+
229
+ private void New()
230
+
231
+ {
232
+
233
+
234
+
235
+ var newCharacters = new List<Character>();
236
+
237
+ foreach (Character c in characters)
238
+
239
+ {
240
+
241
+ Character newCharacter = c.New();
242
+
243
+ if (newCharacter != null)
244
+
245
+ {
246
+
247
+ newCharacters.Add(newCharacter);
248
+
249
+ }
250
+
251
+ }
252
+
253
+ foreach (Character c in newCharacters)
254
+
255
+ {
256
+
257
+ characters.AddLast(c);
258
+
259
+ }
260
+
261
+ }
262
+
263
+ private void Hit()
264
+
265
+ {
266
+
267
+ foreach (Character c1 in characters)
268
+
269
+ {
270
+
271
+ foreach (Character c2 in characters)
272
+
273
+ if (c1.Collision(c2))
274
+
275
+ {
276
+
277
+ c1.Hit(c2);
278
+
279
+ c2.Hit(c1);
280
+
281
+ }
282
+
283
+ }
284
+
285
+ }
286
+
287
+ private void Remove()
288
+
289
+ {
290
+
291
+ LinkedListNode<Character> node = characters.First;
292
+
293
+ while (node != null)
294
+
295
+ {
296
+
297
+ LinkedListNode<Character> next = node.Next;
298
+
299
+ if (node.Value.IsDead())
300
+
301
+ {
302
+
303
+ characters.Remove(node);
304
+
305
+ }
306
+
307
+ node = next;
308
+
309
+ }
310
+
311
+ }
312
+
313
+ public bool IsPlayerDead()
314
+
315
+ {
316
+
317
+ foreach (Character c in characters)
318
+
319
+ {
320
+
321
+ if (c is Player)
322
+
323
+ {
324
+
325
+ return false;
326
+
327
+ }
328
+
329
+ }
330
+
331
+ return true;
332
+
333
+ }
334
+
335
+ public void Draw(Renderer renderer)
336
+
337
+ {
338
+
339
+ foreach (Character c in characters)
340
+
341
+ {
342
+
343
+ //renderer.Begin();
344
+
345
+ c.Draw(renderer);
346
+
347
+ //renderer.Begin();
348
+
349
+ }
350
+
351
+ }
352
+
353
+
354
+
355
+
356
+
357
+ }
358
+
359
+
360
+
361
+
362
+
363
+ class Enemy : Character
364
+
365
+ {
366
+
367
+
368
+
369
+
370
+
371
+
372
+
373
+ public Enemy(Vector2 position)
374
+
375
+ : base("敵", new Vector2(350f, 50.0f), 32.0f)
376
+
377
+ {
378
+
379
+
380
+
381
+ }
382
+
383
+ public override void Update()
384
+
385
+ {
386
+
387
+ position = position + new Vector2(-9.0f, 0.0f);
388
+
389
+ if (position.X < (-9.0f - 55.0f))
390
+
391
+ {
392
+
393
+ isDead = true;
394
+
395
+ }
396
+
397
+
398
+
399
+
400
+
401
+ }
402
+
403
+ public override void Hit(Character character)
404
+
405
+ {
406
+
407
+ if (character is Bullet || character is Player)
408
+
409
+ {
410
+
411
+ isDead = true;
412
+
413
+ }
414
+
415
+
416
+
417
+ }
418
+
419
+ public override Character New()
420
+
421
+ {
422
+
423
+ return null;
424
+
425
+ }
426
+
427
+ }
428
+
429
+
430
+
431
+
432
+
433
+ abstract class Character
434
+
435
+ {
436
+
437
+ protected string name;
438
+
439
+ protected Vector2 position;
440
+
441
+ protected float radius;
442
+
443
+ protected bool isDead = false;
444
+
445
+
446
+
447
+
448
+
449
+ public abstract void Update();
450
+
451
+ public abstract void Hit(Character character);
452
+
453
+
454
+
455
+ public abstract Character New();
456
+
457
+
458
+
459
+ public Character(string name, Vector2 position, float radius)
460
+
461
+ {
462
+
463
+ this.name = name;
464
+
465
+ this.position = position;
466
+
467
+ this.radius = radius;
468
+
469
+
470
+
471
+ }
472
+
473
+ public void Draw(Renderer renderer)
474
+
475
+ {
476
+
477
+ //renderer.Begin();
478
+
479
+
480
+
481
+ renderer.DrawTexture(name, position - new Vector2(radius, radius));
482
+
483
+
484
+
485
+ //renderer.End();
486
+
487
+ }
488
+
489
+ public bool IsDead()
490
+
491
+ {
492
+
493
+ return isDead;
494
+
495
+ }
496
+
497
+ public bool Collision(Character character)
498
+
499
+ {
500
+
501
+ if (Vector2.Distance(this.position, character.position) <= (this.radius + character.radius))
502
+
503
+ {
504
+
505
+ return true;
506
+
507
+ }
508
+
509
+ return false;
510
+
511
+ }
512
+
513
+
514
+
515
+ }
516
+
517
+
518
+
519
+
520
+
521
+ }

1

2019/10/01 23:11

投稿

srp479
srp479

スコア4

test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,4 @@
1
- ~~打ち消し線~~c#で
1
+ c#で
2
2
 
3
3
  画面端にとどけば次の弾が撃てる
4
4