mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-12-24 01:09:23 +01:00
border constraints as well as some other useful goodies
This commit is contained in:
parent
3cde47c762
commit
2ead7c6c6b
2 changed files with 22 additions and 6 deletions
|
@ -15,8 +15,16 @@ namespace MLEM.Cameras {
|
|||
return Matrix.CreateScale(this.Scale, this.Scale, 1) * Matrix.CreateTranslation(new Vector3(pos, 0));
|
||||
}
|
||||
}
|
||||
public Vector2 LookingPosition => this.Position + new Vector2(this.Viewport.Width / 2, this.Viewport.Height / 2) / this.Scale;
|
||||
public Vector2 Max {
|
||||
get => this.Position + this.ScaledViewport;
|
||||
set => this.Position = value - this.ScaledViewport;
|
||||
}
|
||||
public Vector2 LookingPosition {
|
||||
get => this.Position + this.ScaledViewport / 2;
|
||||
set => this.Position = value - this.ScaledViewport / 2;
|
||||
}
|
||||
public Viewport Viewport => this.graphicsDevice.Viewport;
|
||||
public Vector2 ScaledViewport => new Vector2(this.Viewport.Width, this.Viewport.Height) / this.Scale;
|
||||
|
||||
private readonly bool roundPosition;
|
||||
private readonly GraphicsDevice graphicsDevice;
|
||||
|
@ -26,10 +34,6 @@ namespace MLEM.Cameras {
|
|||
this.roundPosition = roundPosition;
|
||||
}
|
||||
|
||||
public void LookAt(Vector2 worldPos) {
|
||||
this.Position = worldPos - new Vector2(this.Viewport.Width / 2, this.Viewport.Height / 2) / this.Scale;
|
||||
}
|
||||
|
||||
public Vector2 ToWorldPos(Vector2 pos) {
|
||||
return Vector2.Transform(pos, Matrix.Invert(this.ViewMatrix));
|
||||
}
|
||||
|
@ -42,5 +46,17 @@ namespace MLEM.Cameras {
|
|||
return (this.ToWorldPos(Vector2.Zero), this.ToWorldPos(new Vector2(this.Viewport.Width, this.Viewport.Height)));
|
||||
}
|
||||
|
||||
public void ConstrainWorldBounds(Vector2 min, Vector2 max) {
|
||||
if (this.Position.X < min.X)
|
||||
this.Position.X = min.X;
|
||||
if (this.Position.Y < min.Y)
|
||||
this.Position.Y = min.Y;
|
||||
|
||||
if (this.Max.X > max.X)
|
||||
this.Max = new Vector2(max.X, this.Max.Y);
|
||||
if (this.Max.Y > max.Y)
|
||||
this.Max = new Vector2(this.Max.X, max.Y);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -10,7 +10,7 @@
|
|||
<PackageProjectUrl>https://github.com/Ellpeck/MLEM</PackageProjectUrl>
|
||||
<RepositoryUrl>https://github.com/Ellpeck/MLEM</RepositoryUrl>
|
||||
<PackageLicenseUrl>https://github.com/Ellpeck/MLEM/blob/master/LICENSE</PackageLicenseUrl>
|
||||
<Version>1.0.9</Version>
|
||||
<Version>1.0.10</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
Loading…
Reference in a new issue