O'Reilly logo

XNA 4.0 Game Development by Example Beginner's Guide by Kurt Jaegers

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action - summoning up the zombies

  1. Add a new class called Enemy to the Gemstone Hunter project.
  2. Add the following using directives to the Enemy class:
    using Microsoft.Xna.Framework;
    using Microsoft.Xna.Framework.Content;
    using Microsoft.Xna.Framework.Graphics;
    using Tile_Engine;
    
  3. Modify the class declaration for the Enemy class to make it public and derive it from the GameObject class:
    public class Enemy : GameObject
    
  4. Add declarations for the Enemy class:
    private Vector2 fallSpeed = new Vector2(0, 20);
    private float walkSpeed = 60.0f;
    private bool facingLeft = true;
    public bool Dead = false;
    
  5. Add a constructor for the Enemy class:
    #region Constructor public Enemy(ContentManager content, int cellX, int cellY) { animations.Add("idle", new AnimationStrip( ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required