X hits on this document

213 views

0 shares

0 downloads

0 comments

35 / 102

Figure 25

First look at the gameplay screen

Right now, the gameplay screen is somewhat barren, so next we will add the Heads-up-display (HUD) for the game. The HUD is the portion of the game’s interface that displays vital information to the user such as the current score.

However, we will also need some additional variables to keep track of the information we are about to display and it will be a great opportunity to introduce some of the game classes in order to encapsulate some of the information.

Our first task, therefore, will be to create basic versions of the Player class and its two sub-classes – Human and AI.

75.

Create a new project folder under the CatapultGame project and name it Players.

76.

Create a new class under the Players project folder and name it Player.

77.

At the top of the newly created class file, add the following using statements:

C#

using Microsoft.Xna.Framework;

using Microsoft.Xna.Framework.Graphics;

78.

Since the player will eventually be responsible for drawing its associated catapult, it could be considered a game component that can be drawn to the screen. Change the Player class to inherit from the DrawableGameComponent class, and also make it internal since it will eventually contain some data which is internal to the game:

C#

internal class Player : DrawableGameComponent

Page | 35

Document info
Document views213
Page views213
Page last viewedSat Dec 03 00:36:55 UTC 2016
Pages102
Paragraphs3115
Words17333

Comments