All pastes #2124832 Raw Edit

Stuff

public text v1 · immutable
#2124832 ·published 2012-03-06 16:13 UTC
rendered paste body
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
{
    /// <summary>
    /// This is a game component that implements IUpdateable.
    /// </summary>
    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;
        }

        /// <summary>
        /// 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.
        /// </summary>
        public override void Initialize()
        {
            // TODO: Add your initialization code here
            base.Initialize();
        }

        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        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<Texture2D>("soldier");
        }

        public bool Move()
        {
            this.position.Y += velocity;
            return true;
        }
    }
}