Example #1
0
        public Game(uint width, uint height)
        {
            RenderWindow window = new RenderWindow(new VideoMode(width, height), "TOU8HOU JAM 5 BABEY", Styles.Close);

            window.SetVerticalSyncEnabled(true);
            window.SetActive();
            Window = window;

            _viewSize = new Vector2f(width, height);
            View v = new View(new FloatRect(new Vector2f(0, 0), _viewSize));

            Window.SetView(v);

            //Window.Resized += (sender, eeee) =>
            //{
            //    Window.SetView(this.CalcView());
            //};

            AKS.InitializeWindow(window);

            this.clock = new Clock();

            window.Closed += (sender, e) =>
            {
                window.Close();
            };

            window.KeyPressed += (sender, e) =>
            {
                if (e.Code == Keyboard.Key.Escape)
                {
                    window.Close();
                }
            };

            // /////////////////////////////////////////////// //

            _battle = new Battle();

            this.Run();
        }
Example #2
0
        protected void Run()
        {
            while (Window.IsOpen)
            {
                AKS.Update();

                float delta = this.clock.Restart().AsSeconds();
                this.counter += delta;
                Window.DispatchEvents();

                if (this.counter >= this.framerate)
                {
                    int times = (int)(this.counter / this.framerate);
                    this.counter %= this.framerate;

                    for (int i = 0; i < times; i++)
                    {
                        this.Update(this.framerate);
                    }
                }

                this.Draw(Window);
            }
        }