|
|
@ -44,36 +44,22 @@ namespace SemiColinGames { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// Draw scene to sceneTarget.
|
|
|
|
graphics.SetRenderTarget(sceneTarget); |
|
|
|
graphics.Clear(backgroundColor); |
|
|
|
|
|
|
|
// Draw scene to sceneTarget.
|
|
|
|
spriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.LinearWrap, null, null); |
|
|
|
|
|
|
|
// Draw background.
|
|
|
|
|
|
|
|
// We assume that all backgrounds are the same size; if not, the computation of yOffset needs
|
|
|
|
// to be computed separately for every background.
|
|
|
|
int yOffset = Textures.Background1.Height - camera.Height - 64; |
|
|
|
Color bgBlend = Color.FromNonPremultiplied(new Vector4(1, 1, 1, 1)); |
|
|
|
spriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.LinearWrap, null, null); |
|
|
|
Rectangle bgTarget = new Rectangle(0, 0, camera.Width, camera.Height); |
|
|
|
|
|
|
|
float xScale = 1f / 16; |
|
|
|
for (int i = 0; i < Textures.Backgrounds.Length; i++) { |
|
|
|
int yOffset = Textures.Backgrounds[i].Height - camera.Height - 24; |
|
|
|
Rectangle bgSource = new Rectangle( |
|
|
|
(int) (camera.Left * 1f / 16), yOffset, camera.Width, camera.Height); |
|
|
|
spriteBatch.Draw(Textures.Background1, bgTarget, bgSource, bgBlend); |
|
|
|
|
|
|
|
bgSource = new Rectangle( |
|
|
|
(int) (camera.Left * 1f / 8), yOffset, camera.Width, camera.Height); |
|
|
|
spriteBatch.Draw(Textures.Background2, bgTarget, bgSource, bgBlend); |
|
|
|
|
|
|
|
bgSource = new Rectangle( |
|
|
|
(int) (camera.Left * 1f / 4), yOffset, camera.Width, camera.Height); |
|
|
|
spriteBatch.Draw(Textures.Background3, bgTarget, bgSource, bgBlend); |
|
|
|
|
|
|
|
bgSource = new Rectangle( |
|
|
|
(int) (camera.Left * 1f / 2), yOffset, camera.Width, camera.Height); |
|
|
|
spriteBatch.Draw(Textures.Background4, bgTarget, bgSource, bgBlend); |
|
|
|
|
|
|
|
(int) (camera.Left * xScale), yOffset, camera.Width, camera.Height); |
|
|
|
spriteBatch.Draw(Textures.Backgrounds[i], bgTarget, bgSource, Color.White); |
|
|
|
xScale *= 2; |
|
|
|
} |
|
|
|
spriteBatch.End(); |
|
|
|
|
|
|
|
// Set up transformation matrix for drawing world objects.
|
|
|
|