I was actually surprised how simple it was to implement the parallaxing background. I thought there would have been some special function, but nope just creating multiple background variables.
CODE:
// Parallaxing Layers
Background bgLayer1;
Background bgLayer2;
Background bgLayer3;
...
//Initializing the backgrounds
protected override void Initialize()
{
PositionMenu.X = 0;
PositionMenu.Y = 0;
// TODO: Add your initialization logic here
bgLayer1 = new Background();
bgLayer2 = new Background();
bgLayer3 = new Background();
game = false;
base.Initialize();
}
...
//Loading in the files into the game world used for the backgrounds
protected override void LoadContent()
{
device = graphics.GraphicsDevice;
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
screenWidth = device.PresentationParameters.BackBufferWidth;
screenWidth = device.PresentationParameters.BackBufferWidth;
mainmenu = Content.Load
dashboard = Content.Load
// Load the parallaxing background
bgLayer3.Initialize(Content, "bglayer2lvl1", GraphicsDevice.Viewport.Width, -2);
bgLayer2.Initialize(Content, "bglayer1lvl1", GraphicsDevice.Viewport.Width, -1);
bgLayer1.Initialize(Content, "mainbackgroundlvl1", GraphicsDevice.Viewport.Width, 0);
...
//Then ya need to actually draw and update them :D
I don't know why I thought it would be more complex than just putting in more background variables, but sure it ended up being just that simple. Despite being straight it does actually look rather nice. Here is a video of it running. Graphically I think the game is coming along nicely, still have to figure out how to get the sprite sheet working to animate the players.












