From 7c0eb479a64c6db5e608869ec410e239659fcb5c Mon Sep 17 00:00:00 2001 From: Colin McMillen Date: Wed, 25 Mar 2020 12:38:56 -0400 Subject: [PATCH] scroll y by a constant scale instead of per-layer. --- Shared/Scene.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Shared/Scene.cs b/Shared/Scene.cs index 0212c15..4e929f7 100644 --- a/Shared/Scene.cs +++ b/Shared/Scene.cs @@ -74,14 +74,16 @@ namespace SemiColinGames { spriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.LinearWrap, null, null); Rectangle bgTarget = new Rectangle(0, 0, camera.Width, camera.Height); - float bgScale = 1f / 16; + float xScale = 1f / 16; // Changes with each layer (the layers further back scroll less). + float yScale = 1f / 4; // Constant across all layers. for (int i = 0; i < Textures.Backgrounds.Length; i++) { - float yDiff = (world.Height - camera.Bottom) * bgScale; - float yOffset = Textures.Backgrounds[i].Get.Height - camera.Height - yDiff; + Texture2D background = Textures.Backgrounds[i].Get; + float yDiff = (world.Height - camera.Bottom) * yScale; + float yOffset = background.Height - camera.Height - yDiff; Rectangle bgSource = new Rectangle( - (int) (camera.Left * bgScale), (int) yOffset, camera.Width, camera.Height); - spriteBatch.Draw(Textures.Backgrounds[i].Get, bgTarget, bgSource, Color.White); - bgScale *= 2; + (int) (camera.Left * xScale), (int) yOffset, camera.Width, camera.Height); + spriteBatch.Draw(background, bgTarget, bgSource, Color.White); + xScale *= 2; } spriteBatch.End();