Новые спрайты (Доспех, искаженный, фурнитура и др.)
This commit is contained in:
parent
207c90a68b
commit
fada807b4d
100 changed files with 1335 additions and 43 deletions
|
@ -2,54 +2,54 @@ using Godot;
|
|||
|
||||
public partial class GameCamera : Camera2D
|
||||
{
|
||||
[Export] public Player Player;
|
||||
[Export] public Vector2 CameraBounds = new(40, 30);
|
||||
[Export] public Vector2 CameraFollowBounds = new(20, 10);
|
||||
[Export] public float Speed = 0.5f;
|
||||
[Export] public Player Player;
|
||||
[Export] public Vector2 CameraBounds = new(40, 30);
|
||||
[Export] public Vector2 CameraFollowBounds = new(20, 10);
|
||||
[Export] public float Speed = 0.5f;
|
||||
|
||||
/// <summary>
|
||||
/// World position of the flashlight
|
||||
/// </summary>
|
||||
public Vector2 FlashlightPosition;
|
||||
/// <summary>
|
||||
/// World position of the flashlight
|
||||
/// </summary>
|
||||
public Vector2 FlashlightPosition;
|
||||
|
||||
public override void _PhysicsProcess(double delta)
|
||||
{
|
||||
var difference = Vector2.Zero;
|
||||
public override void _PhysicsProcess(double delta)
|
||||
{
|
||||
var difference = Vector2.Zero;
|
||||
|
||||
var relativePlayerPosition = Player.Position - Position;
|
||||
var halfCameraBounds = CameraBounds / 2;
|
||||
var halfCameraFollowBounds = CameraFollowBounds / 2;
|
||||
var hardLimit = relativePlayerPosition.Clamp(-halfCameraBounds, halfCameraBounds);
|
||||
difference = relativePlayerPosition - hardLimit;
|
||||
//GD.Print($"HardDiff {difference}");
|
||||
if (difference.IsZeroApprox())
|
||||
{
|
||||
float x = 0, y = 0;
|
||||
if (Mathf.Abs(relativePlayerPosition.X) >= halfCameraFollowBounds.X)
|
||||
{
|
||||
x = relativePlayerPosition.X * Speed * (float)delta;
|
||||
}
|
||||
var relativePlayerPosition = Player.Position - Position;
|
||||
var halfCameraBounds = CameraBounds / 2;
|
||||
var halfCameraFollowBounds = CameraFollowBounds / 2;
|
||||
var hardLimit = relativePlayerPosition.Clamp(-halfCameraBounds, halfCameraBounds);
|
||||
difference = relativePlayerPosition - hardLimit;
|
||||
//GD.Print($"HardDiff {difference}");
|
||||
if (difference.IsZeroApprox())
|
||||
{
|
||||
float x = 0, y = 0;
|
||||
if (Mathf.Abs(relativePlayerPosition.X) >= halfCameraFollowBounds.X)
|
||||
{
|
||||
x = relativePlayerPosition.X * Speed * (float)delta;
|
||||
}
|
||||
|
||||
if (Mathf.Abs(relativePlayerPosition.Y) > halfCameraFollowBounds.Y)
|
||||
{
|
||||
y = relativePlayerPosition.Y * Speed * (float)delta;
|
||||
}
|
||||
if (Mathf.Abs(relativePlayerPosition.Y) > halfCameraFollowBounds.Y)
|
||||
{
|
||||
y = relativePlayerPosition.Y * Speed * (float)delta;
|
||||
}
|
||||
|
||||
difference = new Vector2(x, y);
|
||||
//GD.Print($"SmoothDiff {difference}");
|
||||
}
|
||||
difference = new Vector2(x, y);
|
||||
//GD.Print($"SmoothDiff {difference}");
|
||||
}
|
||||
|
||||
Position = (Position + difference).Round();
|
||||
FlashlightPosition = (FlashlightPosition + difference).Round();
|
||||
}
|
||||
Position = (Position + difference).Round();
|
||||
FlashlightPosition = (FlashlightPosition + difference).Round();
|
||||
}
|
||||
|
||||
public override void _Input(InputEvent @event)
|
||||
{
|
||||
base._Input(@event);
|
||||
public override void _Input(InputEvent @event)
|
||||
{
|
||||
base._Input(@event);
|
||||
|
||||
if (@event is InputEventMouseMotion eventMouseMotion)
|
||||
{
|
||||
FlashlightPosition = eventMouseMotion.Position - Constants.HalfScreenSize + Position;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (@event is InputEventMouseMotion eventMouseMotion)
|
||||
{
|
||||
FlashlightPosition = eventMouseMotion.Position - Constants.HalfScreenSize + Position;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue