public Game() { // Create the main window window = new RenderWindow( new VideoMode(Configuration.Width, Configuration.Height), "World Simulation", Styles.Fullscreen, new ContextSettings() { AntialiasingLevel = 8 }); // Set our frame rate to 60fps so the screen is responsive. window.SetFramerateLimit(60); // Handle window events window.Closed += OnClose; window.Resized += OnResize; // Create our world world = new World(); screenManager = new ScreenManager(window); // Create a simulation screen. Note that screens can be stacked on top of one another // in the screen manager that has been omitted from this specific repository. pathScreen = new SimulationScreen(window, Configuration.SinglePlayer); paretoScreen = new ParetoVisualScreen(window, Configuration.SinglePlayer, world.Population); // Add the screens to the manager screenManager.AddScreen(paretoScreen); screenManager.AddScreen(pathScreen); // Configure the pareto screen to be centred, hidden & appropriately sized SetParetoConfiguration(); // Clock to track frame time. If we dont do this, and instead assume we are hitting 60fps, we can get stutters // in our camera movement. clock = new Clock(); // Create a new generation clock to only DoGeneration once per second. generationClock = new Clock(); }
public static void ShowPopulation(List <Individual> population) { // Create the main window var window = new RenderWindow( new VideoMode(1920 / 2, 1080 / 2), "Population Visualisation", Styles.Titlebar, new ContextSettings() { AntialiasingLevel = 8 }); // Set our frame rate to 60fps so the screen is responsive. window.SetFramerateLimit(60); // Handle window events window.Closed += (sender, b) => ((RenderWindow)sender).Close(); var paretoScreen = new ParetoVisualScreen(window, Configuration.SinglePlayer, population); paretoScreen.Camera.SetCentre(new Vector2f(1880, 950)); paretoScreen.Camera.GetView().Zoom(0.15f); paretoScreen.Update(2f); window.SetView(paretoScreen.Camera.GetView()); while (!Keyboard.IsKeyPressed(Keyboard.Key.Escape) && !Keyboard.IsKeyPressed(Configuration.QuitKey) && window.IsOpen) { // Clear the previous frame window.Clear(Configuration.Background); // Process events window.DispatchEvents(); paretoScreen.Draw(0.16f); window.Display(); Thread.Sleep(16); } }