예제 #1
0
        /// <summary>
        /// Runs main Visualisation loop.
        /// </summary>
        public void Run()
        {
            var mode   = new SFML.Window.VideoMode(width, height);
            var window = new SFML.Graphics.RenderWindow(mode, visualisation.GetType().ToString());

            window.KeyPressed += Window_KeyPressed;
            window.SetFramerateLimit(FPS);

            // Start the game loop
            while (window.IsOpen)
            {
                visualisation.Update();
                window.Clear();

                // Process events
                window.DispatchEvents();
                visualisation.Draw(window);
                // Finally, display the rendered frame on screen
                window.Display();
            }

            visualisation.Quit();
            soundBuffer.Dispose();
            window.Close();
        }
예제 #2
0
        public IGraphicsContext CreateWindow(string title, Size size, SFML.Window.Styles style = SFML.Window.Styles.Default)
        {
            SFML.Window.ContextSettings contextSettings = new SFML.Window.ContextSettings(24, 8, 8);
            var mode   = new SFML.Window.VideoMode((uint)size.Width, (uint)size.Height);
            var window = new SFML.Graphics.RenderWindow(mode, title, style);

            window.SetFramerateLimit(_frameRate);
            return(new GraphicsContext(window));
        }
예제 #3
0
        // Init the game window
        private void InitAndConfigureWindow()
        {
            var mode = new SFML.Window.VideoMode(800, 600);

            window = new SFML.Graphics.RenderWindow(mode, "Interloper");
            window.SetFramerateLimit(60);
            window.KeyPressed += HandleKeypress;

            clock = new SFML.System.Clock();
        }
예제 #4
0
        override internal void handle(msg.Startup startup)
        {
            base.handle(startup);

            var mode = new SFML.Window.VideoMode(1280, 1024);

            m_window             = new SFML.Graphics.RenderWindow(mode, "Client");
            m_window.KeyPressed += Window_KeyPressed;

            m_state = State.Running;
        }
예제 #5
0
        static void Main(string[] args)
        {
            SFML.Window.VideoMode      mode   = new SFML.Window.VideoMode(800, 600);
            SFML.Graphics.RenderWindow window = new SFML.Graphics.RenderWindow(mode, "Flappy Bird");
            GameState myState = new GameState();

            while (true)
            {
                myState.Update();
                myState.Draw(window);
            }
        }
예제 #6
0
        public void Run()
        {
            GameManager gameManager = new GameManager();
            //Window Options
            var mode   = new SFML.Window.VideoMode(WINDOW, WINDOW);
            var window = new SFML.Graphics.RenderWindow(mode, "Malikaz Snake");

            //Keyboard Event Handlers
            window.KeyPressed += Window_KeyPressed;
            window.KeyPressed += gameManager.SetMoveDirection;
            window.KeyPressed += gameManager.RestartGame;


            //Time
            DateTime timer1 = DateTime.Now;

            // Start the game loop
            while (window.IsOpen)
            {
                System.Threading.Thread.Sleep(5);
                //Clear Window
                window.Clear();
                DateTime timer2 = DateTime.Now;

                // Process events
                window.DispatchEvents();
                TimeSpan timeSinceLastUpdate = timer2 - timer1;
                if (timeSinceLastUpdate.TotalSeconds >= .1 && gameManager.GameIsActive == true)
                {
                    gameManager.MoveSnake(ref gameManager.snakeArray);
                    gameManager.CheckForColision(ref gameManager.snakeArray, ref gameManager.food);
                    timer1 = DateTime.Now;
                }
                else if (gameManager.GameIsActive == false)
                {
                    window.Draw(gameManager.gameText.GameOverText);
                }
                for (int counter = 0; counter < gameManager.snakeArray.Length; counter++)
                {
                    if (gameManager.snakeArray[counter].IsActive == true)
                    {
                        window.Draw(gameManager.snakeArray[counter].SnakeShape);
                    }
                }

                window.Draw(gameManager.gameText.ScoreText);
                window.Draw(gameManager.food.FoodShape);


                // Finally, display the rendered frame on screen
                window.Display();
            }
        }
        public void Run()
        {
            var mode   = new SFML.Window.VideoMode(800, 600);
            var window = new SFML.Graphics.RenderWindow(mode, "SFML works!");

            window.KeyPressed += Window_KeyPressed;

            var circle = new SFML.Graphics.CircleShape(100f)
            {
                FillColor = SFML.Graphics.Color.Blue
            };

            // Start the game loop
            while (window.IsOpen)
            {
                // Process events
                window.DispatchEvents();
                window.Draw(circle);

                // Finally, display the rendered frame on screen
                window.Display();
            }
        }
예제 #8
0
            public void Run()
            {
                var mode   = new SFML.Window.VideoMode(800, 600);
                var window = new SFML.Graphics.RenderWindow(mode, "SFML works!");



                window.KeyPressed += Window_KeyPressed;

                var circle = new SFML.Graphics.CircleShape(100f)
                {
                    FillColor = SFML.Graphics.Color.Blue
                };
                Clock clock = new Clock();


                window.SetActive(true);
                //window.PushGLStates();
                GuiImpl.Init(window);
                //window.PopGLStates();
                window.SetActive(false);


                Image   image   = new Image(100, 100, Color.Red);
                Texture texture = new Texture(image);

                // Start the game loop
                while (window.IsOpen)
                {
                    // Process events
                    window.DispatchEvents();
                    window.SetActive(true);
                    //window.PushGLStates();

                    GuiImpl.Update(window, clock.Restart());
                    ImGui.BeginMainMenuBar();
                    if (ImGui.BeginMenu("File"))
                    {
                        ImGui.MenuItem("Open");
                        ImGui.EndMenu();
                    }
                    ImGui.EndMainMenuBar();

                    ImGui.Begin("Hello, world!");
                    if (ImGui.Button("Look at this pretty button"))
                    {
                        System.Console.WriteLine("Hi!");
                    }

                    //System.Console.WriteLine(texture.NativeHandle);
                    ImGui.Image(new IntPtr(texture.NativeHandle), new System.Numerics.Vector2(200, 200));
                    ImGui.End();

                    ImGui.Begin("Hello, world!2");
                    if (ImGui.Button("Look at this pretty button22"))
                    {
                        System.Console.WriteLine("Hi2!");
                    }
                    ImGui.Text("Hallo");
                    ImGui.End();
                    ImGui.Button("lll");

                    //window.PopGLStates();
                    window.SetActive(false);


                    window.Clear();
                    window.Draw(circle);
                    GuiImpl.Render();
                    // Finally, display the rendered frame on screen
                    window.Display();
                }
                GuiImpl.Shutdown();
            }