diff --git a/源代码/.Net/.vs/ProjectEvaluation/stgsharp.metadata.v5.1 b/源代码/.Net/.vs/ProjectEvaluation/stgsharp.metadata.v5.1 index e7201294..37909dd7 100644 Binary files a/源代码/.Net/.vs/ProjectEvaluation/stgsharp.metadata.v5.1 and b/源代码/.Net/.vs/ProjectEvaluation/stgsharp.metadata.v5.1 differ diff --git a/源代码/.Net/.vs/ProjectEvaluation/stgsharp.projects.v5.1 b/源代码/.Net/.vs/ProjectEvaluation/stgsharp.projects.v5.1 index 9b04dbc5..3504c6a9 100644 Binary files a/源代码/.Net/.vs/ProjectEvaluation/stgsharp.projects.v5.1 and b/源代码/.Net/.vs/ProjectEvaluation/stgsharp.projects.v5.1 differ diff --git a/源代码/.Net/.vs/StgSharp/DesignTimeBuild/.dtbcache.v2 b/源代码/.Net/.vs/StgSharp/DesignTimeBuild/.dtbcache.v2 index 9293ff98..dc2b804e 100644 Binary files a/源代码/.Net/.vs/StgSharp/DesignTimeBuild/.dtbcache.v2 and b/源代码/.Net/.vs/StgSharp/DesignTimeBuild/.dtbcache.v2 differ diff --git a/源代码/.Net/.vs/StgSharp/FileContentIndex/07b2d65b-b2c2-40bc-a4bc-097c200571d5.vsidx b/源代码/.Net/.vs/StgSharp/FileContentIndex/07b2d65b-b2c2-40bc-a4bc-097c200571d5.vsidx new file mode 100644 index 00000000..5093a873 Binary files /dev/null and b/源代码/.Net/.vs/StgSharp/FileContentIndex/07b2d65b-b2c2-40bc-a4bc-097c200571d5.vsidx differ diff --git a/源代码/.Net/.vs/StgSharp/FileContentIndex/0c557f91-9a0a-4d1b-8307-dceb90ab8eaf.vsidx b/源代码/.Net/.vs/StgSharp/FileContentIndex/0c557f91-9a0a-4d1b-8307-dceb90ab8eaf.vsidx new file mode 100644 index 00000000..ca77d449 Binary files /dev/null and b/源代码/.Net/.vs/StgSharp/FileContentIndex/0c557f91-9a0a-4d1b-8307-dceb90ab8eaf.vsidx differ diff --git a/源代码/.Net/.vs/StgSharp/FileContentIndex/1470937e-e6c4-4aa2-912a-47943bbb1ba9.vsidx b/源代码/.Net/.vs/StgSharp/FileContentIndex/1470937e-e6c4-4aa2-912a-47943bbb1ba9.vsidx deleted file mode 100644 index cc342d9f..00000000 Binary files a/源代码/.Net/.vs/StgSharp/FileContentIndex/1470937e-e6c4-4aa2-912a-47943bbb1ba9.vsidx and /dev/null differ diff --git a/源代码/.Net/.vs/StgSharp/FileContentIndex/191fd840-0cde-431b-b796-68ea1faf15b9.vsidx b/源代码/.Net/.vs/StgSharp/FileContentIndex/191fd840-0cde-431b-b796-68ea1faf15b9.vsidx deleted file mode 100644 index fe4da020..00000000 Binary files a/源代码/.Net/.vs/StgSharp/FileContentIndex/191fd840-0cde-431b-b796-68ea1faf15b9.vsidx and /dev/null differ diff --git a/源代码/.Net/.vs/StgSharp/FileContentIndex/6b7598c3-e340-433b-ba18-617d267e2e5e.vsidx b/源代码/.Net/.vs/StgSharp/FileContentIndex/6b7598c3-e340-433b-ba18-617d267e2e5e.vsidx new file mode 100644 index 00000000..c37d41c4 Binary files /dev/null and b/源代码/.Net/.vs/StgSharp/FileContentIndex/6b7598c3-e340-433b-ba18-617d267e2e5e.vsidx differ diff --git a/源代码/.Net/.vs/StgSharp/FileContentIndex/4d486994-9111-43bd-bd68-fbb0688a435f.vsidx b/源代码/.Net/.vs/StgSharp/FileContentIndex/d055ba80-e653-485e-a079-70ffcec6f92c.vsidx similarity index 74% rename from 源代码/.Net/.vs/StgSharp/FileContentIndex/4d486994-9111-43bd-bd68-fbb0688a435f.vsidx rename to 源代码/.Net/.vs/StgSharp/FileContentIndex/d055ba80-e653-485e-a079-70ffcec6f92c.vsidx index c71ca17e..aff7b4e8 100644 Binary files a/源代码/.Net/.vs/StgSharp/FileContentIndex/4d486994-9111-43bd-bd68-fbb0688a435f.vsidx and b/源代码/.Net/.vs/StgSharp/FileContentIndex/d055ba80-e653-485e-a079-70ffcec6f92c.vsidx differ diff --git a/源代码/.Net/.vs/StgSharp/FileContentIndex/f912e19e-ea74-4103-88aa-083bf7feb61a.vsidx b/源代码/.Net/.vs/StgSharp/FileContentIndex/f912e19e-ea74-4103-88aa-083bf7feb61a.vsidx deleted file mode 100644 index aba7ca38..00000000 Binary files a/源代码/.Net/.vs/StgSharp/FileContentIndex/f912e19e-ea74-4103-88aa-083bf7feb61a.vsidx and /dev/null differ diff --git a/源代码/.Net/.vs/StgSharp/v17/.futdcache.v2 b/源代码/.Net/.vs/StgSharp/v17/.futdcache.v2 index e792fc13..dd087324 100644 Binary files a/源代码/.Net/.vs/StgSharp/v17/.futdcache.v2 and b/源代码/.Net/.vs/StgSharp/v17/.futdcache.v2 differ diff --git a/源代码/.Net/.vs/StgSharp/v17/.suo b/源代码/.Net/.vs/StgSharp/v17/.suo index d788cb8a..c75ed1e3 100644 Binary files a/源代码/.Net/.vs/StgSharp/v17/.suo and b/源代码/.Net/.vs/StgSharp/v17/.suo differ diff --git a/源代码/.Net/StgSharp/Entities/IEntity.cs b/源代码/.Net/StgSharp/Entities/IEntity.cs index 7d47da83..9407bfb0 100644 --- a/源代码/.Net/StgSharp/Entities/IEntity.cs +++ b/源代码/.Net/StgSharp/Entities/IEntity.cs @@ -1,4 +1,5 @@ using StgSharp; +using StgSharp.Vector; using System; using System.Collections.Generic; using System.Text; @@ -7,14 +8,14 @@ namespace StgSharp { public interface IEntity:INode { - - - public IGeometry CollisionShape { get; set; } + public IGeometry CollisionBox { get; set; } public Sensor CollisionSensor { get; set; } public string Texture { get; set; } - public Point Location { get; set; } + public Vec2D Location { get; } + + public void SetLocation(Point p); } } diff --git a/源代码/.Net/StgSharp/Entities/Launcher.cs b/源代码/.Net/StgSharp/Entities/Launcher.cs new file mode 100644 index 00000000..b2b11383 --- /dev/null +++ b/源代码/.Net/StgSharp/Entities/Launcher.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace StgSharp +{ + public class Launcher + { + + } +} diff --git a/源代码/.Net/StgSharp/Entities/Partical.cs b/源代码/.Net/StgSharp/Entities/Partical.cs new file mode 100644 index 00000000..3914e8bb --- /dev/null +++ b/源代码/.Net/StgSharp/Entities/Partical.cs @@ -0,0 +1,47 @@ +using StgSharp.Vector; +using System; +using System.Collections.Generic; +using System.Text; + +namespace StgSharp +{ + public class Partical : IEntity + { + internal IGeometry _collisionBox; + internal Sensor _collisionSensor; + internal string _texture; + internal Vec2D _position; + + IGeometry IEntity.CollisionBox + { + get { return _collisionBox; } + set { _collisionBox = value; } + } + Sensor IEntity.CollisionSensor + { + get { return _collisionSensor; } + set { _collisionSensor = value; } + } + string IEntity.Texture + { + get { return _texture; } + set { _texture = value; } + } + Vec2D IEntity.Location + { + get { return _position; } + } + + ContainerNode INode.ID => throw new NotImplementedException(); + + void INode.setID(ContainerNode id) + { + throw new NotImplementedException(); + } + + void IEntity.SetLocation(StgSharp.Point p) + { + this._position = p._position; + } + } +} diff --git a/源代码/.Net/StgSharp/Entities/Player.cs b/源代码/.Net/StgSharp/Entities/Player.cs new file mode 100644 index 00000000..341e1f97 --- /dev/null +++ b/源代码/.Net/StgSharp/Entities/Player.cs @@ -0,0 +1,58 @@ +using StgSharp.Vector; +using System; +using System.Collections.Generic; +using System.Text; + +namespace StgSharp +{ + public class Player : IEntity + { + internal IGeometry _collisionBox; + internal Sensor _collisionSensor; + internal string _texture; + internal Vec2D _position; + private ContainerNode _id; + + IGeometry IEntity.CollisionBox + { + get { return this._collisionBox; } + set { this._collisionBox = value; } + } + Sensor IEntity.CollisionSensor + { + get { return this._collisionSensor; } + set { this._collisionSensor = value; } + } + string IEntity.Texture + { + get { return this._texture; } + set { this._texture = value; } + } + Vec2D IEntity.Location + { + get { return this._position; } + set { this._position = value; } + } + + ContainerNode INode.ID + { + get { return _id; } + } + + void INode.setID(ContainerNode id) + { + if (id == null) + { + _id = id as ContainerNode; + } + else + { + throw new ArgumentException("Cannot set id twice!"); + } + } + + + + + } +} diff --git a/源代码/.Net/StgSharp/Geometries/point.cs b/源代码/.Net/StgSharp/Geometries/point.cs index ea24611b..dc2fd7e3 100644 --- a/源代码/.Net/StgSharp/Geometries/point.cs +++ b/源代码/.Net/StgSharp/Geometries/point.cs @@ -1,5 +1,6 @@ using GLFWDotNet; using StgSharp; +using StgSharp.Vector; using System; using System.Collections.Generic; using System.Drawing; @@ -13,11 +14,10 @@ namespace StgSharp { internal StgSharp.ContainerNode _id; - internal float _x; - internal float _y; + internal Vec2D _position; - public GetLocationHandler getXHandler; - public GetLocationHandler getYHandler; + internal GetLocationHandler getXHandler; + internal GetLocationHandler getYHandler; ContainerNode INode.ID { @@ -26,17 +26,12 @@ namespace StgSharp public float X { - get - { - return getXHandler(Control.TimeLine.tickCounter); - } + get { return this._position.X; } } + public float Y { - get - { - return getYHandler(Control.TimeLine.tickCounter); - } + get { return this._position.Y; } } void INode.setID(ContainerNode id) @@ -50,5 +45,11 @@ namespace StgSharp throw new ArgumentException("Cannot set id twice!"); } } + + public void OnRender() + { + this.getXHandler.Invoke(Control.TimeLine.tickCounter); + this.getYHandler.Invoke(Control.TimeLine.tickCounter); + } } } diff --git a/源代码/.Net/StgSharp/Vector/Vec2x1.cs b/源代码/.Net/StgSharp/Vector/Vec2x1.cs index e94b0be8..3e4342c5 100644 --- a/源代码/.Net/StgSharp/Vector/Vec2x1.cs +++ b/源代码/.Net/StgSharp/Vector/Vec2x1.cs @@ -1,22 +1,24 @@ using StgSharp.Math; using System; using System.Collections.Generic; +using System.Data.Common; using System.Text; namespace StgSharp.Vector { public struct Vec2D:IEquatable { - float X; - float Y; - float Direction; - float Length; + public float X; + public float Y; + public float Direction; + public float Length; public Vec2D(float x,float y) { X = x; Y = y; - Direction = 0; + Direction = Calc.ATan(X,Y); + Length = Calc.Sqrt(X * X + Y * Y); } public bool Equals(Vec2D other) @@ -77,6 +79,24 @@ namespace StgSharp.Vector return new Vec2D(vec1.X + vec2.X, vec1.Y + vec2.Y); } - public static + public static float operator *(Vec2D vec1, Vec2D vec2) + { + return vec1.X * vec2.X + vec1.Y*vec2.Y; + } + + public static Vec2D operator *(Vec2D vec, float x) + { + return new Vec2D(vec.X * x, vec.Y * x); + } + + public static Vec2D operator /(Vec2D vec, float x) + { + return new Vec2D(vec.X/x, vec.Y/x); + } + + public float x(Vec2D others) + { + return this.X * others.Y - this.Y * others.X; + } } } diff --git a/源代码/.Net/StgSharpDebug/Program.cs b/源代码/.Net/StgSharpDebug/Program.cs index 6480eaee..56c8cc16 100644 --- a/源代码/.Net/StgSharpDebug/Program.cs +++ b/源代码/.Net/StgSharpDebug/Program.cs @@ -1,4 +1,5 @@ using StgSharp; +using StgSharp.Vector; using System; using System.Diagnostics; @@ -6,74 +7,7 @@ internal class Program { private unsafe static void Main(string[] args) { - /* - int cc = 3; - Console.WriteLine(cc/2); - /**/ - - /* - float test = StgSharp.Math.Calc.ATan(-1f,-1f); - Console.WriteLine(test); - /**/ - - /* - // 测速 - for (int cycle = 0; cycle < 100; cycle++) - { - float time = 1000000; - float a = 114514; - System.Diagnostics.Stopwatch stopwatch = new Stopwatch(); - stopwatch.Start(); // 开始监视代码运行时间 - for (float i = 2; i < time; i++) - { - a = StgSharp.Math.ATan(i); - } - stopwatch.Stop(); // 停止监视 - TimeSpan timespan = stopwatch.Elapsed; // 获取当前实例测量得出的总时间 - double milliseconds = timespan.TotalMilliseconds; // 总毫秒数 - Console.WriteLine($"{milliseconds},{a}"); - - - System.Diagnostics.Stopwatch stopwatch1 = new Stopwatch(); - double b = 114514; - double time2 = time; - stopwatch1.Start(); - for (float i = 2; i < time2; i++) - { - b = System.MathF.Atan(i); - } - stopwatch1.Stop(); - timespan = stopwatch1.Elapsed; - double milliseconds2 = timespan.TotalMilliseconds; - Console.WriteLine($"{milliseconds2},{b}"); - Console.WriteLine(""); - } - /**/ - - - /* - //精度测试 - double accuracy = 0; - for (float i = -200f; i < 200f; i += 0.01f) - { - - double r1 = StgSharp.Math.ATan(i); - double r2 = 180*System.Math.Atan(i)/3.1415926; - double ac = ( System.Math.Max(r1,r2)- System.Math.Min(r1, r2) ) / r2; - if (ac>accuracy) - { - accuracy = ac; - Console.WriteLine(i); - Console.WriteLine(ac); - Console.WriteLine(r1); - Console.WriteLine(r2); - Console.WriteLine(""); - } - } - Console.WriteLine(accuracy); - /**/ - - } } +