Time for action – creating the Player class
- Add a new class file called
Player.cs
to the Gemstone Hunter project. - Add the following
using
directives to the Player class:using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Input; using Tile_Engine;
- Modify the declaration of the Player class to make it public, and derive from the GameObject class:
public class Player : GameObject
- Add declarations to the Player class:
private Vector2 fallSpeed = new Vector2(0, 20); private float moveScale = 180.0f; private bool dead = false;
- Add the
Dead
property to the Player class:public bool Dead { get { return dead; } }
- Create a constructor for the Player class:
#region Constructor ...
Get XNA 4.0 Game Development by Example Beginner's Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.