Revision | 721 (tree) |
---|---|
Zeit | 2011-02-17 13:56:26 |
Autor | massa_senohito |
DebugにSeagmentの表示を追加
CevTestの整理、修正
Program.csで浮力を追加
todo削除
@@ -2,25 +2,26 @@ | ||
2 | 2 | using System.Collections.Generic; |
3 | 3 | using System.Text; |
4 | 4 | using DxLibDLL; |
5 | - | |
6 | 5 | using Box2DX.Dynamics.Controllers; |
7 | 6 | using Box2DX.Collision; |
8 | 7 | using Box2DX.Dynamics; |
9 | 8 | using Box2DX.Common; |
9 | +using Nlgp1.Box2DX; | |
10 | 10 | |
11 | -namespace Nlgp1.Box2DX | |
11 | +namespace Nlgp1.B2DX.Test | |
12 | 12 | { |
13 | 13 | public class CevTest : ContactEvent |
14 | 14 | { |
15 | - public static bool isRaycast=false; | |
15 | + public static bool isRaycast = false; | |
16 | 16 | |
17 | 17 | public override void Persist(ContactPoint point) |
18 | 18 | { |
19 | 19 | 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); | |
24 | 25 | } |
25 | 26 | |
26 | 27 | public override void Add(ContactPoint point) |
@@ -28,16 +29,19 @@ | ||
28 | 29 | base.Add(point); |
29 | 30 | Shape s1 = point.Shape1, s2 = point.Shape2; |
30 | 31 | if (((myUserData)s1.GetBody().GetUserData()).name == "player" && ((float)(int)point.Position.Y == CalcfromShape.GetBottom(s2))) |
31 | - playerhit(s1,s2); | |
32 | + playerhit(s1, s2); | |
32 | 33 | if (((myUserData)s2.GetBody().GetUserData()).name == "player" && ((float)(int)point.Position.Y == CalcfromShape.GetBottom(s1))) |
33 | - playerhit(s2,s1); | |
34 | + playerhit(s2, s1); | |
34 | 35 | } |
35 | - void playerhit(Shape player,Shape another) | |
36 | + | |
37 | + | |
38 | + void playerhit(Shape player, Shape another) | |
36 | 39 | { |
37 | 40 | if (((myUserData)another.GetBody().GetUserData()).name == "sail") |
38 | - //todo myUserdataにRaycastとかさせるべきか | |
41 | + //todo myUserdataにRaycastとかさせるべきか | |
42 | + //todo RigidBodyにisRayCastの定義を加え、Rayをコントロールする | |
39 | 43 | { |
40 | - myUserData data=(myUserData)player.GetBody().GetUserData(); | |
44 | + myUserData data = (myUserData)player.GetBody().GetUserData(); | |
41 | 45 | data.filter.MaskBits = Convert.ToUInt16("100000", 2); |
42 | 46 | isRaycast = true; |
43 | 47 | //dataはplayerである、下から当たった場合、playerはマスクビットを変更する、 |
@@ -45,7 +49,7 @@ | ||
45 | 49 | } |
46 | 50 | } |
47 | 51 | |
48 | - | |
49 | 52 | |
53 | + | |
50 | 54 | } |
51 | 55 | } |
\ No newline at end of file |
@@ -7,8 +7,9 @@ | ||
7 | 7 | using Box2DX.Collision; |
8 | 8 | using Box2DX.Dynamics; |
9 | 9 | using Box2DX.Common; |
10 | +using Nlgp1.B2DX.Test; | |
10 | 11 | |
11 | -namespace Nlgp1.Box2DX | |
12 | +namespace Nlgp1.Box2DX.Test | |
12 | 13 | { |
13 | 14 | class Program |
14 | 15 | { |
@@ -28,10 +29,12 @@ | ||
28 | 29 | LowerBound = new Vec2(0, 0), |
29 | 30 | UpperBound = new Vec2(512, 384), |
30 | 31 | }, new Vec2(0, 9.8f), false); |
31 | - | |
32 | + | |
33 | + world.AddController(new BuoyancyController()); | |
34 | + | |
32 | 35 | Debug dd = new Debug |
33 | 36 | { |
34 | - Flags = DebugDraw.DrawFlags.Shape | |
37 | + Flags = DebugDraw.DrawFlags.Shape|DebugDraw.DrawFlags.Controller | |
35 | 38 | }; |
36 | 39 | world.SetDebugDraw(dd); |
37 | 40 |
@@ -56,7 +56,7 @@ | ||
56 | 56 | |
57 | 57 | bool keyflag = false; |
58 | 58 | //サイズは半径で設定する |
59 | - //todo IBoxインターフェイスからIBox.MakeShapeとか呼びだして、構成すれば処理を分けられるはず | |
59 | + | |
60 | 60 | DynamicRigid d = new DynamicRigid(new Vec2(42, 170), 0 * pi / 180, world, 16, 16, false, |
61 | 61 | new Dictionary<UserDataKind, string>() |
62 | 62 | { |
@@ -55,9 +55,9 @@ | ||
55 | 55 | } |
56 | 56 | public override void DrawSegment(global::Box2DX.Common.Vec2 p1, global::Box2DX.Common.Vec2 p2, Color color) |
57 | 57 | { |
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); | |
59 | 60 | } |
60 | - | |
61 | 61 | public override void DrawSolidCircle(global::Box2DX.Common.Vec2 center, float radius, global::Box2DX.Common.Vec2 axis, Color color) |
62 | 62 | { |
63 | 63 | DX.DrawCircle((int)center.X, (int)center.Y, (int)radius, new DX.COLOR_U8(0x11ffff),false); |