using System;
using AgkSharp;
using AGKCore;

namespace SpriteTest0
{
    
    static class Program
    {
        /// <summary>
        /// Der Haupteinstiegspunkt für die Anwendung.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Core.CreateWin32Window("AGK-Title", 640, 480, false);
            if (!Core.InitAGK())
                return;

            Agk.SetVirtualResolution(320, 480);

            // display a background
            AgkSprite back = new AgkSprite("media/background.jpg");

            AgkImage image = new AgkImage("media/item0.png");   // load/create image
            AgkSprite sprite = new AgkSprite(image);            // create sprite from image
            AgkSprite sprite2 = new AgkSprite(sprite);          // clone sprite from sprite

            // set sprite position
            sprite.SetPositionByOffset(160, 240);               
            sprite2.SetPositionByOffset(64, 64);

            // add animation frames to sprite
            sprite.AddAnimationFrame(new AgkImage("media/item1.png"));  
            sprite.AddAnimationFrame(new AgkImage("media/item2.png"));
            sprite.AddAnimationFrame(new AgkImage("media/item3.png"));
            sprite.AddAnimationFrame(new AgkImage("media/item4.png"));

            // plays the animation of the sprite
            sprite.Play(10, true, 1, 5);

            // create a text
            AgkText text = new AgkText()
            {
                Alignment = EAlignment.Center,
                Size = 24.0f,
                Position = new AGKVector2(160, 0),
                Label = "MadBit's\nTest String"
            };

            while (Core.LoopAGK())
            {
                back.Draw();

                sprite2.Draw();

                sprite.UpdateAnimation(Agk.GetFrameTime());
                sprite.Draw();

                text.Draw();

                Agk.Sync();
            }

            Core.CleanUp();
        }
    }
}
