Browse Source

add background layers

GitOrigin-RevId: 93a5c7e147
master
Colin McMillen 4 years ago
parent
commit
9ed2021039
  1. 10
      Jumpy.Shared/JumpyGame.cs

10
Jumpy.Shared/JumpyGame.cs

@ -26,6 +26,8 @@ namespace Jumpy {
FpsCounter fpsCounter = new FpsCounter();
Player player;
Texture2D grassland;
Texture2D grasslandBg1;
Texture2D grasslandBg2;
public JumpyGame() {
graphics = new GraphicsDeviceManager(this);
@ -54,6 +56,8 @@ namespace Jumpy {
font = Content.Load<SpriteFont>("font");
player = new Player(Content.Load<Texture2D>("player_1x"));
grassland = Content.Load<Texture2D>("grassland");
grasslandBg1 = Content.Load<Texture2D>("grassland_bg1");
grasslandBg2 = Content.Load<Texture2D>("grassland_bg2");
}
// Called once per game. Unloads all game content.
@ -94,6 +98,12 @@ namespace Jumpy {
GraphicsDevice.Clear(Color.CornflowerBlue);
spriteBatch.Begin();
// Draw background.
Rectangle bgSource = new Rectangle(0, grasslandBg1.Height - Camera.Height, Camera.Width, Camera.Height);
Rectangle bgTarget = new Rectangle(0, 0, Camera.Width, Camera.Height);
spriteBatch.Draw(grasslandBg2, bgTarget, bgSource, Color.White);
spriteBatch.Draw(grasslandBg1, bgTarget, bgSource, Color.White);
// Draw player.
player.Draw(gameTime, spriteBatch);

Loading…
Cancel
Save