X hits on this document

256 views

0 shares

0 downloads

0 comments

49 / 102

void DrawComputer(GameTime gameTime)

{

   if (!gameOver)

       computer.Draw(gameTime);

}

115.

Finally, we must make the GameplayScreen class render both players. Open the GameplayScreen.cs file and navigate to the “Draw” method. Remove the comments on the lines which call the “DrawComputer” and “DrawPlayer” helper methods. The relevant portion of the code should now look like this:

C#

...

DrawBackground();

DrawComputer(gameTime);

DrawPlayer(gameTime);

DrawHud();

...

116.

Compile and deploy the project. After navigating to the game screen, the catapults should now be visible:

Figure 28

The catapults can now be seen

This concludes the first task of this exercise. During the next task we will implement the game’s logic, as right now the game merely draws its various elements to the screen.

Task 2 – Game logic

In the course of this task, we will add many elements that are still missing from the game. We will add a turn cycle alternating between the human and computer players, giving each a chance to take a shot at the enemy. This will include adding projectiles and their associated physics, handling user input, writing the AI logic and so on.

Page | 49

Document info
Document views256
Page views256
Page last viewedWed Dec 07 09:33:25 UTC 2016
Pages102
Paragraphs3115
Words17333

Comments