All pastes #503813 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-05-23 01:31 UTC
rendered paste body
#region Using Statements
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
#endregion

namespace SpaceWars2D
{
    class Player
    {
        private Texture2D texture;
        private Vector2 position = new Vector2(20,20);
        private Vector2 velocity;
        private Color color;

        private Vector2 MAX_SPEED = new Vector2(5,5);

        private float rotation = 0.0f;

        private int width;
        private int height;

        #region Properties
        public Texture2D Texture
        {
            get { return texture; }
            set { texture = value; }
        }

        public Vector2 Position
        {
            get { return position; }
            set { position = value; }
        }

        public Vector2 Velocity
        {
            get { return velocity; }
            set { velocity = value; }
        }

        public Vector2 MAXSPEED
        {
            get { return MAX_SPEED; }
        }

        public int Width
        {
            get { return width; }
            set { width = value; }
        }

        public int Height
        {
            get { return height; }
            set { height = value; }
        }

        public Color Color
        {
            get { return color; }
            set { color = value; }
        }
        #endregion

        #region Moving Methods

        public void Move()
        {
            velocity = new Vector2(
            GamePad.GetState(PlayerIndex.One).ThumbSticks.Left.X,
            GamePad.GetState(PlayerIndex.One).ThumbSticks.Left.Y);

            float X, Y;

            X = position.X + (velocity.X * MAX_SPEED.X);
            Y = position.Y - (velocity.Y * MAX_SPEED.Y);

            position = new Vector2(X, Y);

        }
        public void GetRotation()
        {

        }


        #endregion
        #region Class Specific Methods
        public  void Initialize()
        {

        }


        public void Draw(SpriteBatch spriteBatch)
        {
          //  Vector2 positionVector = new Vector2(this.position.X, this.position.Y);
            Vector2 originVector = Vector2.Zero;
            Rectangle sourceRectangle = new Rectangle(0, 0, this.width, this.height);

            spriteBatch.Draw(texture,           //texture
                            position,     //Placement of theSprite
                            sourceRectangle,    //Source Rectangle
                            color,               //Color(Tint)
                            0.0f,               // Rotation
                            originVector,       //Origin of Sprite
                            1.0f,               //Scale
                            SpriteEffects.None, //Sprite Effects
                            0.5f);      //Layer
        }
        #endregion
    }
}