diff --git a/Shared/Camera.cs b/Shared/Camera.cs index 7bf683f..ad5b3b8 100644 --- a/Shared/Camera.cs +++ b/Shared/Camera.cs @@ -11,6 +11,8 @@ namespace SemiColinGames { public int Height { get => bbox.Height; } public int Left { get => bbox.Left; } public int Top { get => bbox.Top; } + public int Bottom { get => bbox.Bottom; } + public Point HalfSize { get => new Point(Width / 2, Height / 2); } private readonly Random random = new Random(); diff --git a/Shared/Scene.cs b/Shared/Scene.cs index 7c1418d..0212c15 100644 --- a/Shared/Scene.cs +++ b/Shared/Scene.cs @@ -74,13 +74,14 @@ namespace SemiColinGames { spriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.LinearWrap, null, null); Rectangle bgTarget = new Rectangle(0, 0, camera.Width, camera.Height); - float xScale = 1f / 16; + float bgScale = 1f / 16; for (int i = 0; i < Textures.Backgrounds.Length; i++) { - int yOffset = Textures.Backgrounds[i].Get.Height - camera.Height - 24; + float yDiff = (world.Height - camera.Bottom) * bgScale; + float yOffset = Textures.Backgrounds[i].Get.Height - camera.Height - yDiff; Rectangle bgSource = new Rectangle( - (int) (camera.Left * xScale), yOffset, camera.Width, camera.Height); + (int) (camera.Left * bgScale), (int) yOffset, camera.Width, camera.Height); spriteBatch.Draw(Textures.Backgrounds[i].Get, bgTarget, bgSource, Color.White); - xScale *= 2; + bgScale *= 2; } spriteBatch.End();