質問編集履歴
1
文章を修正
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
JavaScript 入門者 クラス + new クラス(0,PUYO_SIZE)
|
1
|
+
JavaScript 入門者 クラス + new クラス(0,PUYO_SIZE)のundefinedを対処する方法が知りたい。
|
test
CHANGED
@@ -465,3 +465,101 @@
|
|
465
465
|
}
|
466
466
|
|
467
467
|
```
|
468
|
+
|
469
|
+
|
470
|
+
|
471
|
+
##### Utillity
|
472
|
+
|
473
|
+
```
|
474
|
+
|
475
|
+
|
476
|
+
|
477
|
+
const PI = 3.14159; //円周率
|
478
|
+
|
479
|
+
const sinSpeed = PI / 100.0; //sin波 加算
|
480
|
+
|
481
|
+
const speed = 10; //移動速度
|
482
|
+
|
483
|
+
|
484
|
+
|
485
|
+
//ベクトルの引き算
|
486
|
+
|
487
|
+
//引数 Vector型
|
488
|
+
|
489
|
+
function VectorSub(a,b)
|
490
|
+
|
491
|
+
{
|
492
|
+
|
493
|
+
let xx = a.x - b.x;
|
494
|
+
|
495
|
+
let yy = a.y - b.y;
|
496
|
+
|
497
|
+
|
498
|
+
|
499
|
+
return new Vector(xx,yy);
|
500
|
+
|
501
|
+
}
|
502
|
+
|
503
|
+
|
504
|
+
|
505
|
+
|
506
|
+
|
507
|
+
|
508
|
+
|
509
|
+
function Range(a,b)
|
510
|
+
|
511
|
+
{
|
512
|
+
|
513
|
+
return sqrt((a.x * a.x) + (b.y * b.y));
|
514
|
+
|
515
|
+
}
|
516
|
+
|
517
|
+
|
518
|
+
|
519
|
+
|
520
|
+
|
521
|
+
|
522
|
+
|
523
|
+
//ベクター
|
524
|
+
|
525
|
+
class Vector
|
526
|
+
|
527
|
+
{
|
528
|
+
|
529
|
+
constructor(xx,yy)
|
530
|
+
|
531
|
+
{
|
532
|
+
|
533
|
+
this.x = xx;
|
534
|
+
|
535
|
+
this.y = yy;
|
536
|
+
|
537
|
+
}
|
538
|
+
|
539
|
+
}
|
540
|
+
|
541
|
+
|
542
|
+
|
543
|
+
|
544
|
+
|
545
|
+
//線分
|
546
|
+
|
547
|
+
class LineSegment
|
548
|
+
|
549
|
+
{
|
550
|
+
|
551
|
+
constructor(a,b)
|
552
|
+
|
553
|
+
{
|
554
|
+
|
555
|
+
this.start = new Vector(a.x,a.y);
|
556
|
+
|
557
|
+
this.end = new Vector(b.x,b.y);
|
558
|
+
|
559
|
+
}
|
560
|
+
|
561
|
+
}
|
562
|
+
|
563
|
+
|
564
|
+
|
565
|
+
```
|