Game-Design / Sprint3_actual / ActiveItems / RightArrowSprite.cs
RightArrowSprite.cs
Raw
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Sprint3_actual.StateFiles;
using System;
using System.Collections.Generic;
using System.Text;

namespace Sprint3_actual.ActiveItems
{
    class RightArrowSprite : AItemSprites
    {
        public Texture2D Texture { get; set; }
        public Arrow arrow;
        public int SpriteWidth { get; set; }
        private int SpriteHeight { get; set; }
        public int SpriteX { get; set; }
        public int SpriteY { get; set; }

        public RightArrowSprite(Arrow arrow, Texture2D texture)
        {
            this.arrow = arrow;
            Texture = texture;
            SpriteHeight = 5;
            SpriteWidth = 16;
            SpriteX = 10;
            SpriteY = 190;
        }
        public override void draw()
        {
            Rectangle sourceRectangle;
            Rectangle destinationRectangle;
            if (!arrow.HasCollided())
            {
                sourceRectangle = new Rectangle(SpriteX, SpriteY, SpriteWidth, SpriteHeight);
                destinationRectangle = arrow.PositionRectangle();
            }
            else
            {
                sourceRectangle = new Rectangle(53, 189, 8, 8);
                destinationRectangle = new Rectangle(arrow.PositionRectangle().Right - 16, arrow.ItemY, GlobalVars.activeitemWH, GlobalVars.activeitemWH);
            }
            GlobalVars.spriteBatch.Draw(Texture, destinationRectangle, sourceRectangle, Color.White, 0f, Vector2.Zero, SpriteEffects.None, 0f);
        }

        public override void update(GameTime gameTime)
        {
            if (arrow.IsRemoved())
                IsRemoved = true;
        }
    }
}