Portfolio

Friday, June 15, 2012

I have just uploaded Cannon 2 it is a updated verison
of cannon 1 with Object-oriented programming. 
Check it out 
namespace cannon2
{
    class GameObject
    {
 
        private Point position;
        private Point velocity;
        private PictureBox texture;
 
        #region properties
 
        public Point Position
        {
            get { return position; }
            set { position = value; }
        }
        public Point Velocity
        {
            get { return velocity; }
            set { velocity = value; }
        }
        public PictureBox Texture
        {
            get { return texture; }
            set { texture = value; }
        }
        public Point origin
        {
            get
            {
                 return  new Point(texture.Width / 2texture.Height / 2);
            }
        }
 
        #endregion
 
        public void Update()
        {
            this.position = new Point(this.position.X + this.velocity.X,
                                        this.position.Y + this.velocity.Y);
        }
 
        public void Draw()
        {
            this.texture.Location = new Point(this.position.X - this.origin.X,
                                              this.position.Y - this.origin.Y);
        }
 
    }
}

No comments:

Post a Comment