• R/O
  • SSH
  • HTTPS

nlgp1: Commit


Commit MetaInfo

Revision721 (tree)
Zeit2011-02-17 13:56:26
Autormassa_senohito

Log Message

DebugにSeagmentの表示を追加
CevTestの整理、修正
Program.csで浮力を追加
todo削除

Ändern Zusammenfassung

Diff

--- trunk/Nlgp1/Nlgp1.Box2DX.Test/CevTest.cs (revision 720)
+++ trunk/Nlgp1/Nlgp1.Box2DX.Test/CevTest.cs (revision 721)
@@ -2,25 +2,26 @@
22 using System.Collections.Generic;
33 using System.Text;
44 using DxLibDLL;
5-
65 using Box2DX.Dynamics.Controllers;
76 using Box2DX.Collision;
87 using Box2DX.Dynamics;
98 using Box2DX.Common;
9+using Nlgp1.Box2DX;
1010
11-namespace Nlgp1.Box2DX
11+namespace Nlgp1.B2DX.Test
1212 {
1313 public class CevTest : ContactEvent
1414 {
15- public static bool isRaycast=false;
15+ public static bool isRaycast = false;
1616
1717 public override void Persist(ContactPoint point)
1818 {
1919 base.Persist(point);
20- if (((myUserData)point.Shape1.GetBody().GetUserData()).name == "player")
21- playerhit(point.Shape1, point.Shape2);
22- if (((myUserData)point.Shape2.GetBody().GetUserData()).name == "player")
23- playerhit(point.Shape2, point.Shape1);
20+ Shape s1 = point.Shape1, s2 = point.Shape2;
21+ if (((myUserData)s1.GetBody().GetUserData()).name == "player" && ((float)(int)point.Position.Y == CalcfromShape.GetBottom(s2)))
22+ playerhit(s1, s2);
23+ if (((myUserData)s2.GetBody().GetUserData()).name == "player" && ((float)(int)point.Position.Y == CalcfromShape.GetBottom(s1)))
24+ playerhit(s2, s1);
2425 }
2526
2627 public override void Add(ContactPoint point)
@@ -28,16 +29,19 @@
2829 base.Add(point);
2930 Shape s1 = point.Shape1, s2 = point.Shape2;
3031 if (((myUserData)s1.GetBody().GetUserData()).name == "player" && ((float)(int)point.Position.Y == CalcfromShape.GetBottom(s2)))
31- playerhit(s1,s2);
32+ playerhit(s1, s2);
3233 if (((myUserData)s2.GetBody().GetUserData()).name == "player" && ((float)(int)point.Position.Y == CalcfromShape.GetBottom(s1)))
33- playerhit(s2,s1);
34+ playerhit(s2, s1);
3435 }
35- void playerhit(Shape player,Shape another)
36+
37+
38+ void playerhit(Shape player, Shape another)
3639 {
3740 if (((myUserData)another.GetBody().GetUserData()).name == "sail")
38- //todo myUserdataにRaycastとかさせるべきか
41+ //todo myUserdataにRaycastとかさせるべきか
42+ //todo RigidBodyにisRayCastの定義を加え、Rayをコントロールする
3943 {
40- myUserData data=(myUserData)player.GetBody().GetUserData();
44+ myUserData data = (myUserData)player.GetBody().GetUserData();
4145 data.filter.MaskBits = Convert.ToUInt16("100000", 2);
4246 isRaycast = true;
4347 //dataはplayerである、下から当たった場合、playerはマスクビットを変更する、
@@ -45,7 +49,7 @@
4549 }
4650 }
4751
48-
4952
53+
5054 }
5155 }
\ No newline at end of file
--- trunk/Nlgp1/Nlgp1.Box2DX.Test/Program.cs (revision 720)
+++ trunk/Nlgp1/Nlgp1.Box2DX.Test/Program.cs (revision 721)
@@ -7,8 +7,9 @@
77 using Box2DX.Collision;
88 using Box2DX.Dynamics;
99 using Box2DX.Common;
10+using Nlgp1.B2DX.Test;
1011
11-namespace Nlgp1.Box2DX
12+namespace Nlgp1.Box2DX.Test
1213 {
1314 class Program
1415 {
@@ -28,10 +29,12 @@
2829 LowerBound = new Vec2(0, 0),
2930 UpperBound = new Vec2(512, 384),
3031 }, new Vec2(0, 9.8f), false);
31-
32+
33+ world.AddController(new BuoyancyController());
34+
3235 Debug dd = new Debug
3336 {
34- Flags = DebugDraw.DrawFlags.Shape
37+ Flags = DebugDraw.DrawFlags.Shape|DebugDraw.DrawFlags.Controller
3538 };
3639 world.SetDebugDraw(dd);
3740
--- trunk/Nlgp1/Nlgp1.Box2DX/Gamemain.cs (revision 720)
+++ trunk/Nlgp1/Nlgp1.Box2DX/Gamemain.cs (revision 721)
@@ -56,7 +56,7 @@
5656
5757 bool keyflag = false;
5858 //サイズは半径で設定する
59- //todo IBoxインターフェイスからIBox.MakeShapeとか呼びだして、構成すれば処理を分けられるはず
59+
6060 DynamicRigid d = new DynamicRigid(new Vec2(42, 170), 0 * pi / 180, world, 16, 16, false,
6161 new Dictionary<UserDataKind, string>()
6262 {
--- trunk/Nlgp1/Nlgp1.Box2DX/Debug.cs (revision 720)
+++ trunk/Nlgp1/Nlgp1.Box2DX/Debug.cs (revision 721)
@@ -55,9 +55,9 @@
5555 }
5656 public override void DrawSegment(global::Box2DX.Common.Vec2 p1, global::Box2DX.Common.Vec2 p2, Color color)
5757 {
58- //throw new NotImplementedException();
58+ int x1 = (int)p1.X, x2 = (int)p2.X, y1 = (int)p1.Y, y2 = (int)p2.Y;
59+ DX.DrawBox(x1, y1, x2, y2, new DX.COLOR_U8(0,0,128),true);
5960 }
60-
6161 public override void DrawSolidCircle(global::Box2DX.Common.Vec2 center, float radius, global::Box2DX.Common.Vec2 axis, Color color)
6262 {
6363 DX.DrawCircle((int)center.X, (int)center.Y, (int)radius, new DX.COLOR_U8(0x11ffff),false);
Show on old repository browser