From ad0e2a2c84d779d646e3db6d57df7dc6075fa7e2 Mon Sep 17 00:00:00 2001 From: Damar Indra Date: Wed, 3 Jun 2020 10:48:56 +0700 Subject: [PATCH 1/2] Simulate using IBox instead Box --- Sources/Humper/Base/RectangleF.cs | 1 + Sources/Humper/IWorld.cs | 2 +- Sources/Humper/World.cs | 4 +- .../Humper.Sample.Basic.csproj | 75 ++++++++++++------- .../Humper.Sample.Basic/packages.config | 13 ++++ 5 files changed, 65 insertions(+), 30 deletions(-) create mode 100644 Sources/Samples/Humper.Sample.Basic/packages.config diff --git a/Sources/Humper/Base/RectangleF.cs b/Sources/Humper/Base/RectangleF.cs index 61b2b21..07881f9 100644 --- a/Sources/Humper/Base/RectangleF.cs +++ b/Sources/Humper/Base/RectangleF.cs @@ -415,6 +415,7 @@ public static RectangleF Union(RectangleF value1, RectangleF value2) /// The union of the two rectangles as an output parameter. public static void Union(ref RectangleF value1, ref RectangleF value2, out RectangleF result) { + result = default; result.X = Math.Min(value1.X, value2.X); result.Y = Math.Min(value1.Y, value2.Y); result.Width = Math.Max(value1.Right, value2.Right) - result.X; diff --git a/Sources/Humper/IWorld.cs b/Sources/Humper/IWorld.cs index 04ef494..44973cf 100644 --- a/Sources/Humper/IWorld.cs +++ b/Sources/Humper/IWorld.cs @@ -91,7 +91,7 @@ public interface IWorld /// The x coordinate. /// The y coordinate. /// Filter. - IMovement Simulate(Box box, float x, float y, Func filter); + IMovement Simulate(IBox box, float x, float y, Func filter); #endregion diff --git a/Sources/Humper/World.cs b/Sources/Humper/World.cs index bcdd06c..452e818 100644 --- a/Sources/Humper/World.cs +++ b/Sources/Humper/World.cs @@ -135,7 +135,7 @@ public IHit Hit(RectangleF origin, RectangleF destination, IEnumerable ign #region Movements - public IMovement Simulate(Box box, float x, float y, Func filter) + public IMovement Simulate(IBox box, float x, float y, Func filter) { var origin = box.Bounds; var destination = new RectangleF(x, y, box.Width, box.Height); @@ -153,7 +153,7 @@ public IMovement Simulate(Box box, float x, float y, Func hits, List ignoring, Box box, RectangleF origin, RectangleF destination, Func filter) + private RectangleF Simulate(List hits, List ignoring, IBox box, RectangleF origin, RectangleF destination, Func filter) { var nearest = this.Hit(origin, destination, ignoring); diff --git a/Sources/Samples/Humper.Sample.Basic/Humper.Sample.Basic.csproj b/Sources/Samples/Humper.Sample.Basic/Humper.Sample.Basic.csproj index 1ebec29..b046dd1 100644 --- a/Sources/Samples/Humper.Sample.Basic/Humper.Sample.Basic.csproj +++ b/Sources/Samples/Humper.Sample.Basic/Humper.Sample.Basic.csproj @@ -29,12 +29,49 @@ false + + ..\..\packages\MonoGame.Framework.WindowsDX.3.7.1.189\lib\net45\MonoGame.Framework.dll + True + + + ..\..\packages\SharpDX.4.0.1\lib\net45\SharpDX.dll + True + + + ..\..\packages\SharpDX.Direct2D1.4.0.1\lib\net45\SharpDX.Direct2D1.dll + True + + + ..\..\packages\SharpDX.Direct3D11.4.0.1\lib\net45\SharpDX.Direct3D11.dll + True + + + ..\..\packages\SharpDX.Direct3D9.4.0.1\lib\net45\SharpDX.Direct3D9.dll + True + + + ..\..\packages\SharpDX.DXGI.4.0.1\lib\net45\SharpDX.DXGI.dll + True + + + ..\..\packages\SharpDX.Mathematics.4.0.1\lib\net45\SharpDX.Mathematics.dll + True + + + ..\..\packages\SharpDX.MediaFoundation.4.0.1\lib\net45\SharpDX.MediaFoundation.dll + True + + + ..\..\packages\SharpDX.XAudio2.4.0.1\lib\net45\SharpDX.XAudio2.dll + True + + + ..\..\packages\SharpDX.XInput.4.0.1\lib\net45\SharpDX.XInput.dll + True + - - $(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\DesktopGL\MonoGame.Framework.dll - @@ -51,6 +88,7 @@ + @@ -59,30 +97,6 @@ - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - PreserveNewest @@ -104,4 +118,11 @@ + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}. + + + \ No newline at end of file diff --git a/Sources/Samples/Humper.Sample.Basic/packages.config b/Sources/Samples/Humper.Sample.Basic/packages.config new file mode 100644 index 0000000..b4e8960 --- /dev/null +++ b/Sources/Samples/Humper.Sample.Basic/packages.config @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file From df411cea5f366c6724e4dea9a4515f409eddb71c Mon Sep 17 00:00:00 2001 From: Damar Indra Date: Wed, 3 Jun 2020 10:55:34 +0700 Subject: [PATCH 2/2] fixes simulate doing move on Box --- Sources/Humper/Box.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Sources/Humper/Box.cs b/Sources/Humper/Box.cs index d2f2633..2d8173e 100644 --- a/Sources/Humper/Box.cs +++ b/Sources/Humper/Box.cs @@ -53,13 +53,12 @@ public IMovement Simulate(float x, float y, Func public IMovement Simulate(float x, float y, Func filter) { - return Move(x, y, (col) => - { + return world.Simulate(this, x, y, (col) => + { if (col.Hit == null) - return null; - - return CollisionResponse.Create(col, filter(col)); - }); + return null; + return CollisionResponse.Create(col, filter(col)); + }); } public IMovement Move(float x, float y, Func filter)