Support 4-layer parallax-scrolling backgrounds.
GitOrigin-RevId: 58c1d1fee99e56dd656af5bbf628fbdc16d55e14
This commit is contained in:
parent
8405f32f3c
commit
05638483a4
@ -51,14 +51,29 @@ namespace SemiColinGames {
|
|||||||
spriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.LinearWrap, null, null);
|
spriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.LinearWrap, null, null);
|
||||||
|
|
||||||
// Draw background.
|
// Draw background.
|
||||||
Color bgBlend = Color.FromNonPremultiplied(new Vector4(1, 1, 1, 0.5f));
|
|
||||||
Rectangle bgSource = new Rectangle(
|
// We assume that all backgrounds are the same size; if not, the computation of yOffset needs
|
||||||
(int) (camera.Left * 0.25), 0, camera.Width, camera.Height);
|
// 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));
|
||||||
Rectangle bgTarget = new Rectangle(0, 0, camera.Width, camera.Height);
|
Rectangle bgTarget = new Rectangle(0, 0, camera.Width, camera.Height);
|
||||||
spriteBatch.Draw(Textures.Background2, bgTarget, bgSource, bgBlend);
|
|
||||||
bgSource = new Rectangle(
|
Rectangle bgSource = new Rectangle(
|
||||||
(int) (camera.Left * 0.5), 0, camera.Width, camera.Height);
|
(int) (camera.Left * 1f / 16), yOffset, camera.Width, camera.Height);
|
||||||
spriteBatch.Draw(Textures.Background1, bgTarget, bgSource, bgBlend);
|
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);
|
||||||
|
|
||||||
spriteBatch.End();
|
spriteBatch.End();
|
||||||
|
|
||||||
// Set up transformation matrix for drawing world objects.
|
// Set up transformation matrix for drawing world objects.
|
||||||
|
@ -8,6 +8,8 @@ namespace SemiColinGames {
|
|||||||
|
|
||||||
public static Texture2D Background1;
|
public static Texture2D Background1;
|
||||||
public static Texture2D Background2;
|
public static Texture2D Background2;
|
||||||
|
public static Texture2D Background3;
|
||||||
|
public static Texture2D Background4;
|
||||||
|
|
||||||
public static Texture2D Cemetery;
|
public static Texture2D Cemetery;
|
||||||
public static Texture2D Crypt;
|
public static Texture2D Crypt;
|
||||||
@ -25,8 +27,10 @@ namespace SemiColinGames {
|
|||||||
public static void Load(ContentManager content) {
|
public static void Load(ContentManager content) {
|
||||||
Player = content.Load<Texture2D>("sprites/ccg/ninja_female");
|
Player = content.Load<Texture2D>("sprites/ccg/ninja_female");
|
||||||
|
|
||||||
Background1 = content.Load<Texture2D>("backgrounds/anokolisa/grassland_bg1");
|
Background1 = content.Load<Texture2D>("backgrounds/szadiart/pf4/background1_day");
|
||||||
Background2 = content.Load<Texture2D>("backgrounds/anokolisa/grassland_bg2");
|
Background2 = content.Load<Texture2D>("backgrounds/szadiart/pf4/background2a_day");
|
||||||
|
Background3 = content.Load<Texture2D>("backgrounds/szadiart/pf4/background3_day");
|
||||||
|
Background4 = content.Load<Texture2D>("backgrounds/szadiart/pf4/background4_day");
|
||||||
|
|
||||||
Cemetery = content.Load<Texture2D>("tiles/anokolisa/cemetery");
|
Cemetery = content.Load<Texture2D>("tiles/anokolisa/cemetery");
|
||||||
Crypt = content.Load<Texture2D>("tiles/anokolisa/crypt");
|
Crypt = content.Load<Texture2D>("tiles/anokolisa/crypt");
|
||||||
|
Loading…
Reference in New Issue
Block a user