Time for action – building the Enemy class
Add a new class called Enemy to the Robot Rampage project.
Add the following
using
directives to the top of the class file:using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics;
Add declarations to the Enemy class:
#region Declarations public Sprite EnemyBase; public Sprite EnemyClaws; public float EnemySpeed = 60f; public Vector2 currentTargetSquare; public bool Destroyed = false; private int collisionRadius = 14; #endregion
Add a constructor to the Enemy class:
#region Constructor public Enemy( Vector2 worldLocation, Texture2D texture, Rectangle initialFrame) { EnemyBase = new Sprite( worldLocation, texture, initialFrame, Vector2.Zero); EnemyBase.CollisionRadius = collisionRadius; Rectangle turretFrame = initialFrame; turretFrame.Offset(0, initialFrame.Height); EnemyClaws = new Sprite( worldLocation, texture, turretFrame, Vector2.Zero...