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;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

using XNACS1Lib;

namespace ClassExample
{
    public class Game1 : XNACS1Base
    {
        XNACS1Rectangle Sprite;

        protected override void InitializeWorld()
        {
            Sprite = new XNACS1Rectangle(new Vector2(50,25), 10, 10);
            Sprite.SetTextureSpriteSheet("Sprites", 13, 16, 0);
            Sprite.UseSpriteSheet = true;
            Sprite.SetTextureSpriteAnimationFrames(0, 0, 1, 0, 5, SpriteSheetAnimationMode.AnimateForward);
            Sprite.UseSpriteSheetAnimation = true;
        }

        protected override void UpdateWorld()
        {
            if (GamePad.Dpad.Up == ButtonState.Pressed && (Sprite.CurrentSpriteSheetFrameX < 0 || Sprite.CurrentSpriteSheetFrameX > 1))
                Sprite.SetTextureSpriteAnimationFrames(0, 0, 1, 0, 5, SpriteSheetAnimationMode.AnimateForward);
            else if (GamePad.Dpad.Down == ButtonState.Pressed && (Sprite.CurrentSpriteSheetFrameX < 3 || Sprite.CurrentSpriteSheetFrameX > 4))
                Sprite.SetTextureSpriteAnimationFrames(3, 0, 4, 0, 5, SpriteSheetAnimationMode.AnimateForward);
            else if (GamePad.Dpad.Left == ButtonState.Pressed && (Sprite.CurrentSpriteSheetFrameX < 6 || Sprite.CurrentSpriteSheetFrameX > 7))
                Sprite.SetTextureSpriteAnimationFrames(6, 0, 7, 0, 5, SpriteSheetAnimationMode.AnimateForward);
            else if (GamePad.Dpad.Right == ButtonState.Pressed && (Sprite.CurrentSpriteSheetFrameX < 9 || Sprite.CurrentSpriteSheetFrameX > 10))
                Sprite.SetTextureSpriteAnimationFrames(9, 0, 10, 0, 5, SpriteSheetAnimationMode.AnimateForward);
        }
    }
}
