using System;
using AgkSharp;
using AGKCore;

namespace ChainShape
{

    static class Program
    {
        /// <summary>
        /// Der Haupteinstiegspunkt für die Anwendung.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Core.CreateWin32Window("ChainShape", 1024, 768, false);
            if (!Core.InitAGK())
                return;

            // set window properties
            Agk.SetWindowAllowResize(1); // allow the user to resize the window

            // set display properties
            Agk.SetVirtualResolution(1024, 768); // doesn't have to match the window
            Agk.SetOrientationAllowed(1, 1, 1, 1); // allow both portrait and landscape on mobile devices
            Agk.SetSyncRate(30, 0); // 30fps instead of 60 to save battery
            Agk.SetScissor(0, 0, 0, 0); // use the maximum available screen space, no black borders
            Agk.UseNewDefaultFonts(1); // since version 2.0.22 we can use nicer default fonts

            Agk.SetPhysicsScale(0.1f);
            Agk.SetPhysicsDebugOn();

            // create a ball
            Agk.LoadImage(1, "media/ball-64.png");
            Agk.CreateSprite(1, 1);
            Agk.SetSpriteSize(1, 50, 50);
            Agk.SetSpritePosition(1, 50, 100);
            // make it a circel
            Agk.SetSpriteShape(1, 1);
            // make it dynamic
            Agk.SetSpritePhysicsOn(1, 2);

            // create a terrain
            Agk.CreateDummySprite(2);
            // place it at 0,0 so we can use world coordinates for the vertices
            Agk.SetSpritePositionByOffset(2, 0, 0);
            Agk.SetSpriteShapeChain(2, 10, 0, 0, 20, 400, 1);
            Agk.SetSpriteShapeChain(2, 10, 1, 0, 80, 500, 1);
            Agk.SetSpriteShapeChain(2, 10, 2, 0, 210, 550, 1);
            Agk.SetSpriteShapeChain(2, 10, 3, 0, 300, 570, 1);
            Agk.SetSpriteShapeChain(2, 10, 4, 0, 360, 570, 1);
            Agk.SetSpriteShapeChain(2, 10, 5, 0, 430, 535, 1);
            Agk.SetSpriteShapeChain(2, 10, 6, 0, 484, 500, 1);
            Agk.SetSpriteShapeChain(2, 10, 7, 0, 532, 520, 1);
            Agk.SetSpriteShapeChain(2, 10, 8, 0, 600, 600, 1);
            Agk.SetSpriteShapeChain(2, 10, 9, 0, 715, 626, 1);
            // make it static
            Agk.SetSpritePhysicsOn(2, 1);

            while (Core.LoopAGK())
            {
                Agk.Sync();
            }

            Core.CleanUp();
        }
    }
}
