still working on movement, for some reason some cells do not get set as solid that's why multiple can go on a cell
This commit is contained in:
@@ -29,8 +29,7 @@ public partial class Tower : Sprite2D
|
||||
{
|
||||
if (_arcEnd != GetGlobalMousePosition())
|
||||
{
|
||||
float arcAngle = CalculateLaunchAngle(_attackSpawn.GlobalPosition, GetGlobalMousePosition());
|
||||
DrawArc(arcAngle, _attackSpawn.GlobalPosition, GetGlobalMousePosition());
|
||||
DrawArc(_attackSpawn.GlobalPosition, GetGlobalMousePosition());
|
||||
}
|
||||
if (Input.IsActionJustPressed("rightClick"))
|
||||
{
|
||||
@@ -96,8 +95,17 @@ public partial class Tower : Sprite2D
|
||||
|
||||
bestAngle = testAngle;
|
||||
}
|
||||
bestAngle = (float)Mathf.Clamp(bestAngle, Math.PI, Math.PI * 2);
|
||||
|
||||
if (ToLaunchVector(bestAngle).Y < 0)
|
||||
{
|
||||
if (END.X < START.X)
|
||||
{
|
||||
bestAngle = (float)Math.PI;
|
||||
}
|
||||
else
|
||||
{
|
||||
bestAngle = 0;
|
||||
}
|
||||
}
|
||||
return bestAngle;
|
||||
}
|
||||
|
||||
@@ -107,12 +115,12 @@ public partial class Tower : Sprite2D
|
||||
path.Curve.ClearPoints();
|
||||
}
|
||||
|
||||
public void DrawArc(float ANGLE, Vector2 START, Vector2 END, int MAX_ITERATIONS = 20)
|
||||
public void DrawArc(Vector2 START, Vector2 END, int MAX_ITERATIONS = 20)
|
||||
{
|
||||
CalculateLaunchAngle(START, END);
|
||||
float arcAngle = CalculateLaunchAngle(START, END);
|
||||
|
||||
float speed = _launchSpeed, gravity = Globals._gravity, drag = Globals._drag, delta = 1.0f / 60.0f;
|
||||
Vector2 velocity = new Vector2(Mathf.Cos(ANGLE), Mathf.Sin(ANGLE)) * speed;
|
||||
Vector2 velocity = new Vector2(Mathf.Cos(arcAngle), Mathf.Sin(arcAngle)) * speed;
|
||||
Vector2 position = START;
|
||||
|
||||
float directionSign = Mathf.Sign(END.X - START.X);
|
||||
|
||||
Reference in New Issue
Block a user