private static void Main() { if (!false) // Run in the background { using (var simulation = new WalkerDemo()) { var start = System.DateTime.UtcNow; simulation.RunPhysics(canContinue: () => (System.DateTime.UtcNow - start).TotalSeconds < -5); // Run for a few secs } } ContentArchive content; using (var stream = typeof(Demos.DemoHarness).Assembly.GetManifestResourceStream("Demos.Demos.contentarchive")) { content = ContentArchive.Load(stream); } using (var window = new DemoEngine.Window("SharpNeat Walker", new Int2((int)(DisplayDevice.Default.Width * 0.75f), (int)(DisplayDevice.Default.Height * 0.75f)), WindowMode.Windowed)) using (var loop = new GameLoop(window)) { var harness = new DemoHarness(loop, content, customDemoSet: new DemoSet().AddOption <WalkerDemo>()); loop.Run(harness); } /*var loop = new GameLoop(window); * var demo = new DemoHarness(loop, content, customDemoSet: new DemoSet().AddOption<Walker>()); * loop.Run(demo); * loop.Dispose();*/ }
public void CheckForDemoSwap(DemoHarness harness) { if (harness.input.WasPushed(harness.controls.ChangeDemo.Key)) { TrackingInput = !TrackingInput; TargetDemoIndex = -1; } if (TrackingInput) { for (int i = 0; i < harness.input.TypedCharacters.Count; ++i) { var character = harness.input.TypedCharacters[i]; if (character == '\b') { //Backspace! if (TargetDemoIndex >= 10) { TargetDemoIndex /= 10; } else { TargetDemoIndex = -1; } } else { if (TargetDemoIndex < harness.demoSet.Count) { var digit = character - '0'; if (digit >= 0 && digit <= 9) { TargetDemoIndex = Math.Max(0, TargetDemoIndex) * 10 + digit; } } } } if (harness.input.WasPushed(OpenTK.Input.Key.Enter)) { //Done entering the index. Swap the demo if needed. TrackingInput = false; harness.TryChangeToDemo(TargetDemoIndex); } } }