X hits on this document





42 / 102

           text = "NONE";

           DrawString(hudFont, text, windArrowPosition, Color.Black);


       if (isHumanTurn)


           // Prepare human prompt message

           text = !isDragging ?

               "Drag Anywhere to Fire" : "Release to Fire!";

           size = hudFont.MeasureString(text);




           // Prepare AI message

           text = "I'll get you yet!";

           size = hudFont.MeasureString(text);


       DrawString(hudFont, text,

           new Vector2(

               ScreenManager.GraphicsDevice.Viewport.Width / 2 - size.X / 2,

               ScreenManager.GraphicsDevice.Viewport.Height - size.Y),




Let us review this rather lengthy method.

First, we check to see whether the game is over, drawing a victory/defeat banner according to how the game ended.

If the game has not yet ended, we then draw two nearly identical elements portraying the status of both players. Each element is composed of a background image, text depicting the player’s name and score, and finally a graphical representation of the type of ammunition the player is currently using (though our final game will not actually present the player with different types of ammunition, this serves as an extension point for such a feature).

After drawing both player statuses, we draw an indicator that notifies the player of the direction of the wind. The purpose of the wind within the frame of the game is to make it more challenging for the player to aim, as it affects the course of his shot. The wind in the game will blow to the left or right at a varying strength or will not blow at all. Instead of representing the wind as a scalar value, it is represented by the “wind” 2D vector. The wind’s X component denotes its direction and its Y component denotes its strength. If we examine the code that draws the wind indicator, we can see that first the word “WIND” is drawn on the display, followed either by an arrow representing the magnitude of which the wind currently blows or by the text “NONE” if there is currently no wind.

Page | 42

Document info
Document views145
Page views145
Page last viewedSun Oct 23 18:16:29 UTC 2016