X hits on this document

274 views

0 shares

0 downloads

0 comments

39 / 102

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

   cloud2Position = new Vector2(64, 90);

   // Define initial HUD positions

   playerHUDPosition = new Vector2(7, 7);

   computerHUDPosition = new Vector2(613, 7);

   windArrowPosition = new Vector2(345, 46);

   // Initialize human & AI players

   player = new Human(ScreenManager.Game, ScreenManager.SpriteBatch);

   player.Initialize();

   player.Name = "Player";

   computer = new AI(ScreenManager.Game, ScreenManager.SpriteBatch);

   computer.Initialize();

   computer.Name = "Phone";

   // TODO: Initialize enemy definitions

   base.LoadContent();

   // Start the game

   Start();

}

Notice that we have left a placeholder in the code where future code will designate the human and AI players as enemies.

91.

Add the Start helper methods, which deals with initializations directly related to the beginning of the game:

C#

void Start()

{

   // Set initial wind direction

   wind = Vector2.Zero;

   isHumanTurn = false;

   changeTurn = true;

   // computer.Catapult.CurrentState = CatapultState.Reset;

}

The line that is currently commented out in the above code will later incorporate with other game logic in order to properly set up the game’s turn cycle.

92.

Add a pair of methods to the GameplayScreen class. These methods will be used to draw text to the screen with a shadow effect:

C#

// A simple helper to draw shadowed text.

void DrawString(SpriteFont font, string text, Vector2 position, Color color)

Page | 39

Document info
Document views274
Page views274
Page last viewedFri Dec 09 03:34:54 UTC 2016
Pages102
Paragraphs3115
Words17333

Comments