ゲーム内の演算用の浮動小数点数型をdoubleからfloatに変更
@@ -39,7 +39,7 @@ | ||
39 | 39 | #region ゆっくりと左に歩いてくる |
40 | 40 | character.Sprite.ActionEvent += new EventHandler<SpriteActionEventArgs>( ( sender , e ) => { |
41 | 41 | e.Target.AdvancingDirectionType = AdvancingDirectionType.Left; |
42 | - e.Target.WalkingAcceleration = 0.01; | |
42 | + e.Target.WalkingAcceleration = 0.01f; | |
43 | 43 | } ); |
44 | 44 | #endregion |
45 | 45 | break; |
@@ -48,7 +48,7 @@ | ||
48 | 48 | #region ゆっくりと右に歩いてくる |
49 | 49 | character.Sprite.ActionEvent += new EventHandler<SpriteActionEventArgs>( ( sender , e ) => { |
50 | 50 | e.Target.AdvancingDirectionType = AdvancingDirectionType.Right; |
51 | - e.Target.WalkingAcceleration = 0.01; | |
51 | + e.Target.WalkingAcceleration = 0.01f; | |
52 | 52 | } ); |
53 | 53 | #endregion |
54 | 54 | break; |
@@ -59,7 +59,7 @@ | ||
59 | 59 | character.Sprite.JumpingMaxVelocity = 4; |
60 | 60 | character.Sprite.ActionEvent += new EventHandler<SpriteActionEventArgs>( ( sender , e ) => { |
61 | 61 | e.Target.AdvancingDirectionType = AdvancingDirectionType.Left; |
62 | - e.Target.WalkingAcceleration = 0.01; | |
62 | + e.Target.WalkingAcceleration = 0.01f; | |
63 | 63 | e.Target.StartJumping(); |
64 | 64 | } ); |
65 | 65 | #endregion |
@@ -70,7 +70,7 @@ | ||
70 | 70 | character.Sprite.JumpingMaxVelocity = 4; |
71 | 71 | character.Sprite.ActionEvent += new EventHandler<SpriteActionEventArgs>( ( sender , e ) => { |
72 | 72 | e.Target.AdvancingDirectionType = AdvancingDirectionType.Right; |
73 | - e.Target.WalkingAcceleration = 0.01; | |
73 | + e.Target.WalkingAcceleration = 0.01f; | |
74 | 74 | e.Target.StartJumping(); |
75 | 75 | } ); |
76 | 76 | #endregion |
@@ -25,7 +25,7 @@ | ||
25 | 25 | /// <summary> |
26 | 26 | /// 横幅を取得します。 |
27 | 27 | /// </summary> |
28 | - public double Width { | |
28 | + public float Width { | |
29 | 29 | get { |
30 | 30 | return this.box.Width; |
31 | 31 | } |
@@ -33,7 +33,7 @@ | ||
33 | 33 | /// <summary> |
34 | 34 | /// 縦幅を取得します。 |
35 | 35 | /// </summary> |
36 | - public double Height { | |
36 | + public float Height { | |
37 | 37 | get { |
38 | 38 | return this.box.Height; |
39 | 39 | } |
@@ -43,7 +43,7 @@ | ||
43 | 43 | /// <summary> |
44 | 44 | /// 左端の座標を取得します。 |
45 | 45 | /// </summary> |
46 | - public double Left { | |
46 | + public float Left { | |
47 | 47 | get { |
48 | 48 | return this.sprite.X + this.box.Left; |
49 | 49 | } |
@@ -54,7 +54,7 @@ | ||
54 | 54 | /// <summary> |
55 | 55 | /// 上端の座標を取得します。 |
56 | 56 | /// </summary> |
57 | - public double Top { | |
57 | + public float Top { | |
58 | 58 | get { |
59 | 59 | return this.sprite.Y + this.box.Top; |
60 | 60 | } |
@@ -65,7 +65,7 @@ | ||
65 | 65 | /// <summary> |
66 | 66 | /// 右端の座標を取得します。 |
67 | 67 | /// </summary> |
68 | - public double Right { | |
68 | + public float Right { | |
69 | 69 | get { |
70 | 70 | return this.sprite.X + this.box.Right; |
71 | 71 | } |
@@ -76,7 +76,7 @@ | ||
76 | 76 | /// <summary> |
77 | 77 | /// 下端の座標を取得します。 |
78 | 78 | /// </summary> |
79 | - public double Bottom { | |
79 | + public float Bottom { | |
80 | 80 | get { |
81 | 81 | return this.sprite.Y + this.box.Bottom; |
82 | 82 | } |
@@ -84,22 +84,22 @@ | ||
84 | 84 | this.sprite.Y = value - this.box.Bottom; |
85 | 85 | } |
86 | 86 | } |
87 | - public double PreviousLeft { | |
87 | + public float PreviousLeft { | |
88 | 88 | get { |
89 | 89 | return this.sprite.PreviousX + this.box.Left; |
90 | 90 | } |
91 | 91 | } |
92 | - public double PreviousTop { | |
92 | + public float PreviousTop { | |
93 | 93 | get { |
94 | 94 | return this.sprite.PreviousY + this.box.Top; |
95 | 95 | } |
96 | 96 | } |
97 | - public double PreviousRight { | |
97 | + public float PreviousRight { | |
98 | 98 | get { |
99 | 99 | return this.sprite.PreviousX + this.box.Right; |
100 | 100 | } |
101 | 101 | } |
102 | - public double PreviousBottom { | |
102 | + public float PreviousBottom { | |
103 | 103 | get { |
104 | 104 | return this.sprite.PreviousY + this.box.Bottom; |
105 | 105 | } |
@@ -137,7 +137,7 @@ | ||
137 | 137 | /// <param name="dir">衝突方向</param> |
138 | 138 | /// <param name="bounds">対象の短形</param> |
139 | 139 | /// <returns>重なってる部分の距離</returns> |
140 | - public double GetHittingDistance( DirectionType dir , Bounds bounds ) { | |
140 | + public float GetHittingDistance( DirectionType dir , Bounds bounds ) { | |
141 | 141 | if( this.IsHitting( bounds ) == false ) |
142 | 142 | return 0; |
143 | 143 | if( ( dir == DirectionType.Left || dir == DirectionType.Right ) && this.IsHitting( bounds , AxisType.X ) ) { |
@@ -34,22 +34,22 @@ | ||
34 | 34 | /// </summary> |
35 | 35 | private static readonly int ViewCellCountY = 7; |
36 | 36 | // 画面内のプレーヤーの表示位置 |
37 | - private static readonly double ScrollParameterX = 8 * ChipImage.SizeSide; | |
38 | - private static readonly double ScrollParameterY = 6 * ChipImage.SizeSide; | |
37 | + private static readonly float ScrollParameterX = 8 * ChipImage.SizeSide; | |
38 | + private static readonly float ScrollParameterY = 6 * ChipImage.SizeSide; | |
39 | 39 | // 描画されるチップの範囲を表す |
40 | - private static double xStart = 0; | |
41 | - private static double yStart = 0; | |
42 | - private static double xEnd = 0; | |
43 | - private static double yEnd = 0; | |
40 | + private static float xStart = 0; | |
41 | + private static float yStart = 0; | |
42 | + private static float xEnd = 0; | |
43 | + private static float yEnd = 0; | |
44 | 44 | |
45 | 45 | /// <summary> |
46 | 46 | /// 横方向のスクロール量 |
47 | 47 | /// </summary> |
48 | - private static double scrollX = 0; | |
48 | + private static float scrollX = 0; | |
49 | 49 | /// <summary> |
50 | 50 | /// 縦方向のスクロール量 |
51 | 51 | /// </summary> |
52 | - private static double scrollY = 0; | |
52 | + private static float scrollY = 0; | |
53 | 53 | |
54 | 54 | /// <summary> |
55 | 55 | /// ステージを読み込みます。 |
@@ -74,8 +74,8 @@ | ||
74 | 74 | scrollY = player.Location.Y - ScrollParameterY; |
75 | 75 | |
76 | 76 | #region 可視範囲内でマップの描画 |
77 | - double chipX = player.Location.X / ChipImage.SizeSide; | |
78 | - double chipY = player.Location.Y / ChipImage.SizeSide; | |
77 | + float chipX = player.Location.X / ChipImage.SizeSide; | |
78 | + float chipY = player.Location.Y / ChipImage.SizeSide; | |
79 | 79 | |
80 | 80 | xStart = chipX - ViewCellCountX; // 画面左端にスペースができるのでその分のチップを多めに描画する |
81 | 81 | yStart = chipY - ViewCellCountY; |
@@ -87,7 +87,7 @@ | ||
87 | 87 | #region オブジェクトの描画 |
88 | 88 | foreach( var drawable in drawables ) |
89 | 89 | if( IsVisibleCell( drawable.Location.X , drawable.Location.Y ) ) |
90 | - drawable.Draw( new Vector( drawable.Location.X - scrollX - ChipImage.SizeSide / 2.0 , drawable.Location.Y - scrollY - ChipImage.SizeSide / 2.0 ) ); | |
90 | + drawable.Draw( new Vector( drawable.Location.X - scrollX - ChipImage.SizeSide / 2.0f , drawable.Location.Y - scrollY - ChipImage.SizeSide / 2.0f ) ); | |
91 | 91 | #endregion |
92 | 92 | } |
93 | 93 |
@@ -98,9 +98,9 @@ | ||
98 | 98 | /// <param name="column">ピクチップ単位で表されるY座標</param> |
99 | 99 | /// <param name="blankCells">許容する描画範囲外のチップ数</param> |
100 | 100 | /// <returns>描画範囲かどうか</returns> |
101 | - public static bool IsVisibleCell( double x , double y ) { | |
102 | - double chipX = x / ChipImage.SizeSide; | |
103 | - double chipY = y / ChipImage.SizeSide; | |
101 | + public static bool IsVisibleCell( float x , float y ) { | |
102 | + float chipX = x / ChipImage.SizeSide; | |
103 | + float chipY = y / ChipImage.SizeSide; | |
104 | 104 | return xStart <= chipX && xEnd >= chipX && yStart <= chipY && yEnd >= chipY; |
105 | 105 | } |
106 | 106 | } |
@@ -20,7 +20,7 @@ | ||
20 | 20 | /// <summary> |
21 | 21 | /// 角度 |
22 | 22 | /// </summary> |
23 | - public double Angle{ | |
23 | + public float Angle{ | |
24 | 24 | get; |
25 | 25 | set; |
26 | 26 | } |
@@ -27,7 +27,7 @@ | ||
27 | 27 | /// <summary> |
28 | 28 | /// 半径 |
29 | 29 | /// </summary> |
30 | - public double Radius{ | |
30 | + public float Radius{ | |
31 | 31 | get; |
32 | 32 | set; |
33 | 33 | } |
@@ -34,7 +34,7 @@ | ||
34 | 34 | /// <summary> |
35 | 35 | /// 距離制限 |
36 | 36 | /// </summary> |
37 | - public double LimitDistance{ | |
37 | + public float LimitDistance{ | |
38 | 38 | get; |
39 | 39 | set; |
40 | 40 | } |
@@ -41,7 +41,7 @@ | ||
41 | 41 | /// <summary> |
42 | 42 | /// 速度 |
43 | 43 | /// </summary> |
44 | - public double Speed{ | |
44 | + public float Speed{ | |
45 | 45 | get; |
46 | 46 | set; |
47 | 47 | } |
@@ -67,13 +67,13 @@ | ||
67 | 67 | this.Viewer = SpriteDrawer.Load( imageTypeName , chipId ); |
68 | 68 | this.Owner = owner; |
69 | 69 | this.LogicParameter = new ActionParameter(); |
70 | - this.Bounds = new Bounds( this , new Box( ChipImage.SizeSide / -2.0 , ChipImage.SizeSide / -2.0 , ChipImage.SizeSide / +2.0 , +ChipImage.SizeSide / +2.0 ) ); | |
70 | + this.Bounds = new Bounds( this , new Box( ChipImage.SizeSide / -2.0f , ChipImage.SizeSide / -2.0f , ChipImage.SizeSide / +2.0f , +ChipImage.SizeSide / +2.0f ) ); | |
71 | 71 | |
72 | 72 | this.Type = type; |
73 | 73 | this.ChipId = chipId; |
74 | 74 | this.HitPoint = 1; |
75 | - WalkingAcceleration = 0.5; | |
76 | - RunningAcceleration = 0.5; | |
75 | + WalkingAcceleration = 0.5f; | |
76 | + RunningAcceleration = 0.5f; | |
77 | 77 | WalkingMaxVelocity = 5; |
78 | 78 | RunningMaxVelocity = 10; |
79 | 79 | JumpingMaxVelocity = 4; |
@@ -222,13 +222,13 @@ | ||
222 | 222 | set; |
223 | 223 | } |
224 | 224 | |
225 | - private double walkingMaxVelocity = 0; | |
226 | - private double runningMaxVelocity = 0; | |
225 | + private float walkingMaxVelocity = 0; | |
226 | + private float runningMaxVelocity = 0; | |
227 | 227 | |
228 | 228 | /// <summary> |
229 | 229 | /// 静止時の加速度を設定または、取得します。 |
230 | 230 | /// </summary> |
231 | - public double RestingAcceleration { | |
231 | + public float RestingAcceleration { | |
232 | 232 | get; |
233 | 233 | set; |
234 | 234 | } |
@@ -235,7 +235,7 @@ | ||
235 | 235 | /// <summary> |
236 | 236 | /// 歩行時の加速度を設定または、取得します。 |
237 | 237 | /// </summary> |
238 | - public double WalkingAcceleration { | |
238 | + public float WalkingAcceleration { | |
239 | 239 | get; |
240 | 240 | set; |
241 | 241 | } |
@@ -242,7 +242,7 @@ | ||
242 | 242 | /// <summary> |
243 | 243 | /// 走行時の加速度を設定または、取得します。 |
244 | 244 | /// </summary> |
245 | - public double RunningAcceleration { | |
245 | + public float RunningAcceleration { | |
246 | 246 | get; |
247 | 247 | set; |
248 | 248 | } |
@@ -249,7 +249,7 @@ | ||
249 | 249 | /// <summary> |
250 | 250 | /// 静止時の最高速度を設定または、取得します。 |
251 | 251 | /// </summary> |
252 | - public double RestingMaxVelocity { | |
252 | + public float RestingMaxVelocity { | |
253 | 253 | get; |
254 | 254 | set; |
255 | 255 | } |
@@ -257,7 +257,7 @@ | ||
257 | 257 | /// 横(X)方向の最高速度を設定または、取得します。 |
258 | 258 | /// 1チップを超える速度は、指定できません。 |
259 | 259 | /// </summary> |
260 | - public double WalkingMaxVelocity { | |
260 | + public float WalkingMaxVelocity { | |
261 | 261 | get { |
262 | 262 | return walkingMaxVelocity; |
263 | 263 | } |
@@ -272,7 +272,7 @@ | ||
272 | 272 | /// 加速時の横(X)方向の最高速度を設定または、取得します。 |
273 | 273 | /// 1チップを超える速度は、指定できません。 |
274 | 274 | /// </summary> |
275 | - public double RunningMaxVelocity { | |
275 | + public float RunningMaxVelocity { | |
276 | 276 | get { |
277 | 277 | return runningMaxVelocity; |
278 | 278 | } |
@@ -286,7 +286,7 @@ | ||
286 | 286 | /// <summary> |
287 | 287 | /// 降下重力を設定または、取得します。 |
288 | 288 | /// </summary> |
289 | - public double JumpingAcceleration { | |
289 | + public float JumpingAcceleration { | |
290 | 290 | get; |
291 | 291 | set; |
292 | 292 | } |
@@ -293,7 +293,7 @@ | ||
293 | 293 | /// <summary> |
294 | 294 | /// スプライトのジャンプ力を取得または、設定します。 |
295 | 295 | /// </summary> |
296 | - public double JumpingMaxVelocity { | |
296 | + public float JumpingMaxVelocity { | |
297 | 297 | get; |
298 | 298 | set; |
299 | 299 | } |
@@ -460,8 +460,8 @@ | ||
460 | 460 | #region 移動先を計算する |
461 | 461 | this.ResetPreviousLocation(); |
462 | 462 | if( CanAdvance ) { |
463 | - double accelerationX = 0; | |
464 | - double maxVelocityX = 0; | |
463 | + float accelerationX = 0; | |
464 | + float maxVelocityX = 0; | |
465 | 465 | switch( this.AdvancingType ) { |
466 | 466 | case AdvancingType.Resting: |
467 | 467 | if( this.VelocityX != 0 ) { |
@@ -483,8 +483,8 @@ | ||
483 | 483 | } |
484 | 484 | // 真下のチップの摩擦を取得して影響を計算する。 |
485 | 485 | // ジャンプ力の増加を打ち切る |
486 | - double accelerationY = 0; | |
487 | - double maxVelocityY = 0; | |
486 | + float accelerationY = 0; | |
487 | + float maxVelocityY = 0; | |
488 | 488 | if( this.IsFloating ) { |
489 | 489 | if( jumpingTime > 0 ) { |
490 | 490 | --jumpingTime; |
@@ -643,7 +643,7 @@ | ||
643 | 643 | /// <summary> |
644 | 644 | /// X軸の座標を取得または、設定します。 |
645 | 645 | /// </summary> |
646 | - public double X { | |
646 | + public float X { | |
647 | 647 | get { |
648 | 648 | return this.location.X; |
649 | 649 | } |
@@ -665,7 +665,7 @@ | ||
665 | 665 | /// <summary> |
666 | 666 | /// Y軸の座標を取得または、設定します。 |
667 | 667 | /// </summary> |
668 | - public double Y { | |
668 | + public float Y { | |
669 | 669 | get { |
670 | 670 | return this.location.Y; |
671 | 671 | } |
@@ -688,7 +688,7 @@ | ||
688 | 688 | /// <summary> |
689 | 689 | /// X軸方向の速度を設定または、取得します。 |
690 | 690 | /// </summary> |
691 | - public double VelocityX { | |
691 | + public float VelocityX { | |
692 | 692 | get; |
693 | 693 | set; |
694 | 694 | } |
@@ -695,7 +695,7 @@ | ||
695 | 695 | /// <summary> |
696 | 696 | /// Y軸方向の速度を設定または、取得します。 |
697 | 697 | /// </summary> |
698 | - public double VelocityY { | |
698 | + public float VelocityY { | |
699 | 699 | get; |
700 | 700 | set; |
701 | 701 | } |
@@ -703,7 +703,7 @@ | ||
703 | 703 | /// <summary> |
704 | 704 | /// スプライトの前回のX座標を設定または、取得します。 |
705 | 705 | /// </summary> |
706 | - public double PreviousX { | |
706 | + public float PreviousX { | |
707 | 707 | get { |
708 | 708 | return this.previousLocation.X; |
709 | 709 | } |
@@ -711,7 +711,7 @@ | ||
711 | 711 | /// <summary> |
712 | 712 | /// スプライトの前回のY座標を取得または、設定します。 |
713 | 713 | /// </summary> |
714 | - public double PreviousY { | |
714 | + public float PreviousY { | |
715 | 715 | get { |
716 | 716 | return this.previousLocation.Y; |
717 | 717 | } |
@@ -720,23 +720,23 @@ | ||
720 | 720 | /// <summary> |
721 | 721 | /// チップ座標で表されるX座標を設定または、取得します。 |
722 | 722 | /// </summary> |
723 | - public double ChipX { | |
723 | + public float ChipX { | |
724 | 724 | get { |
725 | - return Math.Floor( this.X / ChipImage.SizeSide ); | |
725 | + return MathF.Floor( this.X / ChipImage.SizeSide ); | |
726 | 726 | } |
727 | 727 | set { |
728 | - this.X = ( value + 0.5 ) * ChipImage.SizeSide; | |
728 | + this.X = ( value + 0.5f ) * ChipImage.SizeSide; | |
729 | 729 | } |
730 | 730 | } |
731 | 731 | /// <summary> |
732 | 732 | /// チップ座標で表されるY座標を設定または、取得します。 |
733 | 733 | /// </summary> |
734 | - public double ChipY { | |
734 | + public float ChipY { | |
735 | 735 | get { |
736 | - return Math.Floor( this.Y / ChipImage.SizeSide ); | |
736 | + return MathF.Floor( this.Y / ChipImage.SizeSide ); | |
737 | 737 | } |
738 | 738 | set { |
739 | - this.Y = ( value + 0.5 ) * ChipImage.SizeSide; | |
739 | + this.Y = ( value + 0.5f ) * ChipImage.SizeSide; | |
740 | 740 | } |
741 | 741 | } |
742 | 742 |
@@ -780,9 +780,9 @@ | ||
780 | 780 | /// <param name="row">中心となるX軸の座標</param> |
781 | 781 | /// <param name="column">中心となるY軸の座標</param> |
782 | 782 | /// <param name="rightRotation">右回りに回転を行うようにします。</param> |
783 | - public static void Rotate( Sprite target , double x , double y , bool rightRotation ) { | |
784 | - target.X = x + ( target.LogicParameter.Radius * Math.Cos( Math.PI / 180 * target.LogicParameter.Angle ) ); | |
785 | - target.Y = y + ( target.LogicParameter.Radius * Math.Sin( Math.PI / 180 * target.LogicParameter.Angle ) ); | |
783 | + public static void Rotate( Sprite target , float x , float y , bool rightRotation ) { | |
784 | + target.X = x + ( target.LogicParameter.Radius * MathF.Cos( MathF.PI / 180 * target.LogicParameter.Angle ) ); | |
785 | + target.Y = y + ( target.LogicParameter.Radius * MathF.Sin( MathF.PI / 180 * target.LogicParameter.Angle ) ); | |
786 | 786 | |
787 | 787 | if( rightRotation ) { |
788 | 788 | target.LogicParameter.Angle += target.LogicParameter.Speed; |
@@ -800,7 +800,7 @@ | ||
800 | 800 | /// <param name="target">対象のスプライト</param> |
801 | 801 | /// <param name="row">中心のX座標</param> |
802 | 802 | /// <param name="column">中心のY座標</param> |
803 | - public static void RoundTrip( Sprite target , double x , double y ) { | |
803 | + public static void RoundTrip( Sprite target , float x , float y ) { | |
804 | 804 | // 移動方向を切り替える |
805 | 805 | if( target.LogicParameter.Radius > target.LogicParameter.LimitDistance ) |
806 | 806 | target.LogicParameter.Universal["GivenDirection"] = false; |
@@ -813,8 +813,8 @@ | ||
813 | 813 | else |
814 | 814 | target.LogicParameter.Radius -= target.LogicParameter.Speed; |
815 | 815 | |
816 | - target.X = x + ( target.LogicParameter.Radius * Math.Cos( Math.PI / 180 * target.LogicParameter.Angle ) ); | |
817 | - target.Y = y + ( target.LogicParameter.Radius * Math.Sin( Math.PI / 180 * target.LogicParameter.Angle ) ); | |
816 | + target.X = x + ( target.LogicParameter.Radius * MathF.Cos( MathF.PI / 180 * target.LogicParameter.Angle ) ); | |
817 | + target.Y = y + ( target.LogicParameter.Radius * MathF.Sin( MathF.PI / 180 * target.LogicParameter.Angle ) ); | |
818 | 818 | } |
819 | 819 | /// <summary> |
820 | 820 | /// キャラクタオブジェクトをVerlet積分法に基づいて移動する。 |
@@ -824,7 +824,7 @@ | ||
824 | 824 | /// <param name="accelerationY">Y軸方向の加速度</param> |
825 | 825 | /// <param name="maxVelocityX">X軸方向の最高速度</param> |
826 | 826 | /// <param name="maxVelocityY">Y軸方向の最高速度</param> |
827 | - public static void Advance( Sprite target , double accelerationX , double accelerationY , double maxVelocityX , double maxVelocityY ) { | |
827 | + public static void Advance( Sprite target , float accelerationX , float accelerationY , float maxVelocityX , float maxVelocityY ) { | |
828 | 828 | target.VelocityX = |
829 | 829 | Math.Min( |
830 | 830 | Math.Max( target.VelocityX + accelerationX , -maxVelocityX ) , |
@@ -845,15 +845,15 @@ | ||
845 | 845 | /// <param name="source">targetに衝突するスプライト</param> |
846 | 846 | /// <param name="target">対象のスプライト</param> |
847 | 847 | /// <param name="bound">反動で移動する距離</param> |
848 | - public static void Rebound( Sprite source , Sprite target , double bound ) { | |
848 | + public static void Rebound( Sprite source , Sprite target , float bound ) { | |
849 | 849 | if( source.Bounds.IsHitting( target.Bounds ) == false ) |
850 | 850 | return; |
851 | - double angle = Sprite.GetAngle( source.X , source.Y , target.X , target.Y ); | |
851 | + float angle = Sprite.GetAngle( source.X , source.Y , target.X , target.Y ); | |
852 | 852 | if( angle > 0 ) |
853 | 853 | angle = -angle; |
854 | 854 | else |
855 | 855 | angle = Math.Abs( angle ); |
856 | - source.Location = new Vector( target.X + ( bound * Math.Cos( Math.PI / 180 * angle ) ) , target.Y + ( bound * Math.Sin( Math.PI / 180 * angle ) ) ); | |
856 | + source.Location = new Vector( target.X + ( bound * MathF.Cos( MathF.PI / 180 * angle ) ) , target.Y + ( bound * MathF.Sin( MathF.PI / 180 * angle ) ) ); | |
857 | 857 | } |
858 | 858 | /// <summary> |
859 | 859 | /// スプライトとの衝突を判定してリバウンドを行わずに停止します。 |
@@ -862,11 +862,11 @@ | ||
862 | 862 | /// <param name="source">targetに衝突するスプライト</param> |
863 | 863 | /// <param name="target">対象のスプライト</param> |
864 | 864 | public static void Stop( Sprite source , Sprite target ) { |
865 | - double x = source.X; | |
866 | - double y = source.Y; | |
865 | + float x = source.X; | |
866 | + float y = source.Y; | |
867 | 867 | if( source.Bounds.IsHitting( target.Bounds , AxisType.Y ) ) { |
868 | - double top = Math.Abs( Math.Abs( source.Bounds.Top ) - Math.Abs( target.Bounds.Bottom ) ); | |
869 | - double bottom = Math.Abs( Math.Abs( source.Bounds.Bottom ) - Math.Abs( target.Bounds.Top ) ); | |
868 | + float top = Math.Abs( Math.Abs( source.Bounds.Top ) - Math.Abs( target.Bounds.Bottom ) ); | |
869 | + float bottom = Math.Abs( Math.Abs( source.Bounds.Bottom ) - Math.Abs( target.Bounds.Top ) ); | |
870 | 870 | if( top < bottom ) { |
871 | 871 | if( target.IsJumping ) { |
872 | 872 | y = target.Bounds.Bottom + ChipImage.SizeSide / 2; |
@@ -878,8 +878,8 @@ | ||
878 | 878 | } |
879 | 879 | |
880 | 880 | if( source.Bounds.IsHitting( target.Bounds , AxisType.X ) ) { |
881 | - double left = Math.Abs( Math.Abs( source.Bounds.Left ) - Math.Abs( target.Bounds.Right ) ); | |
882 | - double right = Math.Abs( Math.Abs( source.Bounds.Right ) - Math.Abs( target.Bounds.Left ) ); | |
881 | + float left = Math.Abs( Math.Abs( source.Bounds.Left ) - Math.Abs( target.Bounds.Right ) ); | |
882 | + float right = Math.Abs( Math.Abs( source.Bounds.Right ) - Math.Abs( target.Bounds.Left ) ); | |
883 | 883 | if( left > right ) |
884 | 884 | x = target.Bounds.Left - target.Bounds.Width; |
885 | 885 | else |
@@ -894,8 +894,8 @@ | ||
894 | 894 | /// <param name="target">スプライト2</param> |
895 | 895 | /// <param name="dir">吸着する方向</param> |
896 | 896 | public static void Physisorb( Sprite source , Sprite target , DirectionFlags dir ) { |
897 | - double x = source.X; | |
898 | - double y = source.Y; | |
897 | + float x = source.X; | |
898 | + float y = source.Y; | |
899 | 899 | |
900 | 900 | DirectionFlags hittingDir = source.NormalizeLocation( target , dir ); |
901 | 901 | if( ( hittingDir & DirectionFlags.Left ) == 0 ) { |
@@ -919,11 +919,11 @@ | ||
919 | 919 | /// <returns>最も衝突している方向</returns> |
920 | 920 | public static DirectionFlags GetHittingDirection( Sprite source , Sprite target ) { |
921 | 921 | DirectionFlags dir = DirectionFlags.None; |
922 | - double max = double.MinValue; | |
923 | - double top = Math.Abs( source.Bounds.GetHittingDistance( DirectionType.Top , target.Bounds ) ); | |
924 | - double bottom = Math.Abs( source.Bounds.GetHittingDistance( DirectionType.Bottom , target.Bounds ) ); | |
925 | - double left = Math.Abs( source.Bounds.GetHittingDistance( DirectionType.Left , target.Bounds ) ); | |
926 | - double right = Math.Abs( source.Bounds.GetHittingDistance( DirectionType.Right , target.Bounds ) ); | |
922 | + float max = float.MinValue; | |
923 | + float top = Math.Abs( source.Bounds.GetHittingDistance( DirectionType.Top , target.Bounds ) ); | |
924 | + float bottom = Math.Abs( source.Bounds.GetHittingDistance( DirectionType.Bottom , target.Bounds ) ); | |
925 | + float left = Math.Abs( source.Bounds.GetHittingDistance( DirectionType.Left , target.Bounds ) ); | |
926 | + float right = Math.Abs( source.Bounds.GetHittingDistance( DirectionType.Right , target.Bounds ) ); | |
927 | 927 | if( max < top && top != 0 ) { |
928 | 928 | max = top; |
929 | 929 | dir = DirectionFlags.Top; |
@@ -951,8 +951,8 @@ | ||
951 | 951 | |
952 | 952 | /// <param name="target">対象のキャラクタ</param> |
953 | 953 | /// <returns>対象キャラクタとの距離</returns> |
954 | - public static double GetDistance( Sprite source , Sprite target ) { | |
955 | - return Math.Sqrt( Math.Pow( source.X - target.X , 2 ) + Math.Pow( source.Y - target.Y , 2 ) ); | |
954 | + public static float GetDistance( Sprite source , Sprite target ) { | |
955 | + return MathF.Sqrt( MathF.Pow( source.X - target.X , 2 ) + MathF.Pow( source.Y - target.Y , 2 ) ); | |
956 | 956 | } |
957 | 957 | /// <summary> |
958 | 958 | /// 二点間の距離を取得します。 |
@@ -962,8 +962,8 @@ | ||
962 | 962 | /// <param name="x2">終点(X)</param> |
963 | 963 | /// <param name="y2">終点(Y)</param> |
964 | 964 | /// <returns>距離</returns> |
965 | - public static double GetDistance( double x1 , double y1 , double x2 , double y2 ) { | |
966 | - return Math.Sqrt( Math.Pow( x2 - x1 , 2 ) + Math.Pow( y2 - y2 , 2 ) ); | |
965 | + public static float GetDistance( float x1 , float y1 , float x2 , float y2 ) { | |
966 | + return MathF.Sqrt( MathF.Pow( x2 - x1 , 2 ) + MathF.Pow( y2 - y2 , 2 ) ); | |
967 | 967 | } |
968 | 968 | /// <summary> |
969 | 969 | /// 始点座標からの角度を取得します。 |
@@ -973,8 +973,8 @@ | ||
973 | 973 | /// <param name="x2">終点(X)</param> |
974 | 974 | /// <param name="y2">終点(Y)</param> |
975 | 975 | /// <returns>角度</returns> |
976 | - public static double GetAngle( double x1 , double y1 , double x2 , double y2 ) { | |
977 | - return Math.Atan2( y2 - y1 , x2 - x1 ) / ( Math.PI / 180 ); | |
976 | + public static float GetAngle( float x1 , float y1 , float x2 , float y2 ) { | |
977 | + return MathF.Atan2( y2 - y1 , x2 - x1 ) / ( MathF.PI / 180 ); | |
978 | 978 | } |
979 | 979 | #endregion |
980 | 980 | } |
@@ -55,11 +55,11 @@ | ||
55 | 55 | |
56 | 56 | DX.SetDrawScreen( DX.DX_SCREEN_BACK ); |
57 | 57 | int baseTime = Environment.TickCount; |
58 | - double frameCount = 0; | |
58 | + float frameCount = 0; | |
59 | 59 | while( DX.ProcessMessage() ) { |
60 | - double nowFrameCount; | |
60 | + float nowFrameCount; | |
61 | 61 | while( true ) { |
62 | - nowFrameCount = ( Environment.TickCount - baseTime ) * ( 60.0 / 1000.0 ); | |
62 | + nowFrameCount = ( Environment.TickCount - baseTime ) * ( 60.0f / 1000.0f ); | |
63 | 63 | if( nowFrameCount < frameCount ) { |
64 | 64 | Thread.Sleep(1); |
65 | 65 | } |
@@ -67,7 +67,7 @@ | ||
67 | 67 | break; |
68 | 68 | } |
69 | 69 | } |
70 | - frameCount = Math.Floor( nowFrameCount + 1 ); | |
70 | + frameCount = MathF.Floor( nowFrameCount + 1.0f ); | |
71 | 71 | |
72 | 72 | rate.Update(); |
73 | 73 |
@@ -0,0 +1,57 @@ | ||
1 | +using System; | |
2 | + | |
3 | +namespace Nlgp1.Utilities { | |
4 | + | |
5 | + public static class MathF { | |
6 | + | |
7 | + public const float PI = ( float )( Math.PI ); | |
8 | + | |
9 | + public static float Acos( float a ) { | |
10 | + return ( float )( Math.Acos( a ) ); | |
11 | + } | |
12 | + | |
13 | + public static float Asin( float a ) { | |
14 | + return ( float )( Math.Asin( a ) ); | |
15 | + } | |
16 | + | |
17 | + public static float Atan( float a ) { | |
18 | + return ( float )( Math.Atan( a ) ); | |
19 | + } | |
20 | + | |
21 | + public static float Atan2( float y , float x ) { | |
22 | + return ( float )( Math.Atan2( y , x ) ); | |
23 | + } | |
24 | + | |
25 | + public static float Ceiling( float a ) { | |
26 | + return ( float )( Math.Ceiling( a ) ); | |
27 | + } | |
28 | + | |
29 | + public static float Cos( float a ) { | |
30 | + return ( float )( Math.Cos( a ) ); | |
31 | + } | |
32 | + | |
33 | + public static float Floor( float a ) { | |
34 | + return ( float )( Math.Floor( a ) ); | |
35 | + } | |
36 | + | |
37 | + public static float Pow( float x , float y ) { | |
38 | + return ( float )( Math.Pow( x , y ) ); | |
39 | + } | |
40 | + | |
41 | + public static float Round( float a ) { | |
42 | + return ( float )( Math.Round( a ) ); | |
43 | + } | |
44 | + | |
45 | + public static float Sin( float a ) { | |
46 | + return ( float )( Math.Sin( a ) ); | |
47 | + } | |
48 | + | |
49 | + public static float Sqrt( float a ) { | |
50 | + return ( float )( Math.Sqrt( a ) ); | |
51 | + } | |
52 | + | |
53 | + public static float Tan( float a ) { | |
54 | + return ( float )( Math.Tan( a ) ); | |
55 | + } | |
56 | + } | |
57 | +} |
@@ -5,10 +5,10 @@ | ||
5 | 5 | |
6 | 6 | public struct Vector { |
7 | 7 | |
8 | - public double X; | |
9 | - public double Y; | |
8 | + public float X; | |
9 | + public float Y; | |
10 | 10 | |
11 | - public Vector( double x , double y ) { | |
11 | + public Vector( float x , float y ) { | |
12 | 12 | this.X = x; |
13 | 13 | this.Y = y; |
14 | 14 | } |
@@ -29,15 +29,15 @@ | ||
29 | 29 | return new Vector( vector1.X - vector2.X , vector1.Y - vector2.Y ); |
30 | 30 | } |
31 | 31 | |
32 | - public static Vector operator *( Vector vector1 , double scalar2 ) { | |
32 | + public static Vector operator *( Vector vector1 , float scalar2 ) { | |
33 | 33 | return new Vector( vector1.X * scalar2 , vector1.Y * scalar2 ); |
34 | 34 | } |
35 | 35 | |
36 | - public static Vector operator *( double scalar1 , Vector vector2 ) { | |
36 | + public static Vector operator *( float scalar1 , Vector vector2 ) { | |
37 | 37 | return new Vector( scalar1 * vector2.X , scalar1 * vector2.Y ); |
38 | 38 | } |
39 | 39 | |
40 | - public static Vector operator /( Vector vector1 , double scalar2 ) { | |
40 | + public static Vector operator /( Vector vector1 , float scalar2 ) { | |
41 | 41 | return new Vector( vector1.X / scalar2 , vector1.Y / scalar2 ); |
42 | 42 | } |
43 | 43 |
@@ -8,7 +8,7 @@ | ||
8 | 8 | public Vector Minimum; |
9 | 9 | public Vector Maximum; |
10 | 10 | |
11 | - public double Left { | |
11 | + public float Left { | |
12 | 12 | get { |
13 | 13 | return this.Minimum.X; |
14 | 14 | } |
@@ -17,7 +17,7 @@ | ||
17 | 17 | } |
18 | 18 | } |
19 | 19 | |
20 | - public double Top { | |
20 | + public float Top { | |
21 | 21 | get { |
22 | 22 | return this.Minimum.Y; |
23 | 23 | } |
@@ -26,7 +26,7 @@ | ||
26 | 26 | } |
27 | 27 | } |
28 | 28 | |
29 | - public double Right { | |
29 | + public float Right { | |
30 | 30 | get { |
31 | 31 | return this.Maximum.X; |
32 | 32 | } |
@@ -35,7 +35,7 @@ | ||
35 | 35 | } |
36 | 36 | } |
37 | 37 | |
38 | - public double Bottom { | |
38 | + public float Bottom { | |
39 | 39 | get { |
40 | 40 | return this.Maximum.Y; |
41 | 41 | } |
@@ -44,13 +44,13 @@ | ||
44 | 44 | } |
45 | 45 | } |
46 | 46 | |
47 | - public double Width { | |
47 | + public float Width { | |
48 | 48 | get { |
49 | 49 | return this.Maximum.X - this.Minimum.X; |
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
53 | - public double Height { | |
53 | + public float Height { | |
54 | 54 | get { |
55 | 55 | return this.Maximum.Y - this.Minimum.Y; |
56 | 56 | } |
@@ -67,7 +67,7 @@ | ||
67 | 67 | this.Maximum = maximum; |
68 | 68 | } |
69 | 69 | |
70 | - public Box( double left , double top , double right, double bottom ) { | |
70 | + public Box( float left , float top , float right, float bottom ) { | |
71 | 71 | this.Minimum = new Vector( left , top ); |
72 | 72 | this.Maximum = new Vector( right , bottom ); |
73 | 73 | } |