using System; using System.Collections.Generic; using System.Linq; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.GamerServices; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Media; namespace HeavyWeapon { /// /// This is a game component that implements IUpdateable. /// public class Soldier : Microsoft.Xna.Framework.DrawableGameComponent { Texture2D texture; Vector2 position; float velocity; SpriteBatch sBatch; public Soldier(Game game, Vector2 position, float velocity) : base(game) { // TODO: Construct any child components here this.position = position; this.velocity = velocity; } /// /// Allows the game component to perform any initialization it needs to before starting /// to run. This is where it can query for any required services and load content. /// public override void Initialize() { // TODO: Add your initialization code here base.Initialize(); } /// /// Allows the game component to update itself. /// /// Provides a snapshot of timing values. public override void Update(GameTime gameTime) { // TODO: Add your update code here Move(); base.Update(gameTime); } public override void Draw(GameTime gameTime) { sBatch = (SpriteBatch)Game.Services.GetService(typeof(SpriteBatch)); sBatch.Draw(texture, position, Color.White); base.Draw(gameTime); } public void LoadContent(ContentManager Content) { texture = Content.Load("soldier"); } public bool Move() { this.position.Y += velocity; return true; } } }