X hits on this document

236 views

0 shares

0 downloads

0 comments

33 / 102

public override void LoadContent()

{

   // Load textures

   foregroundTexture =

       Load<Texture2D>("Textures/Backgrounds/gameplay_screen");

   cloud1Texture = Load<Texture2D>("Textures/Backgrounds/cloud1");

   cloud2Texture = Load<Texture2D>("Textures/Backgrounds/cloud2");

   mountainTexture = Load<Texture2D>("Textures/Backgrounds/mountain");

   skyTexture = Load<Texture2D>("Textures/Backgrounds/sky");

   defeatTexture = Load<Texture2D>("Textures/Backgrounds/defeat");

   victoryTexture = Load<Texture2D>("Textures/Backgrounds/victory");

   hudBackgroundTexture = Load<Texture2D>("Textures/HUD/hudBackground");

   windArrowTexture = Load<Texture2D>("Textures/HUD/windArrow");

   ammoTypeTexture = Load<Texture2D>("Textures/HUD/ammoType");

   // Load font

   hudFont = Load<SpriteFont>("Fonts/HUDFont");

   // Define initial cloud position

   cloud1Position = new Vector2(224 - cloud1Texture.Width, 32);

   cloud2Position = new Vector2(64, 90);

}

71.

Override the Draw method so that the gameplay screen will be able to draw itself onto the screen:

C#

public override void Draw(GameTime gameTime)

{

   float elapsedTime = (float)gameTime.ElapsedGameTime.TotalSeconds;

   ScreenManager.SpriteBatch.Begin();

   // Render all parts of the screen

   DrawBackground();

   // DrawComputer(gameTime);

   // DrawPlayer(gameTime);

   // DrawHud();

   ScreenManager.SpriteBatch.End();

}

Notice that the Draw method is implemented using several helper methods which draw different aspects of the game. Most of them are currently commented out and we will deal with them later in the exercise.

72.

Add the DrawBackground helper method which draws the various background elements:

C#

private void DrawBackground()

{

Page | 33

Document info
Document views236
Page views236
Page last viewedMon Dec 05 05:38:07 UTC 2016
Pages102
Paragraphs3115
Words17333

Comments