This commit is contained in:
Nitload
2023-02-14 14:26:57 +08:00
parent b3e55ecfc7
commit 3762a2e5ce
19 changed files with 162 additions and 90 deletions
+5 -4
View File
@@ -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);
}
}
@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace StgSharp
{
public class Launcher
{
}
}
@@ -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> INode.ID => throw new NotImplementedException();
void INode.setID<T>(ContainerNode<T> id)
{
throw new NotImplementedException();
}
void IEntity.SetLocation(StgSharp.Point p)
{
this._position = p._position;
}
}
}
@@ -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<INode> _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> INode.ID
{
get { return _id; }
}
void INode.setID<T>(ContainerNode<T> id)
{
if (id == null)
{
_id = id as ContainerNode<INode>;
}
else
{
throw new ArgumentException("Cannot set id twice!");
}
}
}
}
+13 -12
View File
@@ -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<INode> _id;
internal float _x;
internal float _y;
internal Vec2D _position;
public GetLocationHandler getXHandler;
public GetLocationHandler getYHandler;
internal GetLocationHandler getXHandler;
internal GetLocationHandler getYHandler;
ContainerNode<INode> 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<T>(ContainerNode<T> 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);
}
}
}
+26 -6
View File
@@ -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<Vec2D>
{
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;
}
}
}