From 9ed202103968540577531ee522c2e9306ddbe943 Mon Sep 17 00:00:00 2001 From: Colin McMillen Date: Tue, 10 Dec 2019 16:37:49 -0500 Subject: [PATCH] add background layers GitOrigin-RevId: 93a5c7e147d9d571fb67bfd818f598e4da823abb --- Jumpy.Shared/JumpyGame.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Jumpy.Shared/JumpyGame.cs b/Jumpy.Shared/JumpyGame.cs index a4babd3..5bccb6e 100644 --- a/Jumpy.Shared/JumpyGame.cs +++ b/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("font"); player = new Player(Content.Load("player_1x")); grassland = Content.Load("grassland"); + grasslandBg1 = Content.Load("grassland_bg1"); + grasslandBg2 = Content.Load("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);