Esempio n. 1
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main(string[] args)
        {
            // SET THE SETTINGS HERE
            settings.DepthBits         = 24;
            settings.StencilBits       = 8;
            settings.AntialiasingLevel = 4;
            settings.MajorVersion      = 3;
            settings.MinorVersion      = 0;

            window   = new RenderWindow(new SFML.Window.VideoMode(windowWidth, windowHeight, windowDepth), "Unnamed Game Engine", Styles.Default, settings); // Create a new game window
            renderer = new Renderer(window);                                                                                                                 // Create the renderer
            window.SetVerticalSyncEnabled(true);                                                                                                             // Vertical Sync

            window.Closed  += WinClosed;
            window.Resized += WinResized;

            float lastTime = 0.0f; // The last calculated time

            // Main game loop
            while (window.IsOpen)
            {
                window.DispatchEvents();
                window.Clear(); // Clear the screen

                // DO LOOP AND DRAWING HERE

                // Draw a basic orange line
                renderer.DrawSetColor(Colors.RGB(1.0f, 0.5f, 0));
                renderer.DrawRectangle(64, 32, 64 + 32, 32 + 32, false);

                // Everything before here needs to be rendered
                window.Display();

                // Calculate FPS
                float currentTime = clock.Restart().AsSeconds();
                fps      = 1.0f / lastTime;// (currentTime - lastTime);
                lastTime = currentTime;

                // Set the title with the frames per second
                window.SetTitle("Unnamed Game Engine (FPS: " + ((int)fps).ToString() + ")");
            }
        }