Skip to content

Commit

Permalink
Risky commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Nhawdge committed Nov 15, 2023
1 parent e048523 commit 386331f
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions Scenes/Levels/Systems/CameraSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using NovemberPirates.Components;
using NovemberPirates.Systems;
using Raylib_CsLo;
using System.Numerics;

namespace NovemberPirates.Scenes.Levels.Systems
{
Expand All @@ -12,6 +13,8 @@ public CameraSystem()
{
}

private float CameraSpeed = 3f;

internal override void Update(World world)
{
var query = new QueryDescription().WithAll<Player>();
Expand All @@ -23,16 +26,16 @@ internal override void Update(World world)

world.Query(in query, (entity) =>
{
var targetPos = entity.Get<Sprite>().Position;

var xdiff = 0;
var shipSprite = entity.Get<Sprite>();
var targetPos = shipSprite.Position + RayMath.Vector2Rotate(new Vector2(0, -100), shipSprite.RotationAsRadians);
var xdiff = 0;
var ydiff = 0;

var x = targetPos.X - xdiff;
if (x < LeftEdge)
{
x = LeftEdge;
}
}
else if (x > RightEdge)
{
x = RightEdge;
Expand All @@ -46,9 +49,12 @@ internal override void Update(World world)
{
y = BottomEdge;
}
var direction = new Vector2(x, y) - NovemberPiratesEngine.Instance.Camera.target;
var currentPos = NovemberPiratesEngine.Instance.Camera.target;
var futurePos = currentPos + (direction * CameraSpeed * Raylib.GetFrameTime());

NovemberPiratesEngine.Instance.Camera.target.X = x;
NovemberPiratesEngine.Instance.Camera.target.Y = y;
NovemberPiratesEngine.Instance.Camera.target.X = futurePos.X;
NovemberPiratesEngine.Instance.Camera.target.Y = futurePos.Y;
});
}
}
Expand Down

0 comments on commit 386331f

Please sign in to comment.