Esempio n. 1
0
        static void Main(string[] args)
        {
            Console.Title = "Nuklear SFML .NET";
            Stopwatch SWatch = Stopwatch.StartNew();

            VideoMode    VMode      = new VideoMode(1366, 768);
            RenderWindow RWind      = new RenderWindow(VMode, Console.Title, Styles.Close);
            Color        ClearColor = new Color(50, 50, 50);

            RWind.Closed += (S, E) => RWind.Close();

            SFMLDevice Dev = new SFMLDevice(RWind);

            RWind.MouseButtonPressed  += (S, E) => Dev.OnMouseButton((NuklearEvent.MouseButton)E.Button, E.X, E.Y, true);
            RWind.MouseButtonReleased += (S, E) => Dev.OnMouseButton((NuklearEvent.MouseButton)E.Button, E.X, E.Y, false);
            RWind.MouseMoved          += (S, E) => Dev.OnMouseMove(E.X, E.Y);
            RWind.MouseWheelMoved     += (S, E) => Dev.OnScroll(0, E.Delta);
            RWind.TextEntered         += (S, E) => Dev.OnText(E.Unicode);
            RWind.KeyPressed          += (S, E) => OnKey(Dev, E, true);
            RWind.KeyReleased         += (S, E) => OnKey(Dev, E, false);

            NuklearAPI.Init(Dev);

            NuklearCalculator CalcA = new NuklearCalculator("Calc A", 50, 50);
            NuklearCalculator CalcB = new NuklearCalculator("Calc B", 300, 50);

            float Dt = 0.1f;

            while (RWind.IsOpen)
            {
                RWind.DispatchEvents();
                RWind.Clear(ClearColor);

                NuklearAPI.SetDeltaTime(Dt);
                NuklearAPI.Frame(() => {
                    if (CalcA.Open)
                    {
                        CalcA.Calculator();
                    }

                    if (CalcB.Open)
                    {
                        CalcB.Calculator();
                    }

                    TestWindow(400, 350);
                });

                RWind.Display();


                Dt = SWatch.ElapsedMilliseconds / 1000.0f;
                SWatch.Restart();
            }

            Environment.Exit(0);
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Console.Title = "Nuklear SFML .NET";

            Stopwatch SWatch     = Stopwatch.StartNew();
            Color     ClearColor = new Color(170, 80, 20);
            VideoMode VMode      = new VideoMode(1366, 768);

            RenderWindow RWind = new RenderWindow(VMode, Console.Title, Styles.Close);

            RWind.SetKeyRepeatEnabled(true);

            SFMLDevice Dev = new SFMLDevice(RWind);

            RWind.Closed              += (S, E) => RWind.Close();
            RWind.MouseButtonPressed  += (S, E) => Dev.OnMouseButton((NuklearEvent.MouseButton)E.Button, E.X, E.Y, true);
            RWind.MouseButtonReleased += (S, E) => Dev.OnMouseButton((NuklearEvent.MouseButton)E.Button, E.X, E.Y, false);
            RWind.MouseMoved          += (S, E) => Dev.OnMouseMove(E.X, E.Y);
            RWind.MouseWheelMoved     += (S, E) => Dev.OnScroll(0, E.Delta);
            RWind.KeyPressed          += (S, E) => OnKey(Dev, E, true);
            RWind.KeyReleased         += (S, E) => OnKey(Dev, E, false);
            RWind.TextEntered         += (S, E) => Dev.OnText(E.Unicode);

            Shared.Init(Dev);

            float Dt = 0.1f;

            while (RWind.IsOpen)
            {
                RWind.DispatchEvents();
                RWind.Clear(ClearColor);

                Shared.DrawLoop(Dt);

                RWind.Display();

                Dt = SWatch.ElapsedMilliseconds / 1000.0f;
                SWatch.Restart();
            }

            Environment.Exit(0);
        }